pub struct Residue<'f, T: MontStorage, P: Personality = Nct> { /* private fields */ }Expand description
A value in Field<T, P>, stored implicitly in Montgomery form.
The 'f lifetime brand ties this residue to its parent Field; the
P parameter ties it to the parent’s algorithm personality. The
borrow checker rejects code that uses a residue after its Field is
dropped, or that mixes residues across personalities. See module docs
for the covariance caveat.
Implementations§
Source§impl<T: MontStorage, P: Personality> Residue<'_, T, P>
impl<T: MontStorage, P: Personality> Residue<'_, T, P>
Sourcepub fn mont_value(&self) -> &T
pub fn mont_value(&self) -> &T
Returns a reference to the underlying Montgomery-form value.
Escape hatch. Intended for downstream specialization layers
(e.g. Curve25519Field) that implement fast paths reading the raw
limbs. General consumers should not call this — use the methods on
Field instead.
Source§impl<'f, T> Residue<'f, T, Ct>where
T: ConditionallySelectable + MontStorage,
impl<'f, T> Residue<'f, T, Ct>where
T: ConditionallySelectable + MontStorage,
Sourcepub fn cswap(choice: Choice, a: &mut Self, b: &mut Self)
pub fn cswap(choice: Choice, a: &mut Self, b: &mut Self)
Conditionally swap two residues in constant time.
If choice is set, a and b exchange Montgomery-form values;
otherwise both are left unchanged. The operation is branchless.
This is the primitive used by Montgomery ladders (x25519 scalar
multiplication, RSA blinded exponentiation). It is the only
residue swap that should appear in such a ladder; std::mem::swap
is not guaranteed to be branchless.
Source§impl<'f, T> Residue<'f, T, Ct>where
T: ConstantTimeEq + MontStorage,
impl<'f, T> Residue<'f, T, Ct>where
T: ConstantTimeEq + MontStorage,
Trait Implementations§
Source§impl<'f, T: Clone + MontStorage, P: Clone + Personality> Clone for Residue<'f, T, P>
impl<'f, T: Clone + MontStorage, P: Clone + Personality> Clone for Residue<'f, T, P>
Source§impl<'f, T: Debug + MontStorage, P: Debug + Personality> Debug for Residue<'f, T, P>
impl<'f, T: Debug + MontStorage, P: Debug + Personality> Debug for Residue<'f, T, P>
Source§impl<'f, T: MontStorage, P: Personality> Drop for Residue<'f, T, P>
Available on crate feature zeroize only.
impl<'f, T: MontStorage, P: Personality> Drop for Residue<'f, T, P>
zeroize only.impl<'f, T: Eq + MontStorage, P: Eq + Personality> Eq for Residue<'f, T, P>
Source§impl<'f, T: PartialEq + MontStorage, P: PartialEq + Personality> PartialEq for Residue<'f, T, P>
impl<'f, T: PartialEq + MontStorage, P: PartialEq + Personality> PartialEq for Residue<'f, T, P>
impl<'f, T: PartialEq + MontStorage, P: PartialEq + Personality> StructuralPartialEq for Residue<'f, T, P>
Source§impl<'f, T: MontStorage, P: Personality> Zeroize for Residue<'f, T, P>
Available on crate feature zeroize only.
impl<'f, T: MontStorage, P: Personality> Zeroize for Residue<'f, T, P>
zeroize only.impl<'f, T: MontStorage, P: Personality> ZeroizeOnDrop for Residue<'f, T, P>
zeroize only.