Struct curve25519_dalek::scalar::Scalar
[−]
[src]
pub struct Scalar(pub [u8; 32]);
The Scalar
struct represents an element in ℤ/lℤ, where
l = 2252 + 27742317777372353535851937790883648493
is the order of the basepoint.
Methods
impl Scalar
[src]
fn zero() -> Self
Construct the additive identity
fn one() -> Self
Construct the multiplicative identity
fn non_adjacent_form(&self) -> [i8; 256]
Compute a width-5 "Non-Adjacent Form" of this scalar.
A width-w
NAF of a positive integer k
is an expression
k = sum(k[i]*2^i for i in range(l))
, where each nonzero
coefficient k[i]
is odd and bounded by |k[i]| < 2^(w-1)
,
k[l-1]
is nonzero, and at most one of any w
consecutive
coefficients is nonzero. (Hankerson, Menezes, Vanstone; def 3.32).
Intuitively, this is like a binary expansion, except that we
allow some coefficients to grow up to 2^(w-1)
so that the
nonzero coefficients are as sparse as possible.
fn to_radix_16(&self) -> [i8; 64]
Write this scalar in radix 16, with coefficients in [-8,8)
,
i.e., compute a_i
such that
a = a_0 + a_1*161 + ... + a_63*1663,
with -8 ≤ a_i < 8
for 0 ≤ i < 63
and -8 ≤ a_63 ≤ 8
.
Precondition: self[31] <= 127. This is the case whenever
self
is reduced.
fn multiply_add(a: &Scalar, b: &Scalar, c: &Scalar) -> Scalar
Compute ab+c (mod l)
.
fn reduce(input: &[u8; 64]) -> Scalar
Reduce a 512-bit little endian number mod l
Trait Implementations
impl Copy for Scalar
[src]
impl Clone for Scalar
[src]
fn clone(&self) -> Scalar
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Index<usize> for Scalar
[src]
type Output = u8
The returned type after indexing
fn index<'a>(&'a self, _index: usize) -> &'a u8
The method for the indexing (container[index]
) operation