Crates.io | sunscreen |
lib.rs | sunscreen |
version | 0.8.1 |
source | src |
created_at | 2022-05-17 00:58:12.304001 |
updated_at | 2023-09-11 21:55:58.247109 |
description | A Fully Homomorphic Encryption (FHE) compiler supporting the Brakerski/Fan-Vercauteren (BFV) scheme. |
homepage | https://sunscreen.tech |
repository | https://github.com/Sunscreen-tech/Sunscreen |
max_upload_size | |
id | 588060 |
size | 391,037 |
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.
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(())
}
For questions about Sunscreen, join our Discord!