Expand description
This crate contains the frontend compiler for Sunscreen fhe_program and the types and
algorithms that support it.
Examples
This example is further annotated in examples/simple_multiply.
#[fhe_program(scheme = "bfv")]
fn simple_multiply(a: Cipher<Signed>, b: Cipher<Signed>) -> Cipher<Signed> {
a * b
}
fn main() {
let app = Compiler::new()
.fhe_program(simple_multiply)
.plain_modulus_constraint(PlainModulusConstraint::Raw(600))
.additional_noise_budget(5)
.compile()
.unwrap();
let runtime = Runtime::new(app.params()).unwrap();
let (public_key, private_key) = runtime.generate_keys().unwrap();
let a = runtime.encrypt(Signed::from(15), &public_key).unwrap();
let b = runtime.encrypt(Signed::from(5), &public_key).unwrap();
let results = runtime.run(app.get_program(simple_multiply).unwrap(), vec![a, b], &public_key).unwrap();
let c: Signed = runtime.decrypt(&results[0], &private_key).unwrap();
assert_eq!(c, 75.into());
}Modules
This module contains types used during
fhe_program construction.Structs
The outcome of successful compilation. Contains one or more
CompiledFheProgram.Indicates the type signatures of an Fhe Program. Serves as a piece of the
FheProgramMetadata.An encryption of the given data type. Note, the data type is
stored in plaintext and is considered part of Sunscreen’s runtime
protocol.
An FHE program with its associated metadata.
A frontend compiler for Sunscreen FHE programs.
The context for constructing the
fhe_program graph during compilation.A serializable list of requirements for an Fhe Program.
Contains the frontend compilation graph.
The parameter set required for a given FHE program to run efficiently and correctly.
Represents an encoded plaintext suitable for use in the underlying scheme.
The private key used to decrypt ciphertexts.
A bundle of public keys. These may be freely shared with other parties without
risk of compromising data security.
Contains all the elements needed to encrypt, decrypt, generate keys, and evaluate FHE programs.
Class to store a plaintext element. The data for the plaintext is
a polynomial with coefficients modulo the plaintext modulus. The degree
of the plaintext polynomial must be one less than the degree of the
polynomial modulus. The backing array always allocates one 64-bit word
per each coefficient of the polynomial.
A data type that contains parameters for reconstructing a context
during deserialization (needed by SEAL).
Enums
Represents an error that can occur in this crate.
An input argument to an Fhe Program. See
crate::Runtime::run.The underlying backend implementation of a ciphertext (e.g SEAL’s
Ciphertext).The underlying backend implementation of a plaintext (e.g. SEAL’s
Plaintext).Represents a literal node’s data.
Information about an edge in the frontend IR.
Represents an operation occurring in the frontend AST.
A constraint on the plaintext
A key type required for an Fhe Program to function correctly.
Represents an error that can occur in this crate.
Sunscreen supports the BFV scheme.
Represents a standard security level according to the HomomorphicEncryption.org
security standard. The value SecLevelType.None signals that no standard
security level should be imposed. The value SecLevelType.TC128 provides
a very high level of security and is the default security level enforced by
Microsoft SEAL when constructing a SEALContext object. Normal users should not
have to specify the security level explicitly anywhere.
Constants
fhe_program, this refers to the current intermediatefhe_program macro.fhe_program macro.Traits
The operations supported by an
#[fhe_program] function.A trait that denotes this type can be used as an
argument to an FHE program.
This trait specifies a type as being able to be used as an input or output of an
fhe_program.Functions
Runs the specified closure, injecting the current
fhe_program context.Type Definitions
Attribute Macros
Specifies a function to be an
fhe_program. An fhe_program has any number of inputs that impl the
FheType trait and returns either a single type implementing FheType or a tuple of
types implementing FheType.Derive Macros
Allows you to
#[derive(Typename)].