Trait frost_core::Field
source · pub trait Field: Copy + Clone {
type Scalar: Add<Output = Self::Scalar> + Copy + Clone + Eq + Mul<Output = Self::Scalar> + PartialEq + Sub<Output = Self::Scalar>;
type Serialization: AsRef<[u8]> + Debug + TryFrom<Vec<u8>>;
// Required methods
fn zero() -> Self::Scalar;
fn one() -> Self::Scalar;
fn invert(scalar: &Self::Scalar) -> Result<Self::Scalar, FieldError>;
fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self::Scalar;
fn serialize(scalar: &Self::Scalar) -> Self::Serialization;
fn little_endian_serialize(scalar: &Self::Scalar) -> Self::Serialization;
fn deserialize(
buf: &Self::Serialization
) -> Result<Self::Scalar, FieldError>;
}
Expand description
A prime order finite field GF(q) over which all scalar values for our prime order group can be multiplied are defined.
This trait does not have to be implemented for a finite field scalar itself, it can be a pass-through, implemented for a type just for the ciphersuite, and calls through to another implementation underneath, so that this trait does not have to be implemented for types you don’t own.
Required Associated Types§
Required Methods§
sourcefn invert(scalar: &Self::Scalar) -> Result<Self::Scalar, FieldError>
fn invert(scalar: &Self::Scalar) -> Result<Self::Scalar, FieldError>
Computes the multiplicative inverse of an element of the scalar field, failing if the element is zero.
sourcefn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self::Scalar
fn random<R: RngCore + CryptoRng>(rng: &mut R) -> Self::Scalar
Generate a random scalar from the entire space [0, l-1]
https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-11.html#section-3.1-3.3
sourcefn serialize(scalar: &Self::Scalar) -> Self::Serialization
fn serialize(scalar: &Self::Scalar) -> Self::Serialization
A member function of a Field
that maps a Scalar
to a unique byte array buf of
fixed length Ne.
https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-11.html#section-3.1-3.8
sourcefn little_endian_serialize(scalar: &Self::Scalar) -> Self::Serialization
fn little_endian_serialize(scalar: &Self::Scalar) -> Self::Serialization
sourcefn deserialize(buf: &Self::Serialization) -> Result<Self::Scalar, FieldError>
fn deserialize(buf: &Self::Serialization) -> Result<Self::Scalar, FieldError>
A member function of a Field
that attempts to map a byte array buf
to a Scalar
.
Fails if the input is not a valid byte representation of an Scalar
of the
Field
. This function can raise an Error
if deserialization fails or if the
resulting Scalar
is zero
https://www.ietf.org/archive/id/draft-irtf-cfrg-frost-11.html#section-3.1-3.9