Crate parasol_runtime

Crate parasol_runtime 

Source
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 bincode deserialization to limit input sizes and prevent malicious or improperly serialized data from causing panics.

Structs§

CircuitProcessor
A “backend” processor that runs FheCircuits.
CompletionHandler
A callback that fires when all the operations in an FheCircuit passed to crate::CircuitProcessor::spawn_graph or crate::CircuitProcessor::run_graph_blocking finish.
ComputeKey
A set of keys used during FHE evaluation.
ComputeKeyNonFft
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.
KeylessEvaluation
Performs FHE operations that don’t require the compute key.
L0LweCiphertext
An LweCiphertext under the level 0 parameters. See Params for more details as to the significance of these ciphertexts.
L1GgswCiphertext
A GgswCiphertext under the level 1 parameters. See Params for more details as to the significance of these ciphertexts.
L1GlevCiphertext
A GlevCiphertext under the level 1 parameters. See Params for more details as to the significance of these ciphertexts.
L1GlweCiphertext
A GlweCiphertext under the level 1 parameters. See Params for more details as to the significance of these ciphertexts.
L1LweCiphertext
An LweCiphertext under the level 1 parameters. See Params for 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.
PublicKey
A public key
PublicOneTimePad
The encrypted version of a one-time-pad.
RuntimeError
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.).
SecretKey
A secret key.
SecretOneTimePad
The secret key for a one-time-pad.
Seed
A cryptographically secure seed for deterministic key generation.

Enums§

CiphertextType
An enum of possible ciphertext types.
Error
Errors that can occur in this crate.
FheEdge
The input types for FheOps in an FheCircuit.
FheOp
A node in an FheCircuit representing 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§

TrivialOne
A trait that produces a trivial one encryption for the implementing ciphertext type.
TrivialZero
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, SecretOneTimePad pair. 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_node from an in_type ciphertext to an out_type ciphertext. Returns the index of the node of the out_type` ciphertext.
prune
Removes any nodes not reachable from any of nodes to optimize a computation.
recrypt_one_time_pad
Perform one-time pad recryption. The result GLWE ciphertext contains the message in x xor’d with otp.key, and is thus a one-time pad. After the resulting GLWE ciphertext is decrypted, the holder of the SecretOneTimePad can then decrypt the result.

Type Aliases§

Result
A Result for this crate.
SharedL0LweCiphertext
An L0LweCiphertext that can be shared across threads.
SharedL1GgswCiphertext
An L1GgswCiphertext that can be shared across threads.
SharedL1GlevCiphertext
An L1GlevCiphertext that can be shared across threads.
SharedL1GlweCiphertext
An L1GlweCiphertext that can be shared across threads.
SharedL1LweCiphertext
An L1LweCiphertext that can be shared across threads.