Skip to main content

LinearTransformation

Struct LinearTransformation 

Source
pub struct LinearTransformation<P> {
    pub baby_steps: Vec<i64>,
    pub giant_steps: Vec<LinearTransformationGiantStep<P>>,
}
Expand description

A linear transformation in baby-step / giant-step form.

P is the encoded-plaintext container.

Fields§

§baby_steps: Vec<i64>

Distinct baby-step slot rotations k; baby_steps[0] == 0 (the identity).

§giant_steps: Vec<LinearTransformationGiantStep<P>>

The giant steps.

Implementations§

Source§

impl<BE: Backend> LinearTransformation<PreparedDiagonal<BE::OwnedBuf, BE>>

Source

pub fn alloc_prepared<M, P>( module: &M, layout: &LinearTransformationLayout, pt_infos: &P, ) -> Self
where M: CnvPVecAlloc<BE>, P: LWEInfos,

Pre-allocates a resident (prepared) linear transformation sized for the given BSGS layout and plaintext shape pt_infos.

Convenience for the layout-driven flow: builds the BSGS index via layout.index() and forwards to Self::alloc_prepared_from_index.

Source

pub fn alloc_prepared_from_index<M, P>( module: &M, index: &LinearTransformationPlan, pt_infos: &P, ) -> Self
where M: CnvPVecAlloc<BE>, P: LWEInfos,

Pre-allocates a resident transform sized for an explicit BSGS index.

Each diagonal carries the plaintext’s base2k / k so the evaluator never needs the raw plaintext transform again; the convolution buffers are zeroed and populated by glwe_prepare_linear_transformation_rhs. The per-diagonal log_scale is left at 0 for the scheme layer to set.

Source

pub fn set_log_scale(&mut self, log_scale: usize)

Sets the per-diagonal log_scale of every diagonal; called by the scheme layer during the populate step (mirrors the streamed plaintext’s log_delta).

Source

pub fn log_scale(&self) -> usize

Base-2 log of the plaintext scaling factor shared by every diagonal.

Source§

impl<P> LinearTransformation<P>

Source

pub fn baby_steps(&self) -> &[i64]

The distinct baby-step slot rotations k (baby_steps[0] == 0, the identity); the set the prepared baby cache must hold. Accessor over the baby_steps field for callers that prefer a method.

Source

pub fn first_diagonal_plaintext(&self) -> Option<&P>

The first encoded diagonal across all giant steps, or None if the transform is empty. The diagonals share a uniform plaintext shape, so this is the canonical place callers read base2k / k / log_delta from.

Source

pub fn index(&self) -> LinearTransformationPlan

Derives the BSGS index schedule implied by this transform’s actual baby/giant rotations. Useful for one-shot allocation of the prepared cache directly from an unprepared transform.

The output is canonical — giant steps sorted, per-giant baby rotations sorted and de-duplicated — so it matches the schedule LinearTransformationLayout::index would derive from the same diagonal set. Only baby rotations actually referenced by at least one non-empty giant step are included; the field self.baby_steps may declare more rotations than the transform’s data populates, and those extras would otherwise force the caller to provide automorphism keys that the schedule does not actually need.

Source

pub fn galois_elements(&self, cyclotomic_order: i64) -> Vec<i64>

The Galois elements whose automorphism keys are required to evaluate this transform: one per non-zero baby- and giant-step rotation.

Automorphism keys are keyed by Galois element throughout the engine (cf. LinearTransformationPlan::galois_elements); pass the result here to index the key store the eval entry points look up.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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