Struct dusk_bls12_381::BlsScalar [−][src]
Represents an element of the scalar field $\mathbb{F}_q$ of the BLS12-381 elliptic curve construction.
Implementations
impl Scalar
[src]
impl Scalar
[src]pub const fn zero() -> Scalar
[src]
Returns zero, the additive identity.
pub const fn one() -> Scalar
[src]
Returns one, the multiplicative identity.
pub fn is_zero(&self) -> Choice
[src]
Checks in ct_time whether a Scalar is equal to zero.
pub fn is_one(&self) -> Choice
[src]
Checks in ct_time whether a Scalar is equal to one.
pub const fn internal_repr(&self) -> &[u64; 4]
[src]
Returns the internal representation of the Scalar.
pub const fn double(&self) -> Scalar
[src]
Doubles this field element.
pub fn to_bits(&self) -> [u8; 256]
[src]
Returns the bit representation of the given Scalar
as
an array of 256 bits represented as u8
.
pub fn from_bytes_wide(bytes: &[u8; 64]) -> Scalar
[src]
Converts a 512-bit little endian integer into
a Scalar
by reducing by the modulus.
pub const fn from_raw(val: [u64; 4]) -> Self
[src]
Converts from an integer represented in little endian
into its (congruent) Scalar
representation.
pub fn random<T>(rand: &mut T) -> Scalar where
T: RngCore + CryptoRng,
[src]
T: RngCore + CryptoRng,
Generate a valid Scalar choosen uniformly using user- provided rng.
By rng
we mean any Rng that implements: Rng
+ CryptoRng
.
pub fn reduce(&self) -> Scalar
[src]
Reduces the scalar and returns it multiplied by the montgomery radix.
pub const fn square(&self) -> Scalar
[src]
Squares this element.
pub fn sqrt(&self) -> CtOption<Self>
[src]
Computes the square root of this element, if it exists.
pub fn pow(&self, by: &[u64; 4]) -> Self
[src]
Exponentiates self
by by
, where by
is a
little-endian order integer exponent.
pub fn pow_vartime(&self, by: &[u64; 4]) -> Self
[src]
Exponentiates self
by by
, where by
is a
little-endian order integer exponent.
This operation is variable time with respect to the exponent. If the exponent is fixed, this operation is effectively constant time.
pub fn pow_of_2(by: u64) -> Self
[src]
Computes 2^X
where X is a u64
without the need to generate
pub fn invert(&self) -> CtOption<Self>
[src]
Computes the multiplicative inverse of this element, failing if the element is zero.
pub const fn mul(&self, rhs: &Self) -> Self
[src]
Multiplies rhs
by self
, returning the result.
pub const fn sub(&self, rhs: &Self) -> Self
[src]
Subtracts rhs
from self
, returning the result.
pub const fn add(&self, rhs: &Self) -> Self
[src]
Adds rhs
to self
, returning the result.
pub const fn neg(&self) -> Self
[src]
Negates self
.
pub fn divn(&mut self, n: u32)
[src]
SHR impl
Trait Implementations
impl ConditionallySelectable for Scalar
[src]
impl ConditionallySelectable for Scalar
[src]fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
[src]
pub fn conditional_assign(&mut self, other: &Self, choice: Choice)
[src]
pub fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
[src]
impl<'a, 'b> Mul<&'b Scalar> for &'a G1Projective
[src]
impl<'a, 'b> Mul<&'b Scalar> for &'a G1Projective
[src]impl<'b> Mul<&'b Scalar> for G1Projective
[src]
impl<'b> Mul<&'b Scalar> for G1Projective
[src]type Output = G1Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b BlsScalar) -> G1Projective
[src]
impl<'b> Mul<&'b Scalar> for G1Affine
[src]
impl<'b> Mul<&'b Scalar> for G1Affine
[src]type Output = G1Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b BlsScalar) -> G1Projective
[src]
impl<'a, 'b> Mul<&'b Scalar> for &'a G2Projective
[src]
impl<'a, 'b> Mul<&'b Scalar> for &'a G2Projective
[src]impl<'b> Mul<&'b Scalar> for G2Projective
[src]
impl<'b> Mul<&'b Scalar> for G2Projective
[src]type Output = G2Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b BlsScalar) -> G2Projective
[src]
impl<'b> Mul<&'b Scalar> for G2Affine
[src]
impl<'b> Mul<&'b Scalar> for G2Affine
[src]type Output = G2Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b BlsScalar) -> G2Projective
[src]
impl<'a> Mul<Scalar> for &'a G1Projective
[src]
impl<'a> Mul<Scalar> for &'a G1Projective
[src]type Output = G1Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G1Projective
[src]
impl Mul<Scalar> for G1Projective
[src]
impl Mul<Scalar> for G1Projective
[src]type Output = G1Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G1Projective
[src]
impl<'a> Mul<Scalar> for &'a G1Affine
[src]
impl<'a> Mul<Scalar> for &'a G1Affine
[src]type Output = G1Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G1Projective
[src]
impl Mul<Scalar> for G1Affine
[src]
impl Mul<Scalar> for G1Affine
[src]type Output = G1Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G1Projective
[src]
impl<'a> Mul<Scalar> for &'a G2Projective
[src]
impl<'a> Mul<Scalar> for &'a G2Projective
[src]type Output = G2Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G2Projective
[src]
impl Mul<Scalar> for G2Projective
[src]
impl Mul<Scalar> for G2Projective
[src]type Output = G2Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G2Projective
[src]
impl<'a> Mul<Scalar> for &'a G2Affine
[src]
impl<'a> Mul<Scalar> for &'a G2Affine
[src]type Output = G2Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G2Projective
[src]
impl Mul<Scalar> for G2Affine
[src]
impl Mul<Scalar> for G2Affine
[src]type Output = G2Projective
The resulting type after applying the *
operator.
fn mul(self, rhs: BlsScalar) -> G2Projective
[src]
impl<'b> MulAssign<&'b Scalar> for G1Projective
[src]
impl<'b> MulAssign<&'b Scalar> for G1Projective
[src]fn mul_assign(&mut self, rhs: &'b BlsScalar)
[src]
impl<'b> MulAssign<&'b Scalar> for G2Projective
[src]
impl<'b> MulAssign<&'b Scalar> for G2Projective
[src]fn mul_assign(&mut self, rhs: &'b BlsScalar)
[src]
impl MulAssign<Scalar> for G1Projective
[src]
impl MulAssign<Scalar> for G1Projective
[src]fn mul_assign(&mut self, rhs: BlsScalar)
[src]
impl MulAssign<Scalar> for G2Projective
[src]
impl MulAssign<Scalar> for G2Projective
[src]fn mul_assign(&mut self, rhs: BlsScalar)
[src]
impl PartialOrd<Scalar> for Scalar
[src]
impl PartialOrd<Scalar> for Scalar
[src]impl Serializable<32_usize> for Scalar
[src]
impl Serializable<32_usize> for Scalar
[src]type Error = BytesError
The type returned in the event of a conversion error.
fn to_bytes(&self) -> [u8; 32]
[src]
Converts an element of Scalar
into a byte representation in
little-endian byte order.
fn from_bytes(buf: &[u8; 32]) -> Result<Self, Self::Error>
[src]
Attempts to convert a little-endian byte representation of
a scalar into a Scalar
, failing if the input is not canonical.
pub const SIZE: usize
[src]
impl StructuralEq for Scalar
[src]
impl StructuralEq for Scalar
[src]Auto Trait Implementations
impl RefUnwindSafe for Scalar
impl RefUnwindSafe for Scalar
impl UnwindSafe for Scalar
impl UnwindSafe for Scalar
Blanket Implementations
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
[src]
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
[src]pub fn conditional_negate(&mut self, choice: Choice)
[src]
impl<T, const N: usize> DeserializableSlice<N> for T where
T: Serializable<N>,
[src]
impl<T, const N: usize> DeserializableSlice<N> for T where
T: Serializable<N>,
[src]impl<T, const N: usize> ParseHexStr<N> for T where
T: Serializable<N>,
[src]
impl<T, const N: usize> ParseHexStr<N> for T where
T: Serializable<N>,
[src]pub fn from_hex_str(s: &str) -> Result<Self, Self::Error> where
Self::Error: BadLength,
Self::Error: InvalidChar,
[src]
Self::Error: BadLength,
Self::Error: InvalidChar,