pub struct WnafScalar<F: PrimeField + WnafSize, W: WindowSize> { /* private fields */ }Expand description
A “w-ary non-adjacent form” scalar, precomputed to improve the speed of scalar multiplication.
The wNAF representation is represented by a table of Digits which includes one for each
bit of the original scalar, plus an additional bit for any remaining carry, i.e.
F::NUM_BITS + 1.
§Examples
See WnafBase for usage examples.
Implementations§
Source§impl<F: PrimeField + WnafSize, W: WindowSize> WnafScalar<F, W>
impl<F: PrimeField + WnafSize, W: WindowSize> WnafScalar<F, W>
Sourcepub fn new(scalar: &F) -> Self
pub fn new(scalar: &F) -> Self
Computes the wNAF representation of the given scalar with window size W.
Sourcepub fn from_le_bytes(bytes: &[u8]) -> Self
pub fn from_le_bytes(bytes: &[u8]) -> Self
Computes the wNAF representation directly from raw little-endian bytes.
bytes is interpreted as a little-endian unsigned integer (trailing zero bytes may be
omitted), and the resulting WnafScalar evaluates to that integer times the base.
Because the number of wNAF digits, and therefore the number of doublings, is proportional
to bytes.len() * 8, passing a slice shorter than the field’s canonical representation is
faster.
§Panics
If bytes*8+1 > S::USIZE.
Sourcepub fn init_from_le_bytes(&mut self, bytes: &[u8])
pub fn init_from_le_bytes(&mut self, bytes: &[u8])
Initialize wNAF representation directly from raw little-endian bytes, for an already
allocated WnafScalar.
This is the equivalent of WnafScalar::from_le_bytes for reusing an existing value.
See that method for full documentation.
§Panics
If bytes is larger than F::Repr.
Trait Implementations§
Source§impl<F: Clone + PrimeField + WnafSize, W: Clone + WindowSize> Clone for WnafScalar<F, W>where
F::StorageSize: Clone,
impl<F: Clone + PrimeField + WnafSize, W: Clone + WindowSize> Clone for WnafScalar<F, W>where
F::StorageSize: Clone,
Source§fn clone(&self) -> WnafScalar<F, W>
fn clone(&self) -> WnafScalar<F, W>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more