pub struct Scalar(pub [u32; 8]);
Expand description
A 256-bit scalar value.
Tuple Fields§
§0: [u32; 8]
Implementations§
Source§impl Scalar
impl Scalar
Sourcepub fn bits(&self, offset: usize, count: usize) -> u32
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.
Sourcepub fn bits_var(&self, offset: usize, count: usize) -> u32
pub fn bits_var(&self, offset: usize, count: usize) -> u32
Access bits from a scalar. Not constant time.
Sourcepub fn cadd_bit(&mut self, bit: usize, flag: bool)
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.
Sourcepub fn set_b32(&mut self, b32: &[u8; 32]) -> Choice
pub fn set_b32(&mut self, b32: &[u8; 32]) -> Choice
Set a scalar from a big endian byte array, return whether it overflowed.
Sourcepub fn is_high(&self) -> bool
pub fn is_high(&self) -> bool
Check whether a scalar is higher than the group order divided by 2.
Sourcepub fn cond_neg_assign(&mut self, flag: Choice)
pub fn cond_neg_assign(&mut self, flag: Choice)
Conditionally negate a number, in constant time.
Source§impl Scalar
impl Scalar
pub fn mul_in_place(&mut self, a: &Scalar, b: &Scalar)
Sourcepub fn shr_int(&mut self, n: usize) -> u32
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.
pub fn sqr_in_place(&mut self, a: &Scalar)
pub fn sqr(&self) -> Scalar
pub fn inv_in_place(&mut self, x: &Scalar)
pub fn inv(&self) -> Scalar
pub fn inv_var(&self) -> Scalar
pub fn is_even(&self) -> bool
Trait Implementations§
Source§impl<'a> AddAssign<&'a Scalar> for Scalar
impl<'a> AddAssign<&'a Scalar> for Scalar
Source§fn add_assign(&mut self, other: &'a Scalar)
fn add_assign(&mut self, other: &'a Scalar)
Performs the
+=
operation. Read moreSource§impl AddAssign for Scalar
impl AddAssign for Scalar
Source§fn add_assign(&mut self, other: Scalar)
fn add_assign(&mut self, other: Scalar)
Performs the
+=
operation. Read moreSource§impl<'a> MulAssign<&'a Scalar> for Scalar
impl<'a> MulAssign<&'a Scalar> for Scalar
Source§fn mul_assign(&mut self, other: &'a Scalar)
fn mul_assign(&mut self, other: &'a Scalar)
Performs the
*=
operation. Read moreSource§impl MulAssign for Scalar
impl MulAssign for Scalar
Source§fn mul_assign(&mut self, other: Scalar)
fn mul_assign(&mut self, other: Scalar)
Performs the
*=
operation. Read moreimpl Copy for Scalar
impl Eq for Scalar
impl StructuralPartialEq for Scalar
Auto Trait Implementations§
impl Freeze for Scalar
impl RefUnwindSafe for Scalar
impl Send for Scalar
impl Sync for Scalar
impl Unpin for Scalar
impl UnwindSafe for Scalar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more