Skip to main content

WnafScalar

Struct WnafScalar 

Source
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>

Source

pub fn new(scalar: &F) -> Self

Computes the wNAF representation of the given scalar with window size W.

Source

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.

Source

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,

Source§

fn clone(&self) -> WnafScalar<F, W>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + PrimeField + WnafSize, W: Debug + WindowSize> Debug for WnafScalar<F, W>
where F::StorageSize: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<F: Default + PrimeField + WnafSize, W: Default + WindowSize> Default for WnafScalar<F, W>
where F::StorageSize: Default,

Source§

fn default() -> WnafScalar<F, W>

Returns the “default value” for a type. Read more
Source§

impl<G, W> Mul<&WnafScalar<<G as Group>::Scalar, W>> for &WnafBase<G, W>
where G: Group<Scalar: WnafSize>, W: WindowSize,

Source§

type Output = G

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &WnafScalar<G::Scalar, W>) -> Self::Output

Performs the * operation. Read more
Source§

impl<G, W> Mul<&WnafScalar<<G as Group>::Scalar, W>> for WnafBase<G, W>
where G: Group<Scalar: WnafSize>, W: WindowSize,

Source§

type Output = G

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &WnafScalar<G::Scalar, W>) -> Self::Output

Performs the * operation. Read more
Source§

impl<G, W> Mul<WnafScalar<<G as Group>::Scalar, W>> for WnafBase<G, W>
where G: Group<Scalar: WnafSize>, W: WindowSize,

Source§

type Output = G

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: WnafScalar<G::Scalar, W>) -> Self::Output

Performs the * operation. Read more

Auto Trait Implementations§

§

impl<F, W> Freeze for WnafScalar<F, W>

§

impl<F, W> RefUnwindSafe for WnafScalar<F, W>

§

impl<F, W> Send for WnafScalar<F, W>
where W: Send,

§

impl<F, W> Sync for WnafScalar<F, W>
where W: Sync,

§

impl<F, W> Unpin for WnafScalar<F, W>
where <<F as WnafSize>::StorageSize as ArraySize>::ArrayType<i8>: Unpin, F: Unpin, W: Unpin,

§

impl<F, W> UnsafeUnpin for WnafScalar<F, W>

§

impl<F, W> UnwindSafe for WnafScalar<F, W>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.