FheEngine

Struct FheEngine 

Source
pub struct FheEngine { /* private fields */ }
Expand description

The main FHE engine

Implementations§

Source§

impl FheEngine

Source

pub fn new(params: FheParams) -> Self

Create a new FHE engine with given parameters

Source

pub fn new_ckks() -> Self

Create with default CKKS parameters (for ML)

Source

pub fn new_bfv() -> Self

Create with BFV parameters (for exact integers)

Source

pub fn keygen(&mut self) -> &FheKeyPair

Generate key pair

Source

pub fn encode_integers(&self, values: &[i64]) -> Plaintext

Encode a vector of integers as plaintext

Source

pub fn encode_floats(&self, values: &[f64]) -> Plaintext

Encode a vector of floats as plaintext (CKKS)

Source

pub fn encrypt(&mut self, plaintext: &Plaintext) -> Result<Ciphertext, FheError>

Encrypt a plaintext

Source

pub fn decrypt( &mut self, ciphertext: &Ciphertext, ) -> Result<Plaintext, FheError>

Decrypt a ciphertext

Source

pub fn add( &mut self, a: &Ciphertext, b: &Ciphertext, ) -> Result<Ciphertext, FheError>

Homomorphic addition

Source

pub fn sub( &mut self, a: &Ciphertext, b: &Ciphertext, ) -> Result<Ciphertext, FheError>

Homomorphic subtraction

Source

pub fn multiply( &mut self, a: &Ciphertext, b: &Ciphertext, ) -> Result<Ciphertext, FheError>

Homomorphic multiplication

Source

pub fn multiply_plain( &mut self, ct: &Ciphertext, pt: &Plaintext, ) -> Result<Ciphertext, FheError>

Multiply ciphertext by plaintext

Source

pub fn add_plain( &mut self, ct: &Ciphertext, pt: &Plaintext, ) -> Result<Ciphertext, FheError>

Add plaintext to ciphertext

Source

pub fn rotate( &mut self, ct: &Ciphertext, steps: i32, ) -> Result<Ciphertext, FheError>

Rotate ciphertext slots

Source

pub fn rescale(&mut self, ct: &Ciphertext) -> Result<Ciphertext, FheError>

Rescale (for CKKS - reduce scale after multiplication)

Source

pub fn bootstrap(&mut self, ct: &Ciphertext) -> Result<Ciphertext, FheError>

Bootstrap (refresh noise budget - expensive operation)

Source

pub fn get_stats(&self) -> &FheStats

Get statistics

Source

pub fn get_params(&self) -> &FheParams

Get parameters

Trait Implementations§

Source§

impl Debug for FheEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V