pub struct GLWEPacker { /* private fields */ }Expand description
GLWEPacker enables only the fly GLWE packing with constant memory of Log(N) ciphertexts. Main difference with usual GLWE packing is that the output is bit-reversed.
Implementations§
Source§impl GLWEPacker
impl GLWEPacker
Sourcepub fn new(
n: usize,
log_batch: usize,
basek: usize,
k: usize,
rank: usize,
) -> Self
pub fn new( n: usize, log_batch: usize, basek: usize, k: usize, rank: usize, ) -> Self
Instantiates a new GLWEPacker.
§Arguments
module: static backend FFT tables.log_batch: packs coefficients which are multiples of X^{N/2^log_batch}. i.e. withlog_batch=0only the constant coefficient is packed and N GLWE ciphertext can be packed. Withlog_batch=2all coefficients which are multiples of X^{N/4} are packed. Meaning that N/4 ciphertexts can be packed.basek: base 2 logarithm of the GLWE ciphertext in memory digit representation.k: base 2 precision of the GLWE ciphertext precision over the Torus.rank: rank of the GLWE ciphertext.
Sourcepub fn scratch_space<B: Backend>(
module: &Module<B>,
basek: usize,
ct_k: usize,
k_ksk: usize,
digits: usize,
rank: usize,
) -> usize
pub fn scratch_space<B: Backend>( module: &Module<B>, basek: usize, ct_k: usize, k_ksk: usize, digits: usize, rank: usize, ) -> usize
Number of scratch space bytes required to call Self::add.
pub fn galois_elements<B: Backend>(module: &Module<B>) -> Vec<i64>
Sourcepub fn add<DataA: DataRef, DataAK: DataRef, B: Backend>(
&mut self,
module: &Module<B>,
a: Option<&GLWECiphertext<DataA>>,
auto_keys: &HashMap<i64, GGLWEAutomorphismKeyPrepared<DataAK, B>>,
scratch: &mut Scratch<B>,
)where
Module<B>: VecZnxDftAllocBytes + VmpApplyDftToDftTmpBytes + VecZnxBigNormalizeTmpBytes + VmpApplyDftToDft<B> + VmpApplyDftToDftAdd<B> + VecZnxDftApply<B> + VecZnxIdftApplyConsume<B> + VecZnxBigAddSmallInplace<B> + VecZnxBigNormalize<B> + VecZnxCopy + VecZnxRotateInplace<B> + VecZnxSub + VecZnxNegateInplace + VecZnxRshInplace<B> + VecZnxAddInplace + VecZnxNormalizeInplace<B> + VecZnxSubABInplace + VecZnxRotate + VecZnxAutomorphismInplace<B> + VecZnxBigSubSmallBInplace<B> + VecZnxBigAutomorphismInplace<B>,
Scratch<B>: TakeVecZnxDft<B> + ScratchAvailable + TakeVecZnx,
pub fn add<DataA: DataRef, DataAK: DataRef, B: Backend>(
&mut self,
module: &Module<B>,
a: Option<&GLWECiphertext<DataA>>,
auto_keys: &HashMap<i64, GGLWEAutomorphismKeyPrepared<DataAK, B>>,
scratch: &mut Scratch<B>,
)where
Module<B>: VecZnxDftAllocBytes + VmpApplyDftToDftTmpBytes + VecZnxBigNormalizeTmpBytes + VmpApplyDftToDft<B> + VmpApplyDftToDftAdd<B> + VecZnxDftApply<B> + VecZnxIdftApplyConsume<B> + VecZnxBigAddSmallInplace<B> + VecZnxBigNormalize<B> + VecZnxCopy + VecZnxRotateInplace<B> + VecZnxSub + VecZnxNegateInplace + VecZnxRshInplace<B> + VecZnxAddInplace + VecZnxNormalizeInplace<B> + VecZnxSubABInplace + VecZnxRotate + VecZnxAutomorphismInplace<B> + VecZnxBigSubSmallBInplace<B> + VecZnxBigAutomorphismInplace<B>,
Scratch<B>: TakeVecZnxDft<B> + ScratchAvailable + TakeVecZnx,
Adds a GLWE ciphertext to the GLWEPacker. #Arguments
module: static backend FFT tables.res: space to append fully packed ciphertext. Only when the number of packed ciphertexts reaches N/2^log_batch is a result written.a: ciphertext to pack. Can optionally give None to pack a 0 ciphertext.auto_keys: a HashMap containing the [AutomorphismKeyExec]s.scratch: scratch space of size at least Self::scratch_space.
Sourcepub fn flush<Data: DataMut, B: Backend>(
&mut self,
module: &Module<B>,
res: &mut GLWECiphertext<Data>,
)where
Module<B>: VecZnxCopy,
pub fn flush<Data: DataMut, B: Backend>(
&mut self,
module: &Module<B>,
res: &mut GLWECiphertext<Data>,
)where
Module<B>: VecZnxCopy,
Flush result tores.
Auto Trait Implementations§
impl Freeze for GLWEPacker
impl RefUnwindSafe for GLWEPacker
impl Send for GLWEPacker
impl Sync for GLWEPacker
impl Unpin for GLWEPacker
impl UnwindSafe for GLWEPacker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.