Expand description
This crate provides the Parasol processor for running programs over encrypted data. The general workflow for using it is:
- Compile a program using Parasol-clang
- Encrypt our data and create an
CallDataobject. - Call
FheComputer::run_program, passing our key, program binary, the name of the program we want to run, and args. - Return or decrypt your program’s result.
§Example
ⓘ
use parasol_cpu::{run_program, ArgsBuilder};
use parasol_runtime::{ComputeKey, Encryption, PublicKey, SecretKey, fluent::Uint};
// Embed the compiled Parasol add program into a constant.
const FHE_FILE: &[u8] = include_bytes!("../data/add");
// Generate a secret key for the user. By default this ensures
// 128-bit security.
let secret_key =
SecretKey::generate_with_default_params();
// Generate a compute key for the user. These keys are used for
// operations and do not give access to the plaintext data;
// therefore, this key can safely be shared with another party.
let compute_key =
ComputeKey::generate_with_default_params(
&secret_key,
);
// Generate a public key that can be shared, allowing
// users to encrypt (but not decrypt) their data. By default
// this ensures 128-bit security.
let public_key =
PublicKey::generate_with_default_params();
// Define the values we want to add. The values'
// sizes must match the Parasol C program's parameters
// when we encrypt them. Create the arguments and specify
// the return type
let enc = Encryption::default();
let args = ArgsBuilder::new()
.arg(UInt8::encrypt(2, &enc, &public_key))
.arg(UInt8::encrypt(7, &enc, &public_key))
.return_value::<UInt8>();
// Run the program.
let encrypted_result = run_program(
compute_key.clone(),
FHE_FILE,
"add",
&args,
)
.unwrap();
// Decrypt the result.
let result = encrypted_result.decrypt(&enc, &secret_key);
println!("Encrypted {a} + {b} = {result}");Modules§
Macros§
- define_
op - Define the list of opcodes for the processors ISA.
- dep_idx
- Return an expression that evaluates to
$idx_ident’s index in$($src_name)*. - rep_len
- Emit an expression that evaluates to the length of a macro rep expression.
Structs§
- Allocation
- A structure for efficiently placing multiple allocations into a single page allocation request.
- Arg
- The info needed to pass an argument to a function from the host program.
- Args
Builder - A type for passing arguments to Parasol programs. When invoking
crate::FheComputer::run_program, the processor will transparently set up the registers and first stack frame according to Parasol ABI’s calling convention. - Call
Data - Arguments passed to an FHE program when calling
crate::FheComputer::run_program. - FheComputer
- The Parasol processor that can run programs over encrypted and plaintext data.
- Memory
- The memory used by a
crate::FheComputerduring computation. The Parasol processor uses a Von Neumann architecture, meaning - Memory
Config - Configuration used when building a memory object.
- Memory
Config Builder - A builder for constructing a
MemoryConfigobject. - Ptr32
- A 32-bit pointer.
- Return
Value - The info needed to capture the return value from an FHE program on the host.
- RunProgram
Options - Options for running
FheComputer::run_program_with_options - RunProgram
Options Builder - Builder pattern for
RunProgramOptions - Word
- An encrypted or unencrypted 32-bit value.
Enums§
- Byte
- An 8-bit encrypted or plaintext value.
- Error
- Errors that can occur in this crate.
- Extend
- How to extend an N-byte value to M >= N byte value.
Constants§
- PAGE_
SIZE - The number of bytes in a page.
Traits§
- Dynamic
ToArg - Similar to
ToArgbut the alignment and size are figured out from the instance not just the type - ToArg
- A trait specifying how to convert this value to a form that can be passed as an FHE program argument.
Functions§
- check_
register_ width - Checks if the width of two registers is the same. Used inside an instruction implementation.
- register_
to_ l1glwe_ by_ trivial_ lift - Convert a plaintext register to a L1 GLWE ciphertext register, or copy the existing ciphertext register if it’s already in that form.
- run_
program - Runs a program by generating a new
crate::FheComputer. This function is meant for simple testing of a program; for full applications see thecrate::FheComputerstruct.
Type Aliases§
- Result
- Results for this crate.
Derive Macros§
- Into
Bytes - Allows you to
#[derive(IntoBytes)]on structures where each member implsIntoBytes