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() -> Result<()> {
let multiply_program = simple_multiply.compile()?;
let runtime = simple_multiply.runtime()?;
let (public_key, private_key) = runtime.generate_keys()?;
let a = runtime.encrypt(Signed::from(15), &public_key)?;
let b = runtime.encrypt(Signed::from(5), &public_key)?;
let results = runtime.run(
&multiply_program,
vec![a, b],
&public_key
)?;
let c: Signed = runtime.decrypt(&results[0], &private_key)?;
assert_eq!(c, 75.into());
Ok(())
}
Re-exports§
pub use zkp::invoke_gadget;
pub use zkp::ZkpProgramFn;
pub use zkp::ZkpProgramFnExt;
Modules§
- bulletproofs
- Types for working with Bulletproofs as the ZKP backend.
- fhe
- This module contains types used internally when compiling
fhe_program
s. - types
- This module contains types used when writing and compiling FHE and ZKP programs.
- zkp
- This module contains types used internally when compiling
zkp_program
s.
Macros§
Structs§
- Application
- The outcome of successful compilation. Contains one or more
CompiledFheProgram
. - Call
Signature - Indicates the type signature of an FHE or ZKP program.
- Ciphertext
- An encryption of the given data type. Note, the data type is stored in plaintext and is considered part of Sunscreen’s runtime protocol.
- Compiled
FheProgram - An FHE program with its associated metadata.
- FheProgram
Metadata - A serializable list of requirements for an Fhe Program.
- Frontend
Compilation - Contains the frontend compilation graph.
- Generic
Compiler - A frontend compiler for Sunscreen FHE programs.
- Params
- The parameter set required for a given FHE program to run efficiently and correctly.
- Plaintext
- Represents an encoded plaintext suitable for use in the underlying scheme.
- Private
Key - The private key used to decrypt ciphertexts.
- Proof
Builder - A builder for creating a proof.
- Public
Key - A bundle of public keys. These may be freely shared with other parties without risk of compromising data security.
- Seal
Plaintext - 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.
- Verification
Builder - A builder for verifying a proof.
- With
Context - A data type that contains parameters for reconstructing a context during deserialization (needed by SEAL).
- ZkpProgram
Input - An input argument to a ZKP program.
Enums§
- Error
- Represents an error that can occur in this crate.
- FheProgram
Input - An input argument to an Fhe Program. See
crate::Runtime::run
. - Inner
Ciphertext - The underlying backend implementation of a ciphertext (e.g SEAL’s
Ciphertext
). - Inner
Plaintext - The underlying backend implementation of a plaintext (e.g. SEAL’s
Plaintext
). - Operand
Info - Information about an edge in the frontend IR.
- Plain
Modulus Constraint - A constraint on the plaintext
- Proof
- An R1CS proof.
- Required
Keys - A key type required for an Fhe Program to function correctly.
- Runtime
Error - Represents an error that can occur in this crate.
- Scheme
Type - Sunscreen supports the BFV scheme.
- Security
Level - 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.
- ZkpError
- An error in a ZKP backend.
Constants§
- INDEX_
ARENA - An arena containing slices of indicies. An implementation detail of FHE/ZKP programs.
Traits§
- FheProgram
Fn - The operations supported by an
#[fhe_program]
function. - FheProgram
FnExt - An extension of
FheProgramFn
, providing helpers and convenience methods. - FheProgram
Input Trait - A trait that denotes this type can be used as an argument to an FHE program.
- Value
- This trait specifies a type as being able to be used as an input or output of an
fhe_program
. - ZkpBackend
- The methods needed for a type to serve as a proof system in the Sunscreen ecosystem.
Type Aliases§
- Compiler
- A compiler that has not yet been types. After calling
Compiler::new
, the builder type evolves as you specify parameters and new configurations become valid. - FheApplication
- An application with FHE programs.
- FheRuntime
- A runtime capable of only FHE operations.
- FheZkp
Application - An application with FHE and ZKP programs.
- FheZkp
Runtime - A runtime capable of both FHE and ZKP operations.
- Result
- Wrapper around
Result
with this crate’s error type. - Runtime
- A type containing the
Runtime::new_*
constructor methods to create the appropriate runtime: - ZkpApplication
- An application with ZKP programs.
- ZkpResult
- See
std::result::Result
. - ZkpRuntime
- A runtime capable of only ZKP operations.
Attribute Macros§
- fhe_
program - Specifies a function to be an
fhe_program
. Anfhe_program
has any number of inputs that impl theFheType
trait and returns either a single type implementingFheType
or a tuple of types implementingFheType
. - zkp_
program - Specifies a function to be a ZKP program. TODO: docs.
Derive Macros§
- Type
Name - Allows you to
#[derive(Typename)]
.