Expand description
This crate provides a number of types and methods for interacting with the Parasol processor and FHE.
Furthermore, the circuits module provides FheCircuit generators that build circuits
for performing integer computation.
Additionally, the fluent module provides convenient and readable builders for constructing
circuits over integers that one can directly run on a CircuitProcessor and perform low-level
operations, such as ciphertext conversion.
§Example
use parasol_runtime::{
fluent::{
FheCircuitCtx, PackedUInt}, ComputeKey, Encryption, Evaluation, L1GgswCiphertext,
L1GlweCiphertext, PublicKey, SecretKey, CircuitProcessor, DEFAULT_128
};
use std::sync::Arc;
// Generate our keys.
let sk = SecretKey::generate_with_default_params();
let ck = Arc::new(ComputeKey::generate_with_default_params(&sk));
let pk = PublicKey::generate(&DEFAULT_128, &sk);
// Generate the things needed to encrypt data and run our circuit.
let enc = Encryption::new(&DEFAULT_128);
let eval = Evaluation::new(ck, &DEFAULT_128, &enc);
let (mut proc, flow_control) = CircuitProcessor::new(16384, None, &eval, &enc);
// Encrypt our 2 16-bit unsigned inputs, each packed into a single GLWE ciphertext.
let a = PackedUInt::<16, L1GlweCiphertext>::encrypt(42, &enc, &pk);
let b = PackedUInt::<16, L1GlweCiphertext>::encrypt(16, &enc, &pk);
// Build a circuit that first `unpack()`s each encrypted value into 16 ciphertexts.
// Next, we convert our encrypted values to L1GgswCiphertext, which will insert
// circuit bootstrapping operations.
// The fluent types ensure at compile time that you only create valid graphs
// and guarantees you've `convert()`ed ciphertexts appropriately.
let ctx = FheCircuitCtx::new();
let a = a
.graph_input(&ctx)
.unpack(&ctx)
.convert::<L1GgswCiphertext>(&ctx);
let b = b
.graph_input(&ctx)
.unpack(&ctx)
.convert::<L1GgswCiphertext>(&ctx);
// With our data in GGSW form, we can now multiply the two encrypted integers, which will result in
// L1GlweCiphertexts that we re`pack()` into a single ciphertext.
let c = a
.mul::<L1GlweCiphertext>(&b, &ctx)
.pack(&ctx, &enc)
.collect_output(&ctx, &enc);
proc.run_graph_blocking(&ctx.circuit.borrow(), &flow_control);
assert_eq!(c.decrypt(&enc, &sk), 672);Modules§
- circuits
- Contains circuits that perform integer computation.
- fluent
- A module that allows one to build
FheCircuits that perform computation over integers and perform low-level operations, such as ciphertext conversion. - recryption
- Recryption is the process of homomorphically computing an encryption under a different algorithm. When the resulting FHE ciphertext is decrypted, the resulting message is then a ciphertext under a that algorithm.
- safe_
bincode - A safe wrapper around
bincodedeserialization to limit input sizes and prevent malicious or improperly serialized data from causing panics.
Structs§
- Circuit
Processor - A “backend” processor that runs
FheCircuits. - Completion
Handler - A callback that fires when all the operations in an
FheCircuitpassed tocrate::CircuitProcessor::spawn_graphorcrate::CircuitProcessor::run_graph_blockingfinish. - Compute
Key - A set of keys used during FHE evaluation.
- Compute
KeyNon Fft - A set of keys that can be FFT’d and used during evaluation.
- Encryption
- A low-level type that allows encrypting and decrypting various ciphertext types.
- Evaluation
- Performs FHE operations, including those that require the compute key.
- FheCircuit
- A directed graph of FHE operations that describe a computational circuit.
- Keyless
Evaluation - Performs FHE operations that don’t require the compute key.
- L0Lwe
Ciphertext - An
LweCiphertextunder the level 0 parameters. SeeParamsfor more details as to the significance of these ciphertexts. - L1Ggsw
Ciphertext - A
GgswCiphertextunder the level 1 parameters. SeeParamsfor more details as to the significance of these ciphertexts. - L1Glev
Ciphertext - A
GlevCiphertextunder the level 1 parameters. SeeParamsfor more details as to the significance of these ciphertexts. - L1Glwe
Ciphertext - A
GlweCiphertextunder the level 1 parameters. SeeParamsfor more details as to the significance of these ciphertexts. - L1Lwe
Ciphertext - An
LweCiphertextunder the level 1 parameters. SeeParamsfor more details as to the significance of these ciphertexts. - Params
- The set of parameters for performing FHE computation with Sunscreen’s circuit bootstrapping (CBS) approach.
- Public
Key - A public key
- Public
OneTime Pad - The encrypted version of a one-time-pad.
- Runtime
Error - An error that occurs when running an FHE circuit. These usually occur when a circuit is malformed (e.g. illegally connecting nodes, using edges incorrectly etc.).
- Secret
Key - A secret key.
- Secret
OneTime Pad - The secret key for a one-time-pad.
- Seed
- A cryptographically secure seed for deterministic key generation.
Enums§
- Ciphertext
Type - An enum of possible ciphertext types.
- Error
- Errors that can occur in this crate.
- FheEdge
- The input types for
FheOps in anFheCircuit. - FheOp
- A node in an
FheCircuitrepresenting a low-level crypto operation.
Constants§
- DEFAULT_
128 - The standard 128-bit secure parameter set.
- FAST_
BIG_ 128 - A balance of speed and keysize.
- TURBO_
CHUNGUS_ 128 - Fastest parameters at the expense of significantly larger key size.
Traits§
- Trivial
One - A trait that produces a trivial one encryption for the implementing ciphertext type.
- Trivial
Zero - A trait that produces a trivial zero encryption for the implementing ciphertext type.
Functions§
- decrypt_
one_ time_ pad - Given a
SecretOneTimePad, decrypt the resulting message. - generate_
one_ time_ pad - Generates a
PublicOneTimePad,SecretOneTimePadpair. Give the public version to the party to perform recryption and use the secret version to decrypt the contained message. - insert_
ciphertext_ conversion - Inserts conversions between the result at
cur_nodefrom anin_typeciphertext to anout_typeciphertext. Returns the index of the node of theout_type` ciphertext. - prune
- Removes any nodes not reachable from any of
nodesto optimize a computation. - recrypt_
one_ time_ pad - Perform one-time pad recryption. The result GLWE ciphertext contains the message in
xxor’d withotp.key, and is thus a one-time pad. After the resulting GLWE ciphertext is decrypted, the holder of theSecretOneTimePadcan then decrypt the result.
Type Aliases§
- Result
- A
Resultfor this crate. - Shared
L0Lwe Ciphertext - An
L0LweCiphertextthat can be shared across threads. - Shared
L1Ggsw Ciphertext - An
L1GgswCiphertextthat can be shared across threads. - Shared
L1Glev Ciphertext - An
L1GlevCiphertextthat can be shared across threads. - Shared
L1Glwe Ciphertext - An
L1GlweCiphertextthat can be shared across threads. - Shared
L1Lwe Ciphertext - An
L1LweCiphertextthat can be shared across threads.