Struct stark_curve::core::W
source · pub struct W<F>(/* private fields */);Expand description
Wraps scalar or field element
Field element and scalar, derived by ff, initially are not compatible with [elliptic-curve] crate and cannot be used together. This struct wraps scalar or field element, and implements required traits.
Implementations§
source§impl<F: PrimeField> W<F>
impl<F: PrimeField> W<F>
sourcepub fn to_be_bytes(&self) -> F::Repr
pub fn to_be_bytes(&self) -> F::Repr
Converts integer to byte array in big-endian
sourcepub fn to_le_bytes(&self) -> F::Repr
pub fn to_le_bytes(&self) -> F::Repr
Converts integer to byte array in little-endian
sourcepub fn from_be_bytes(bytes: F::Repr) -> CtOption<Self>
pub fn from_be_bytes(bytes: F::Repr) -> CtOption<Self>
Constructs integer from its bytes representation in big-endian
Returns None if it overflows maximum allowed value
sourcepub fn from_le_bytes(bytes: F::Repr) -> CtOption<Self>
pub fn from_le_bytes(bytes: F::Repr) -> CtOption<Self>
Constructs integer from its bytes representation in little-endian
Returns None if it overflows maximum allowed value
sourcepub fn from_be_bytes_mod_order(bytes: &[u8]) -> Self
pub fn from_be_bytes_mod_order(bytes: &[u8]) -> Self
Constructs integer from bytes in big-endian
Integer is reduced modulo max allowed value ($p$ if it’s field element, $n$ if it’s a scalar)
sourcepub fn from_le_bytes_mod_order(bytes: &[u8]) -> Self
pub fn from_le_bytes_mod_order(bytes: &[u8]) -> Self
Constructs integer from bytes in little-endian
Integer is reduced modulo max allowed value ($p$ if it’s field element, $n$ if it’s a scalar)
sourcepub fn from_uint_mod_order(uint: &U256) -> Self
pub fn from_uint_mod_order(uint: &U256) -> Self
Constructs integer from [U256]
Integer is reduced modulo max allowed value ($p$ if it’s field element, $n$ if it’s a scalar)
source§impl<F: PrimeField> W<F>
impl<F: PrimeField> W<F>
source§impl W<FieldElementCore>
impl W<FieldElementCore>
Trait Implementations§
source§impl<'r, F: AddAssign<&'r F>> AddAssign<&'r W<F>> for W<F>
impl<'r, F: AddAssign<&'r F>> AddAssign<&'r W<F>> for W<F>
source§fn add_assign(&mut self, rhs: &'r W<F>)
fn add_assign(&mut self, rhs: &'r W<F>)
+= operation. Read moresource§impl<F: AddAssign> AddAssign for W<F>
impl<F: AddAssign> AddAssign for W<F>
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moresource§impl<F: ConditionallySelectable> ConditionallySelectable for W<F>
impl<F: ConditionallySelectable> ConditionallySelectable for W<F>
source§impl<F: ConstantTimeEq> ConstantTimeEq for W<F>
impl<F: ConstantTimeEq> ConstantTimeEq for W<F>
source§impl<F: Field> Field for W<F>
impl<F: Field> Field for W<F>
source§fn random(rng: impl RngCore) -> Self
fn random(rng: impl RngCore) -> Self
source§fn invert(&self) -> CtOption<Self>
fn invert(&self) -> CtOption<Self>
source§fn sqrt(&self) -> CtOption<Self>
fn sqrt(&self) -> CtOption<Self>
source§fn is_zero_vartime(&self) -> bool
fn is_zero_vartime(&self) -> bool
source§impl From<&W<ScalarCore>> for ScalarPrimitive<StarkCurve>
impl From<&W<ScalarCore>> for ScalarPrimitive<StarkCurve>
source§impl<F: PrimeField, C: Curve> From<ScalarPrimitive<C>> for W<F>
impl<F: PrimeField, C: Curve> From<ScalarPrimitive<C>> for W<F>
source§impl From<W<ScalarCore>> for ScalarPrimitive<StarkCurve>
impl From<W<ScalarCore>> for ScalarPrimitive<StarkCurve>
source§impl<F: PrimeField> FromUintUnchecked for W<F>
impl<F: PrimeField> FromUintUnchecked for W<F>
source§impl<'r, F: MulAssign<&'r F>> MulAssign<&'r W<F>> for W<F>
impl<'r, F: MulAssign<&'r F>> MulAssign<&'r W<F>> for W<F>
source§fn mul_assign(&mut self, rhs: &'r W<F>)
fn mul_assign(&mut self, rhs: &'r W<F>)
*= operation. Read moresource§impl<F: MulAssign> MulAssign for W<F>
impl<F: MulAssign> MulAssign for W<F>
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*= operation. Read moresource§impl<F: Ord> Ord for W<F>
impl<F: Ord> Ord for W<F>
source§impl<F: PartialEq> PartialEq for W<F>
impl<F: PartialEq> PartialEq for W<F>
source§impl<F: PartialOrd> PartialOrd for W<F>
impl<F: PartialOrd> PartialOrd for W<F>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl<F> PrimeField for W<F>
impl<F> PrimeField for W<F>
§type Repr = GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>
type Repr = GenericArray<u8, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>>
source§const MODULUS: &'static str = F::MODULUS
const MODULUS: &'static str = F::MODULUS
source§const NUM_BITS: u32 = F::NUM_BITS
const NUM_BITS: u32 = F::NUM_BITS
source§const CAPACITY: u32 = F::CAPACITY
const CAPACITY: u32 = F::CAPACITY
source§const MULTIPLICATIVE_GENERATOR: Self = _
const MULTIPLICATIVE_GENERATOR: Self = _
modulus - 1 order. This element must also be
a quadratic nonresidue. Read moresource§const ROOT_OF_UNITY: Self = _
const ROOT_OF_UNITY: Self = _
2^s root of unity. Read moresource§const ROOT_OF_UNITY_INV: Self = _
const ROOT_OF_UNITY_INV: Self = _
Self::ROOT_OF_UNITY.source§fn from_repr(repr: Self::Repr) -> CtOption<Self>
fn from_repr(repr: Self::Repr) -> CtOption<Self>
source§fn to_repr(&self) -> Self::Repr
fn to_repr(&self) -> Self::Repr
source§fn from_str_vartime(s: &str) -> Option<Self>
fn from_str_vartime(s: &str) -> Option<Self>
source§impl<F: ShlAssign<usize>> ShlAssign<usize> for W<F>
impl<F: ShlAssign<usize>> ShlAssign<usize> for W<F>
source§fn shl_assign(&mut self, rhs: usize)
fn shl_assign(&mut self, rhs: usize)
<<= operation. Read moresource§impl<F> ShrAssign<usize> for W<F>
impl<F> ShrAssign<usize> for W<F>
source§fn shr_assign(&mut self, rhs: usize)
fn shr_assign(&mut self, rhs: usize)
>>= operation. Read moresource§impl<'r, F: SubAssign<&'r F>> SubAssign<&'r W<F>> for W<F>
impl<'r, F: SubAssign<&'r F>> SubAssign<&'r W<F>> for W<F>
source§fn sub_assign(&mut self, rhs: &'r W<F>)
fn sub_assign(&mut self, rhs: &'r W<F>)
-= operation. Read moresource§impl<F: SubAssign> SubAssign for W<F>
impl<F: SubAssign> SubAssign for W<F>
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-= operation. Read more