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

Modules

  • Types for working with Bulletproofs as the ZKP backend.
  • This module contains types used internally when compiling fhe_programs.
  • This module contains types used when writing and compiling FHE and ZKP programs.
  • This module contains types used internally when compiling zkp_programs.

Macros

  • Creates new FHE variables from literals.
  • Creates new ZKP variables from literals.

Structs

  • The outcome of successful compilation. Contains one or more CompiledFheProgram.
  • Indicates the type signature of an FHE or ZKP program.
  • 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 serializable list of requirements for an Fhe Program.
  • Contains the frontend compilation graph.
  • A frontend compiler for Sunscreen FHE programs.
  • 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 builder for creating a proof.
  • A bundle of public keys. These may be freely shared with other parties without risk of compromising data security.
  • 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 builder for verifying a proof.
  • A data type that contains parameters for reconstructing a context during deserialization (needed by SEAL).
  • An input argument to a ZKP program.

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).
  • Information about an edge in the frontend IR.
  • A constraint on the plaintext
  • An R1CS proof.
  • 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.
  • An error in a ZKP backend.

Constants

  • An arena containing slices of indicies. An implementation detail of FHE/ZKP programs.

Traits

  • The operations supported by an #[fhe_program] function.
  • An extension of FheProgramFn, providing helpers and convenience methods.
  • 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.
  • The methods needed for a type to serve as a proof system in the Sunscreen ecosystem.

Type Aliases

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.
  • Specifies a function to be a ZKP program. TODO: docs.

Derive Macros

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