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

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

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 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 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<(), Error>

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

source§

fn into(self) -> Scalar

Converts this type into the (usually inferred) input type.
source§

impl LowerHex for Scalar

source§

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

Formats the value using the given formatter. Read more
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 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 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 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 TryFrom<Scalar> for SecretKey

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(scalar: Scalar) -> Result<Self, Error>

Performs the conversion.
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: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬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

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V