Struct libsecp256k1::curve::Scalar
source · 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<Scalar> for Scalar
impl AddAssign<Scalar> 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<Scalar> for Scalar
impl MulAssign<Scalar> for Scalar
source§fn mul_assign(&mut self, other: Scalar)
fn mul_assign(&mut self, other: Scalar)
Performs the
*=
operation. Read moresource§impl PartialEq<Scalar> for Scalar
impl PartialEq<Scalar> for Scalar
impl Copy for Scalar
impl Eq for Scalar
impl StructuralEq for Scalar
impl StructuralPartialEq for Scalar
Auto Trait Implementations§
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