he_ring::bfv::bootstrap

Struct DigitExtract

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

The digit extraction operation, as required in BFV bootstrapping.

Concretely, this encapsulates an efficient implementation of the per-slot digit extraction function

  Z/p^eZ -> Z/p^rZ x Z/p^eZ,  x -> (x - (x mod p^v) / p^v, x mod p^v)

for v = e - r. Here x mod p^v refers to the smallest positive element of Z/p^eZ that is congruent to x modulo p^v.

This function can also be applied to values in a ring Z/p^e'Z for e' > e, in which case the results are only specified modulo p^e, i.e. may be perturbed by an arbitrary value p^e a.

Implementations§

Source§

impl DigitExtract

Source

pub fn new_precomputed_p_is_2(p: i64, e: usize, r: usize) -> Self

Creates a DigitExtract for a scalar ring Z/2^eZ.

Uses the precomputed table of best digit extraction circuits for e <= 23.

Source

pub fn new_default<const LOG: bool>(p: i64, e: usize, r: usize) -> Self

Creates a DigitExtract for a scalar ring Z/p^eZ.

Uses the Chen-Han digit retain polynomials [https://ia.cr/2018/067] together with a heuristic method to compile them into an arithmetic circuit, based on the Paterson-Stockmeyer method.

Source

pub fn new_with( p: i64, e: usize, r: usize, extraction_circuits: Vec<(Vec<usize>, ArithCircuit)>, ) -> Self

Creates a new DigitExtract from the given circuits.

This functions expects the list of circuits to contain tuples (digits, C), where the circuit C takes a single input and computes digits.len() outputs, such that the i-th output is congruent to lift(input mod p) modulo p^digits[i].

If you want to use the default choice of circuits, consider using DigitExtract::new_default().

Source

pub fn r(&self) -> usize

Source

pub fn e(&self) -> usize

Source

pub fn v(&self) -> usize

Source

pub fn p(&self) -> i64

Source

pub fn evaluate<R>(&self, ring: R, input: El<R>) -> (El<R>, El<R>)

Computes the function directly on a ring. Mainly designed for testing.

To avoid requiring many rings, this actually computes a slight variant of the digit extraction function on only one ring, namely

  Z/p^eZ -> Z/p^eZ x Z/p^eZ,  x -> (x - (x mod p^v), x mod p^v)

In particular, the first returned value is divisible by p^v.

Source

pub fn evaluate_homomorphic<'a, Params, const LOG: bool>( &self, P_base: &PlaintextRing<Params>, P_bootstrap: &[PlaintextRing<Params>], C: &CiphertextRing<Params>, C_mul: &CiphertextRing<Params>, ct: Ciphertext<Params>, rk: &RelinKey<'a, Params>, debug_sk: Option<&SecretKey<Params>>, ) -> (Ciphertext<Params>, Ciphertext<Params>)
where Params: 'a + BFVParams,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

fn from_ref<'a>(t: &'a T) -> &'a T

Source§

fn to_ref<'a>(&'a self) -> &'a T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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