Struct dusk_plonk::prelude::BlsScalar
source · [−]Expand description
Represents an element of the scalar field $\mathbb{F}_q$ of the BLS12-381 elliptic curve construction.
Tuple Fields
0: [u64; 4]
Implementations
sourceimpl Scalar
impl Scalar
sourcepub const fn internal_repr(&self) -> &[u64; 4]
pub const fn internal_repr(&self) -> &[u64; 4]
Returns the internal representation of the Scalar.
sourcepub fn to_bits(&self) -> [u8; 256]
pub fn to_bits(&self) -> [u8; 256]
Returns the bit representation of the given Scalar
as
an array of 256 bits represented as u8
.
sourcepub fn from_bytes_wide(bytes: &[u8; 64]) -> Scalar
pub fn from_bytes_wide(bytes: &[u8; 64]) -> Scalar
Converts a 512-bit little endian integer into
a Scalar
by reducing by the modulus.
sourcepub const fn from_raw(val: [u64; 4]) -> Scalar
pub const fn from_raw(val: [u64; 4]) -> Scalar
Converts from an integer represented in little endian
into its (congruent) Scalar
representation.
sourcepub fn random<T>(rand: &mut T) -> Scalar where
T: RngCore + CryptoRng,
pub fn random<T>(rand: &mut T) -> Scalar where
T: RngCore + CryptoRng,
Generate a valid Scalar choosen uniformly using user- provided rng.
By rng
we mean any Rng that implements: Rng
+ CryptoRng
.
sourcepub fn reduce(&self) -> Scalar
pub fn reduce(&self) -> Scalar
Reduces the scalar and returns it multiplied by the montgomery radix.
sourcepub fn pow(&self, by: &[u64; 4]) -> Scalar
pub fn pow(&self, by: &[u64; 4]) -> Scalar
Exponentiates self
by by
, where by
is a
little-endian order integer exponent.
sourcepub fn pow_vartime(&self, by: &[u64; 4]) -> Scalar
pub fn pow_vartime(&self, by: &[u64; 4]) -> Scalar
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.
sourcepub fn pow_of_2(by: u64) -> Scalar
pub fn pow_of_2(by: u64) -> Scalar
Computes 2^X
where X is a u64
without the need to generate
an array in the stack as pow
& pow_vartime
require.
Trait Implementations
sourceimpl<'b> AddAssign<&'b Scalar> for Scalar
impl<'b> AddAssign<&'b Scalar> for Scalar
sourcefn add_assign(&mut self, rhs: &'b Scalar)
fn add_assign(&mut self, rhs: &'b Scalar)
Performs the +=
operation. Read more
sourceimpl AddAssign<Scalar> for Scalar
impl AddAssign<Scalar> for Scalar
sourcefn add_assign(&mut self, rhs: Scalar)
fn add_assign(&mut self, rhs: Scalar)
Performs the +=
operation. Read more
sourceimpl ConditionallySelectable for Scalar
impl ConditionallySelectable for Scalar
sourceimpl ConstantTimeEq for Scalar
impl ConstantTimeEq for Scalar
sourceimpl From<Scalar> for PublicInputValue
impl From<Scalar> for PublicInputValue
sourceimpl<'b> MulAssign<&'b Scalar> for Scalar
impl<'b> MulAssign<&'b Scalar> for Scalar
sourcefn mul_assign(&mut self, rhs: &'b Scalar)
fn mul_assign(&mut self, rhs: &'b Scalar)
Performs the *=
operation. Read more
sourceimpl MulAssign<Scalar> for Scalar
impl MulAssign<Scalar> for Scalar
sourcefn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
Performs the *=
operation. Read more
sourceimpl Ord for Scalar
impl Ord for Scalar
sourceimpl PartialOrd<Scalar> for Scalar
impl PartialOrd<Scalar> for Scalar
sourcefn partial_cmp(&self, other: &Scalar) -> Option<Ordering>
fn partial_cmp(&self, other: &Scalar) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serializable<32_usize> for Scalar
impl Serializable<32_usize> for Scalar
sourcefn to_bytes(&self) -> [u8; 32]
fn to_bytes(&self) -> [u8; 32]
Converts an element of Scalar
into a byte representation in
little-endian byte order.
sourcefn from_bytes(
buf: &[u8; 32]
) -> Result<Scalar, <Scalar as Serializable<32_usize>>::Error>
fn from_bytes(
buf: &[u8; 32]
) -> Result<Scalar, <Scalar as Serializable<32_usize>>::Error>
Attempts to convert a little-endian byte representation of
a scalar into a Scalar
, failing if the input is not canonical.
sourceimpl<'b> SubAssign<&'b Scalar> for Scalar
impl<'b> SubAssign<&'b Scalar> for Scalar
sourcefn sub_assign(&mut self, rhs: &'b Scalar)
fn sub_assign(&mut self, rhs: &'b Scalar)
Performs the -=
operation. Read more
sourceimpl SubAssign<Scalar> for Scalar
impl SubAssign<Scalar> for Scalar
sourcefn sub_assign(&mut self, rhs: Scalar)
fn sub_assign(&mut self, rhs: Scalar)
Performs the -=
operation. Read more
impl Copy for Scalar
impl Eq for Scalar
impl StructuralEq 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
impl<T> ConditionallyNegatable for T where
T: ConditionallySelectable,
&'a T: for<'a> Neg,
<&'a T as Neg>::Output == T,
sourcefn conditional_negate(&mut self, choice: Choice)
fn conditional_negate(&mut self, choice: Choice)
Negate self
if choice == Choice(1)
; otherwise, leave it
unchanged. Read more
sourceimpl<T, const N: usize> DeserializableSlice<N> for T where
T: Serializable<N>,
impl<T, const N: usize> DeserializableSlice<N> for T where
T: Serializable<N>,
sourceimpl<T, const N: usize> ParseHexStr<N> for T where
T: Serializable<N>,
impl<T, const N: usize> ParseHexStr<N> for T where
T: Serializable<N>,
sourcefn from_hex_str(s: &str) -> Result<Self, Self::Error> where
Self::Error: BadLength,
Self::Error: InvalidChar,
fn from_hex_str(s: &str) -> Result<Self, Self::Error> where
Self::Error: BadLength,
Self::Error: InvalidChar,
Parse a string slice as bytes hex representation and returns `