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
impl Scalar
Sourcepub fn from_bytes(bytes: &[u8; 32]) -> CtOption<Scalar>
pub fn from_bytes(bytes: &[u8; 32]) -> CtOption<Scalar>
Create from little-endian bytes if canonical
Sourcepub fn from_bytes_wide(bytes: &[u8; 64]) -> Scalar
pub fn from_bytes_wide(bytes: &[u8; 64]) -> Scalar
Create from 512-bit little-endian integer mod q
Sourcepub fn hash_to_field(data: &[u8], dst: &[u8]) -> Result<Self>
pub fn hash_to_field(data: &[u8], dst: &[u8]) -> Result<Self>
Hashes arbitrary data to a scalar field element using SHA-256.
This function implements a standards-compliant hash-to-field method following the IETF hash-to-curve specification using expand_message_xmd with SHA-256.
§Arguments
data
: The input data to hash.dst
: A Domain Separation Tag (DST) to ensure hashes are unique per application context.
§Returns
A Result
containing the Scalar
or an error.
Trait Implementations§
Source§impl<'b> AddAssign<&'b Scalar> for Scalar
impl<'b> AddAssign<&'b Scalar> for Scalar
Source§fn add_assign(&mut self, rhs: &'b Scalar)
fn add_assign(&mut self, rhs: &'b Scalar)
Performs the
+=
operation. Read moreSource§impl AddAssign for Scalar
impl AddAssign for Scalar
Source§fn add_assign(&mut self, rhs: Scalar)
fn add_assign(&mut self, rhs: Scalar)
Performs the
+=
operation. Read moreSource§impl ByteSerializable for Scalar
impl ByteSerializable for Scalar
Source§impl ConditionallySelectable for Scalar
impl ConditionallySelectable for Scalar
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
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 moreSource§impl ConstantTimeEq for Scalar
impl ConstantTimeEq for Scalar
Source§impl ConstantTimeEq for Scalar
impl ConstantTimeEq for Scalar
Source§impl<'b> Mul<&'b G1Affine> for Scalar
impl<'b> Mul<&'b G1Affine> for Scalar
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl<'a, 'b> Mul<&'b G1Projective> for &'a Scalar
impl<'a, 'b> Mul<&'b G1Projective> for &'a Scalar
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl<'b> Mul<&'b G1Projective> for Scalar
impl<'b> Mul<&'b G1Projective> for Scalar
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: &'b G1Projective) -> G1Projective
fn mul(self, rhs: &'b G1Projective) -> G1Projective
Performs the
*
operation. Read moreSource§impl<'b> Mul<&'b G2Affine> for Scalar
impl<'b> Mul<&'b G2Affine> for Scalar
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl<'a, 'b> Mul<&'b G2Projective> for &'a Scalar
impl<'a, 'b> Mul<&'b G2Projective> for &'a Scalar
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl<'b> Mul<&'b G2Projective> for Scalar
impl<'b> Mul<&'b G2Projective> for Scalar
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: &'b G2Projective) -> G2Projective
fn mul(self, rhs: &'b G2Projective) -> G2Projective
Performs the
*
operation. Read moreSource§impl<'a, 'b> Mul<&'b Scalar> for &'a G1Projective
impl<'a, 'b> Mul<&'b Scalar> for &'a G1Projective
Source§impl<'a, 'b> Mul<&'b Scalar> for &'a G2Projective
impl<'a, 'b> Mul<&'b Scalar> for &'a G2Projective
Source§impl<'b> Mul<&'b Scalar> for G1Affine
impl<'b> Mul<&'b Scalar> for G1Affine
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl<'b> Mul<&'b Scalar> for G1Projective
impl<'b> Mul<&'b Scalar> for G1Projective
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl<'b> Mul<&'b Scalar> for G2Affine
impl<'b> Mul<&'b Scalar> for G2Affine
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl<'b> Mul<&'b Scalar> for G2Projective
impl<'b> Mul<&'b Scalar> for G2Projective
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl<'a> Mul<G1Affine> for &'a Scalar
impl<'a> Mul<G1Affine> for &'a Scalar
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl Mul<G1Affine> for Scalar
impl Mul<G1Affine> for Scalar
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl<'a> Mul<G1Projective> for &'a Scalar
impl<'a> Mul<G1Projective> for &'a Scalar
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: G1Projective) -> G1Projective
fn mul(self, rhs: G1Projective) -> G1Projective
Performs the
*
operation. Read moreSource§impl Mul<G1Projective> for Scalar
impl Mul<G1Projective> for Scalar
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: G1Projective) -> G1Projective
fn mul(self, rhs: G1Projective) -> G1Projective
Performs the
*
operation. Read moreSource§impl<'a> Mul<G2Affine> for &'a Scalar
impl<'a> Mul<G2Affine> for &'a Scalar
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl Mul<G2Affine> for Scalar
impl Mul<G2Affine> for Scalar
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl<'a> Mul<G2Projective> for &'a Scalar
impl<'a> Mul<G2Projective> for &'a Scalar
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: G2Projective) -> G2Projective
fn mul(self, rhs: G2Projective) -> G2Projective
Performs the
*
operation. Read moreSource§impl Mul<G2Projective> for Scalar
impl Mul<G2Projective> for Scalar
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§fn mul(self, rhs: G2Projective) -> G2Projective
fn mul(self, rhs: G2Projective) -> G2Projective
Performs the
*
operation. Read moreSource§impl<'a> Mul<Scalar> for &'a G1Affine
impl<'a> Mul<Scalar> for &'a G1Affine
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl<'a> Mul<Scalar> for &'a G1Projective
impl<'a> Mul<Scalar> for &'a G1Projective
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl<'a> Mul<Scalar> for &'a G2Affine
impl<'a> Mul<Scalar> for &'a G2Affine
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl<'a> Mul<Scalar> for &'a G2Projective
impl<'a> Mul<Scalar> for &'a G2Projective
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl Mul<Scalar> for G1Affine
impl Mul<Scalar> for G1Affine
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl Mul<Scalar> for G1Projective
impl Mul<Scalar> for G1Projective
Source§type Output = G1Projective
type Output = G1Projective
The resulting type after applying the
*
operator.Source§impl Mul<Scalar> for G2Affine
impl Mul<Scalar> for G2Affine
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl Mul<Scalar> for G2Projective
impl Mul<Scalar> for G2Projective
Source§type Output = G2Projective
type Output = G2Projective
The resulting type after applying the
*
operator.Source§impl<'b> MulAssign<&'b Scalar> for G1Projective
impl<'b> MulAssign<&'b Scalar> for G1Projective
Source§fn mul_assign(&mut self, rhs: &'b Scalar)
fn mul_assign(&mut self, rhs: &'b Scalar)
Performs the
*=
operation. Read moreSource§impl<'b> MulAssign<&'b Scalar> for G2Projective
impl<'b> MulAssign<&'b Scalar> for G2Projective
Source§fn mul_assign(&mut self, rhs: &'b Scalar)
fn mul_assign(&mut self, rhs: &'b Scalar)
Performs the
*=
operation. Read moreSource§impl<'b> MulAssign<&'b Scalar> for Gt
impl<'b> MulAssign<&'b Scalar> for Gt
Source§fn mul_assign(&mut self, rhs: &'b Scalar)
fn mul_assign(&mut self, rhs: &'b Scalar)
Performs the
*=
operation. Read moreSource§impl<'b> MulAssign<&'b Scalar> for Scalar
impl<'b> MulAssign<&'b Scalar> for Scalar
Source§fn mul_assign(&mut self, rhs: &'b Scalar)
fn mul_assign(&mut self, rhs: &'b Scalar)
Performs the
*=
operation. Read moreSource§impl MulAssign<Scalar> for G1Projective
impl MulAssign<Scalar> for G1Projective
Source§fn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
Performs the
*=
operation. Read moreSource§impl MulAssign<Scalar> for G2Projective
impl MulAssign<Scalar> for G2Projective
Source§fn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
Performs the
*=
operation. Read moreSource§impl MulAssign<Scalar> for Gt
impl MulAssign<Scalar> for Gt
Source§fn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
Performs the
*=
operation. Read moreSource§impl MulAssign for Scalar
impl MulAssign for Scalar
Source§fn mul_assign(&mut self, rhs: Scalar)
fn mul_assign(&mut self, rhs: Scalar)
Performs the
*=
operation. Read moreSource§impl SecureZeroingType for Scalar
impl SecureZeroingType for Scalar
Source§impl<'b> SubAssign<&'b Scalar> for Scalar
impl<'b> SubAssign<&'b Scalar> for Scalar
Source§fn sub_assign(&mut self, rhs: &'b Scalar)
fn sub_assign(&mut self, rhs: &'b Scalar)
Performs the
-=
operation. Read moreSource§impl SubAssign for Scalar
impl SubAssign for Scalar
Source§fn sub_assign(&mut self, rhs: Scalar)
fn sub_assign(&mut self, rhs: Scalar)
Performs the
-=
operation. Read moreimpl Copy for Scalar
impl DefaultIsZeroes for Scalar
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more