4 releases (2 breaking)
0.7.0 | Oct 17, 2022 |
---|---|
0.6.1 | Jul 14, 2022 |
0.6.0 | Jul 14, 2022 |
0.5.0 | May 17, 2022 |
#330 in Cryptography
53 downloads per month
13MB
259K
SLoC
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, Runtime,
};
#[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 = Runtime::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_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
~5–9.5MB
~202K SLoC