Struct Bls12_381Scalar

Source
pub struct Bls12_381Scalar(/* private fields */);
Expand description

Scalar field element of BLS12-381 Internal: Four 64-bit limbs in little-endian Montgomery form

Implementations§

Source§

impl Scalar

Source

pub const fn zero() -> Scalar

Additive identity

Source

pub const fn one() -> Scalar

Multiplicative identity

Source

pub const fn double(&self) -> Scalar

Double this element

Source

pub fn from_bytes(bytes: &[u8; 32]) -> CtOption<Scalar>

Create from little-endian bytes if canonical

Source

pub fn to_bytes(&self) -> [u8; 32]

Convert to little-endian bytes

Source

pub fn from_bytes_wide(bytes: &[u8; 64]) -> Scalar

Create from 512-bit little-endian integer mod q

Source

pub const fn from_raw(val: [u64; 4]) -> Self

Create from raw values and convert to Montgomery

Source

pub const fn square(&self) -> Scalar

Square this element

Source

pub fn invert(&self) -> CtOption<Self>

Multiplicative inverse

Source

pub const fn mul(&self, rhs: &Self) -> Self

Multiply two scalars

Source

pub const fn sub(&self, rhs: &Self) -> Self

Subtract rhs from self

Source

pub const fn add(&self, rhs: &Self) -> Self

Add rhs to self

Source

pub const fn neg(&self) -> Self

Negate self

Trait Implementations§

Source§

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

Source§

type Output = Scalar

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Scalar) -> Scalar

Performs the + operation. Read more
Source§

impl<'b> Add<&'b Scalar> for Scalar

Source§

type Output = Scalar

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Scalar) -> Scalar

Performs the + operation. Read more
Source§

impl<'a> Add<Scalar> for &'a Scalar

Source§

type Output = Scalar

The resulting type after applying the + operator.
Source§

fn add(self, rhs: 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, rhs: Scalar) -> Scalar

Performs the + operation. Read more
Source§

impl<'b> AddAssign<&'b Scalar> for Scalar

Source§

fn add_assign(&mut self, rhs: &'b Scalar)

Performs the += operation. Read more
Source§

impl AddAssign for Scalar

Source§

fn add_assign(&mut self, rhs: Scalar)

Performs the += operation. Read more
Source§

impl ByteSerializable for Scalar

Source§

fn to_bytes(&self) -> Vec<u8>

Convert to a byte vector
Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>

Try to create from a byte slice
Source§

impl Clone for Scalar

Source§

fn clone(&self) -> Scalar

Returns a duplicate 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 ConditionallySelectable for Scalar

Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl ConstantTimeEq for Scalar

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl ConstantTimeEq for Scalar

Source§

fn ct_eq(&self, other: &Self) -> bool

Compare two values in constant time
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() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Scalar

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> From<&'a Scalar> for [u8; 32]

Source§

fn from(value: &'a Scalar) -> [u8; 32]

Converts to this type from the input type.
Source§

impl From<Scalar> for [u8; 32]

Source§

fn from(value: Scalar) -> [u8; 32]

Converts to this type from the input type.
Source§

impl From<u64> for Scalar

Source§

fn from(val: u64) -> Scalar

Converts to this type from the input type.
Source§

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

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G1Affine) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b G1Affine> for Scalar

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G1Affine) -> G1Projective

Performs the * operation. Read more
Source§

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

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G1Projective) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b G1Projective> for Scalar

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G1Projective) -> G1Projective

Performs the * operation. Read more
Source§

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

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G2Affine) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b G2Affine> for Scalar

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G2Affine) -> G2Projective

Performs the * operation. Read more
Source§

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

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G2Projective) -> Self::Output

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b G2Projective> for Scalar

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b G2Projective) -> G2Projective

Performs the * operation. Read more
Source§

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

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b Scalar) -> Self::Output

Performs the * operation. Read more
Source§

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

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b Scalar) -> Self::Output

Performs the * operation. Read more
Source§

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

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b Scalar) -> Self::Output

Performs the * operation. Read more
Source§

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

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b Scalar) -> Self::Output

Performs the * operation. Read more
Source§

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

Source§

type Output = Gt

The resulting type after applying the * operator.
Source§

fn mul(self, other: &'b Scalar) -> Self::Output

Performs the * operation. Read more
Source§

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

Source§

type Output = Scalar

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar) -> Scalar

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar> for G1Affine

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar) -> G1Projective

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar> for G1Projective

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar) -> G1Projective

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar) -> G2Projective

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar> for G2Projective

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar) -> G2Projective

Performs the * operation. Read more
Source§

impl<'b> Mul<&'b Scalar> for Gt

Source§

type Output = Gt

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar) -> Gt

Performs the * operation. Read more
Source§

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

Source§

type Output = Scalar

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'b Scalar) -> Scalar

Performs the * operation. Read more
Source§

impl<'a> Mul<G1Affine> for &'a Scalar

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G1Affine) -> G1Projective

Performs the * operation. Read more
Source§

impl Mul<G1Affine> for Scalar

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G1Affine) -> G1Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<G1Projective> for &'a Scalar

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G1Projective) -> G1Projective

Performs the * operation. Read more
Source§

impl Mul<G1Projective> for Scalar

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G1Projective) -> G1Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<G2Affine> for &'a Scalar

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G2Affine) -> G2Projective

Performs the * operation. Read more
Source§

impl Mul<G2Affine> for Scalar

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G2Affine) -> G2Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<G2Projective> for &'a Scalar

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G2Projective) -> G2Projective

Performs the * operation. Read more
Source§

impl Mul<G2Projective> for Scalar

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: G2Projective) -> G2Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar> for &'a G1Affine

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G1Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar> for &'a G1Projective

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G1Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar> for &'a G2Affine

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G2Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar> for &'a G2Projective

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G2Projective

Performs the * operation. Read more
Source§

impl<'a> Mul<Scalar> for &'a Gt

Source§

type Output = Gt

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> Gt

Performs the * operation. Read more
Source§

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

Source§

type Output = Scalar

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> Scalar

Performs the * operation. Read more
Source§

impl Mul<Scalar> for G1Affine

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G1Projective

Performs the * operation. Read more
Source§

impl Mul<Scalar> for G1Projective

Source§

type Output = G1Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G1Projective

Performs the * operation. Read more
Source§

impl Mul<Scalar> for G2Affine

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G2Projective

Performs the * operation. Read more
Source§

impl Mul<Scalar> for G2Projective

Source§

type Output = G2Projective

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> G2Projective

Performs the * operation. Read more
Source§

impl Mul<Scalar> for Gt

Source§

type Output = Gt

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Scalar) -> Gt

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, rhs: Scalar) -> Scalar

Performs the * operation. Read more
Source§

impl<'b> MulAssign<&'b Scalar> for G1Projective

Source§

fn mul_assign(&mut self, rhs: &'b Scalar)

Performs the *= operation. Read more
Source§

impl<'b> MulAssign<&'b Scalar> for G2Projective

Source§

fn mul_assign(&mut self, rhs: &'b Scalar)

Performs the *= operation. Read more
Source§

impl<'b> MulAssign<&'b Scalar> for Gt

Source§

fn mul_assign(&mut self, rhs: &'b Scalar)

Performs the *= operation. Read more
Source§

impl<'b> MulAssign<&'b Scalar> for Scalar

Source§

fn mul_assign(&mut self, rhs: &'b Scalar)

Performs the *= operation. Read more
Source§

impl MulAssign<Scalar> for G1Projective

Source§

fn mul_assign(&mut self, rhs: Scalar)

Performs the *= operation. Read more
Source§

impl MulAssign<Scalar> for G2Projective

Source§

fn mul_assign(&mut self, rhs: Scalar)

Performs the *= operation. Read more
Source§

impl MulAssign<Scalar> for Gt

Source§

fn mul_assign(&mut self, rhs: Scalar)

Performs the *= operation. Read more
Source§

impl MulAssign for Scalar

Source§

fn mul_assign(&mut self, rhs: 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: &Self) -> 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<T> Product<T> for Scalar
where T: Borrow<Scalar>,

Source§

fn product<I>(iter: I) -> Self
where I: Iterator<Item = T>,

Takes an iterator and generates Self from the elements by multiplying the items.
Source§

impl SecureZeroingType for Scalar

Source§

fn zeroed() -> Self

Create a zeroed instance
Source§

fn secure_clone(&self) -> Self

Create a secure clone that preserves security properties Read more
Source§

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

Source§

type Output = Scalar

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Scalar) -> Scalar

Performs the - operation. Read more
Source§

impl<'b> Sub<&'b Scalar> for Scalar

Source§

type Output = Scalar

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Scalar) -> Scalar

Performs the - operation. Read more
Source§

impl<'a> Sub<Scalar> for &'a Scalar

Source§

type Output = Scalar

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Scalar) -> Scalar

Performs the - operation. Read more
Source§

impl Sub for Scalar

Source§

type Output = Scalar

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Scalar) -> Scalar

Performs the - operation. Read more
Source§

impl<'b> SubAssign<&'b Scalar> for Scalar

Source§

fn sub_assign(&mut self, rhs: &'b Scalar)

Performs the -= operation. Read more
Source§

impl SubAssign for Scalar

Source§

fn sub_assign(&mut self, rhs: Scalar)

Performs the -= operation. Read more
Source§

impl<T> Sum<T> for Scalar
where T: Borrow<Scalar>,

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = T>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Copy for Scalar

Source§

impl DefaultIsZeroes for Scalar

Source§

impl Eq 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, dest: *mut u8)

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

impl<T> ConditionallyNegatable for T
where T: ConditionallySelectable, &'a T: for<'a> Neg<Output = T>,

Source§

fn conditional_negate(&mut self, choice: Choice)

Negate self if choice == Choice(1); otherwise, leave it unchanged. 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<Z> Zeroize for Z
where Z: DefaultIsZeroes,

Source§

fn zeroize(&mut self)

Zero out this object from memory using Rust intrinsics which ensure the zeroization operation is not “optimized away” by the compiler.