pub struct Scalar(pub [u32; 8]);
Expand description

A 256-bit scalar value.

Tuple Fields§

§0: [u32; 8]

Implementations§

source§

impl Scalar

source

pub fn clear(&mut self)

Clear a scalar to prevent the leak of sensitive data.

source

pub fn set_int(&mut self, v: u32)

Set a scalar to an unsigned integer.

source

pub fn from_int(v: u32) -> Self

Create a scalar from an unsigned integer.

source

pub fn bits(&self, offset: usize, count: usize) -> u32

Access bits from a scalar. All requested bits must belong to the same 32-bit limb.

source

pub fn bits_var(&self, offset: usize, count: usize) -> u32

Access bits from a scalar. Not constant time.

source

pub fn cadd_bit(&mut self, bit: usize, flag: bool)

Conditionally add a power of two to a scalar. The result is not allowed to overflow.

source

pub fn set_b32(&mut self, b32: &[u8; 32]) -> Choice

Set a scalar from a big endian byte array, return whether it overflowed.

source

pub fn b32(&self) -> [u8; 32]

Convert a scalar to a byte array.

source

pub fn fill_b32(&self, bin: &mut [u8; 32])

Convert a scalar to a byte array.

source

pub fn is_zero(&self) -> bool

Check whether a scalar equals zero.

source

pub fn is_one(&self) -> bool

Check whether a scalar equals one.

source

pub fn is_high(&self) -> bool

Check whether a scalar is higher than the group order divided by 2.

source

pub fn cond_neg_assign(&mut self, flag: Choice)

Conditionally negate a number, in constant time.

source§

impl Scalar

source

pub fn mul_in_place(&mut self, a: &Scalar, b: &Scalar)

source

pub fn shr_int(&mut self, n: usize) -> u32

Shift a scalar right by some amount strictly between 0 and 16, returning the low bits that were shifted off.

source

pub fn sqr_in_place(&mut self, a: &Scalar)

source

pub fn sqr(&self) -> Scalar

source

pub fn inv_in_place(&mut self, x: &Scalar)

source

pub fn inv(&self) -> Scalar

source

pub fn inv_var(&self) -> Scalar

source

pub fn is_even(&self) -> bool

Trait Implementations§

source§

impl<'a, 'b> Add<&'a Scalar> for &'b Scalar

§

type Output = Scalar

The resulting type after applying the + operator.
source§

fn add(self, other: &'a Scalar) -> Scalar

Performs the + operation. Read more
source§

impl Add<Scalar> for Scalar

§

type Output = Scalar

The resulting type after applying the + operator.
source§

fn add(self, other: Scalar) -> Scalar

Performs the + operation. Read more
source§

impl<'a> AddAssign<&'a Scalar> for Scalar

source§

fn add_assign(&mut self, other: &'a Scalar)

Performs the += operation. Read more
source§

impl AddAssign<Scalar> for Scalar

source§

fn add_assign(&mut self, other: Scalar)

Performs the += operation. Read more
source§

impl Clone for Scalar

source§

fn clone(&self) -> Scalar

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for Scalar

source§

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

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

impl Default for Scalar

source§

fn default() -> Scalar

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

impl LowerHex for Scalar

source§

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

Formats the value using the given formatter.
source§

impl<'a, 'b> Mul<&'a Scalar> for &'b Scalar

§

type Output = Scalar

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a Scalar) -> Scalar

Performs the * operation. Read more
source§

impl Mul<Scalar> for Scalar

§

type Output = Scalar

The resulting type after applying the * operator.
source§

fn mul(self, other: Scalar) -> Scalar

Performs the * operation. Read more
source§

impl<'a> MulAssign<&'a Scalar> for Scalar

source§

fn mul_assign(&mut self, other: &'a Scalar)

Performs the *= operation. Read more
source§

impl MulAssign<Scalar> for Scalar

source§

fn mul_assign(&mut self, other: Scalar)

Performs the *= operation. Read more
source§

impl<'a> Neg for &'a Scalar

§

type Output = Scalar

The resulting type after applying the - operator.
source§

fn neg(self) -> Scalar

Performs the unary - operation. Read more
source§

impl Neg for Scalar

§

type Output = Scalar

The resulting type after applying the - operator.
source§

fn neg(self) -> Scalar

Performs the unary - operation. Read more
source§

impl PartialEq<Scalar> for Scalar

source§

fn eq(&self, other: &Scalar) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Scalar

source§

impl Eq for Scalar

source§

impl StructuralEq for Scalar

source§

impl StructuralPartialEq for Scalar

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.