Crate sunscreen

Source
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_programs.
types
This module contains types used when writing and compiling FHE and ZKP programs.
zkp
This module contains types used internally when compiling zkp_programs.

Macros§

fhe_var
Creates new FHE variables from literals.
zkp_var
Creates new ZKP variables from literals.

Structs§

Application
The outcome of successful compilation. Contains one or more CompiledFheProgram.
CallSignature
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.
CompiledFheProgram
An FHE program with its associated metadata.
FheProgramMetadata
A serializable list of requirements for an Fhe Program.
FrontendCompilation
Contains the frontend compilation graph.
GenericCompiler
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.
PrivateKey
The private key used to decrypt ciphertexts.
ProofBuilder
A builder for creating a proof.
PublicKey
A bundle of public keys. These may be freely shared with other parties without risk of compromising data security.
SealPlaintext
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.
VerificationBuilder
A builder for verifying a proof.
WithContext
A data type that contains parameters for reconstructing a context during deserialization (needed by SEAL).
ZkpProgramInput
An input argument to a ZKP program.

Enums§

Error
Represents an error that can occur in this crate.
FheProgramInput
An input argument to an Fhe Program. See crate::Runtime::run.
InnerCiphertext
The underlying backend implementation of a ciphertext (e.g SEAL’s Ciphertext).
InnerPlaintext
The underlying backend implementation of a plaintext (e.g. SEAL’s Plaintext).
OperandInfo
Information about an edge in the frontend IR.
PlainModulusConstraint
A constraint on the plaintext
Proof
An R1CS proof.
RequiredKeys
A key type required for an Fhe Program to function correctly.
RuntimeError
Represents an error that can occur in this crate.
SchemeType
Sunscreen supports the BFV scheme.
SecurityLevel
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§

FheProgramFn
The operations supported by an #[fhe_program] function.
FheProgramFnExt
An extension of FheProgramFn, providing helpers and convenience methods.
FheProgramInputTrait
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.
FheZkpApplication
An application with FHE and ZKP programs.
FheZkpRuntime
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. 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.
zkp_program
Specifies a function to be a ZKP program. TODO: docs.

Derive Macros§

TypeName
Allows you to #[derive(Typename)].