#[repr(transparent)]pub struct Fn(pub [u64; 6]);Expand description
The P-384 scalar ring, Z/nZ where n is the order of the base point.
Values are held in Montgomery form (a * R mod m). Arithmetic is
branch-free and carries no data-dependent memory access.
Tuple Fields§
§0: [u64; 6]Implementations§
Source§impl Fn
impl Fn
Sourcepub fn to_mont(limbs: [u64; 6]) -> Self
pub fn to_mont(limbs: [u64; 6]) -> Self
Convert a plain integer into Montgomery form, in constant time.
Sourcepub const fn to_mont_const(limbs: [u64; 6]) -> Self
pub const fn to_mont_const(limbs: [u64; 6]) -> Self
Self::to_mont for a curve constant, evaluated at compile
time. Not for secrets: it skips the barrier to_mont has.
Sourcepub fn pow(&self, exponent: &[u64; 6]) -> Self
pub fn pow(&self, exponent: &[u64; 6]) -> Self
Exponentiation with a fixed four-bit window, branch-free in the exponent as well as the base.
The exponent is always a public constant here (m - 2 for
inversion, (p + 1) / 4 for square roots), but nothing below
relies on that: every window costs four squarings and one
multiplication whatever its bits, and its power is chosen from
the table by reading all sixteen entries with conditional
moves, never by indexing or branching on the exponent. An
earlier square-and-multiply branched on each exponent bit, and
Valgrind’s secret-dependence harness reported that branch in
the nonce inversion – whether the compiler had folded the
secret into the condition or the tool was imprecise, the cure
is to have no such branch at all.
One multiplication per four bits, where square-and-multiply
made one per set bit: nearly one per bit for an m - 2 that is
mostly ones.