libsecp256k1_core::curve

Struct Scalar

Source
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

Source§

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 for Scalar

Source§

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 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. Read more
Source§

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

Source§

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 for Scalar

Source§

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 for Scalar

Source§

fn mul_assign(&mut self, other: Scalar)

Performs the *= operation. Read more
Source§

impl<'a> Neg for &'a Scalar

Source§

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

Source§

type Output = Scalar

The resulting type after applying the - operator.
Source§

fn neg(self) -> Scalar

Performs the unary - operation. Read more
Source§

impl PartialEq for Scalar

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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 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> 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, dst: *mut u8)

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