#fhe #lattice #bfv #compiler-error #zero-knowledge-proofs

sunscreen

A Fully Homomorphic Encryption (FHE) compiler supporting the Brakerski/Fan-Vercauteren (BFV) scheme

6 releases (3 breaking)

0.8.1 Sep 11, 2023
0.8.0 Aug 23, 2023
0.7.0 Oct 17, 2022
0.6.1 Jul 14, 2022
0.5.0 May 17, 2022

#1 in #fhe

Download history 1/week @ 2024-02-18 7/week @ 2024-02-25 20/week @ 2024-03-10 1/week @ 2024-03-17 46/week @ 2024-03-24 13/week @ 2024-03-31

80 downloads per month

AGPL-3.0-only

14MB
267K SLoC

C++ 102K SLoC // 0.1% comments C 92K SLoC // 0.2% comments Visual Studio Project 21K SLoC Rust 16K SLoC // 0.2% comments C# 14K SLoC // 0.3% comments Python 10K SLoC // 0.3% comments Shell 3K SLoC // 0.2% comments Ada 1.5K SLoC // 0.2% comments GNU Style Assembly 1.5K SLoC // 0.3% comments Assembly 1.5K SLoC // 0.2% comments Pascal 1K SLoC // 0.2% comments Bazel 1K SLoC // 0.1% comments Visual Studio Solution 878 SLoC Bitbake 526 SLoC Batch 169 SLoC Lua 68 SLoC // 0.0% comments Automake 33 SLoC Prolog 19 SLoC NuGet Config 3 SLoC ReScript 3 SLoC Forge Config 1 SLoC // 0.8% comments

Intro

Sunscreen is an ecosystem for building privacy-preserving applications using fully homomorphic encryption.

This project is licensed under the terms of the GNU AGPLv3 license. If you require a different license for your application, please reach out to us.

WARNING! This library is meant for experiments only. It has not been externally audited and is not intended for use in production.

Example

Below, we look at how to multiply two encrypted integers together.

use sunscreen::{
    fhe_program,
    types::{bfv::Signed, Cipher},
    Compiler, Error, FheRuntime,
};

#[fhe_program(scheme = "bfv")]
fn simple_multiply(a: Cipher<Signed>, b: Cipher<Signed>) -> Cipher<Signed> {
    a * b
}

fn main() -> Result<(), Error> {
    let app = Compiler::new()
        .fhe_program(simple_multiply)
        .compile()?;

    let runtime = FheRuntime::new(app.params())?;

    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(app.get_fhe_program(simple_multiply).unwrap(), vec![a, b], &public_key)?;

    let c: Signed = runtime.decrypt(&results[0], &private_key)?;

    assert_eq!(c, 75.into());

    Ok(())
}

Docs

Getting help

For questions about Sunscreen, join our Discord!

Dependencies

~11–17MB
~285K SLoC