pub trait FheProgramFnExt: FheProgramFn {
// Provided methods
fn compile(&self) -> Result<CompiledFheProgram>
where Self: AsRef<str> + Sized + Clone + 'static { ... }
fn runtime(&self) -> Result<FheRuntime>
where Self: AsRef<str> + Sized + Clone + 'static { ... }
}
Expand description
An extension of FheProgramFn
, providing helpers and convenience methods.
Provided Methods§
Sourcefn compile(&self) -> Result<CompiledFheProgram>
fn compile(&self) -> Result<CompiledFheProgram>
Compile the #[fhe_program]
into a runnable
CompiledFheProgram
.
This is a convenient way to compile just a single FHE program.
use sunscreen::{fhe_program, types::{bfv::Signed, Cipher}, FheProgramFnExt};
#[fhe_program(scheme = "bfv")]
fn multiply(a: Cipher<Signed>, b: Cipher<Signed>) -> Cipher<Signed> {
a * b
}
let multiply_prog = multiply.compile()?;
It is shorthand for:
use sunscreen::{fhe_program, types::{bfv::Signed, Cipher}, Compiler};
#[fhe_program(scheme = "bfv")]
fn multiply(a: Cipher<Signed>, b: Cipher<Signed>) -> Cipher<Signed> {
a * b
}
let app = Compiler::new().fhe_program(multiply).compile()?;
let multiply_prog = app.get_fhe_program(multiply).unwrap();
Sourcefn runtime(&self) -> Result<FheRuntime>
fn runtime(&self) -> Result<FheRuntime>
Make a new FheRuntime
with parameters suitable to run this #[fhe_program]
.
This is a convenient way to run a single FHE program.
use sunscreen::{fhe_program, types::{bfv::Signed, Cipher}, FheProgramFnExt};
#[fhe_program(scheme = "bfv")]
fn multiply(a: Cipher<Signed>, b: Cipher<Signed>) -> Cipher<Signed> {
a * b
}
let runtime = multiply.runtime()?;
It is shorthand for:
use sunscreen::{fhe_program, types::{bfv::Signed, Cipher}, Compiler, FheRuntime};
#[fhe_program(scheme = "bfv")]
fn multiply(a: Cipher<Signed>, b: Cipher<Signed>) -> Cipher<Signed> {
a * b
}
let app = Compiler::new().fhe_program(multiply).compile()?;
let runtime = FheRuntime::new(app.params());