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<'de> Deserialize<'de> for Scalar
impl<'de> Deserialize<'de> for Scalar
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Scalar, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Scalar, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§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 moreSource§impl Ord for Scalar
impl Ord for Scalar
Source§impl PartialOrd for Scalar
impl PartialOrd for Scalar
Source§impl Serialize for Scalar
impl Serialize for Scalar
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl 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