Skip to main content

RawXgcdOutput

Struct RawXgcdOutput 

Source
pub(crate) struct RawXgcdOutput<const LIMBS: usize, MATRIX> {
    gcd: OddUint<LIMBS>,
    matrix: MATRIX,
}
Expand description

Container for the raw output of the Binary XGCD algorithm.

Fields§

§gcd: OddUint<LIMBS>§matrix: MATRIX

Implementations§

Source§

impl<const LIMBS: usize> RawXgcdOutput<LIMBS, DividedPatternMatrix<LIMBS>>

Source

pub(crate) const fn divide(self) -> RawXgcdOutput<LIMBS, PatternMatrix<LIMBS>>

Divide self.matrix.inner by 2^self.matrix.k, allowing us to simplify inner from a DividedPatternMatrix to a PatternMatrix.

The performed divisions are modulo lhs/gcd and rhs/gcd to maintain the correctness of the XGCD state.

This operation is ‘fast’ since it only applies the division to the top row of the matrix. This is allowed since it is assumed that self.matrix * (lhs, rhs) = (gcd, 0); dividing the bottom row of the matrix by a constant has no impact since its inner-product with the input vector is zero.

Executes in variable time w.r.t. k_upper_bound.

Source§

impl<const LIMBS: usize> RawXgcdOutput<LIMBS, PatternMatrix<LIMBS>>

Source

pub(crate) const fn gcd(&self) -> OddUint<LIMBS>

Obtain the gcd.

Source

pub(crate) const fn bezout_coefficients(&self) -> (Int<LIMBS>, Int<LIMBS>)

Obtain the bezout coefficients (x, y) such that lhs * x + rhs * y = gcd.

Source

pub(crate) const fn quotients(&self) -> (Uint<LIMBS>, Uint<LIMBS>)

Obtain the quotients lhs/gcd and rhs/gcd from matrix.

Auto Trait Implementations§

§

impl<const LIMBS: usize, MATRIX> Freeze for RawXgcdOutput<LIMBS, MATRIX>
where MATRIX: Freeze,

§

impl<const LIMBS: usize, MATRIX> RefUnwindSafe for RawXgcdOutput<LIMBS, MATRIX>
where MATRIX: RefUnwindSafe,

§

impl<const LIMBS: usize, MATRIX> Send for RawXgcdOutput<LIMBS, MATRIX>
where MATRIX: Send,

§

impl<const LIMBS: usize, MATRIX> Sync for RawXgcdOutput<LIMBS, MATRIX>
where MATRIX: Sync,

§

impl<const LIMBS: usize, MATRIX> Unpin for RawXgcdOutput<LIMBS, MATRIX>
where MATRIX: Unpin,

§

impl<const LIMBS: usize, MATRIX> UnsafeUnpin for RawXgcdOutput<LIMBS, MATRIX>
where MATRIX: UnsafeUnpin,

§

impl<const LIMBS: usize, MATRIX> UnwindSafe for RawXgcdOutput<LIMBS, MATRIX>
where MATRIX: UnwindSafe,

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, 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.