pub trait Group {
type Elem: ConstantTimeEq + Copy + Zeroize + for<'a> Add<&'a Self::Elem, Output = Self::Elem> + for<'a> Mul<&'a Self::Scalar, Output = Self::Elem>;
type ElemLen: ArrayLength<u8> + 'static;
type Scalar: ConstantTimeEq + Copy + Zeroize + for<'a> Add<&'a Self::Scalar, Output = Self::Scalar> + for<'a> Mul<&'a Self::Scalar, Output = Self::Scalar> + for<'a> Sub<&'a Self::Scalar, Output = Self::Scalar>;
type ScalarLen: ArrayLength<u8> + 'static;
// Required methods
fn hash_to_curve<H>(
input: &[&[u8]],
dst: &[&[u8]],
) -> Result<Self::Elem, InternalError>
where H: BlockSizeUser + Default + FixedOutput + HashMarker,
H::OutputSize: IsLess<U256> + IsLessOrEqual<H::BlockSize>;
fn hash_to_scalar<H>(
input: &[&[u8]],
dst: &[&[u8]],
) -> Result<Self::Scalar, InternalError>
where H: BlockSizeUser + Default + FixedOutput + HashMarker,
H::OutputSize: IsLess<U256> + IsLessOrEqual<H::BlockSize>;
fn base_elem() -> Self::Elem;
fn identity_elem() -> Self::Elem;
fn serialize_elem(elem: Self::Elem) -> GenericArray<u8, Self::ElemLen>;
fn deserialize_elem(element_bits: &[u8]) -> Result<Self::Elem>;
fn random_scalar<R: RngCore + CryptoRng>(rng: &mut R) -> Self::Scalar;
fn invert_scalar(scalar: Self::Scalar) -> Self::Scalar;
fn is_zero_scalar(scalar: Self::Scalar) -> Choice;
fn serialize_scalar(
scalar: Self::Scalar,
) -> GenericArray<u8, Self::ScalarLen>;
fn deserialize_scalar(scalar_bits: &[u8]) -> Result<Self::Scalar>;
// Provided method
fn is_identity_elem(elem: Self::Elem) -> Choice { ... }
}Expand description
A prime-order subgroup of a base field (EC, prime-order field …). This subgroup is noted additively — as in the RFC — in this trait.
Required Associated Types§
Sourcetype Elem: ConstantTimeEq + Copy + Zeroize + for<'a> Add<&'a Self::Elem, Output = Self::Elem> + for<'a> Mul<&'a Self::Scalar, Output = Self::Elem>
type Elem: ConstantTimeEq + Copy + Zeroize + for<'a> Add<&'a Self::Elem, Output = Self::Elem> + for<'a> Mul<&'a Self::Scalar, Output = Self::Elem>
The type of group elements
Sourcetype ElemLen: ArrayLength<u8> + 'static
type ElemLen: ArrayLength<u8> + 'static
The byte length necessary to represent group elements
Sourcetype Scalar: ConstantTimeEq + Copy + Zeroize + for<'a> Add<&'a Self::Scalar, Output = Self::Scalar> + for<'a> Mul<&'a Self::Scalar, Output = Self::Scalar> + for<'a> Sub<&'a Self::Scalar, Output = Self::Scalar>
type Scalar: ConstantTimeEq + Copy + Zeroize + for<'a> Add<&'a Self::Scalar, Output = Self::Scalar> + for<'a> Mul<&'a Self::Scalar, Output = Self::Scalar> + for<'a> Sub<&'a Self::Scalar, Output = Self::Scalar>
The type of base field scalars
Sourcetype ScalarLen: ArrayLength<u8> + 'static
type ScalarLen: ArrayLength<u8> + 'static
The byte length necessary to represent scalars
Required Methods§
Sourcefn hash_to_curve<H>(
input: &[&[u8]],
dst: &[&[u8]],
) -> Result<Self::Elem, InternalError>where
H: BlockSizeUser + Default + FixedOutput + HashMarker,
H::OutputSize: IsLess<U256> + IsLessOrEqual<H::BlockSize>,
fn hash_to_curve<H>(
input: &[&[u8]],
dst: &[&[u8]],
) -> Result<Self::Elem, InternalError>where
H: BlockSizeUser + Default + FixedOutput + HashMarker,
H::OutputSize: IsLess<U256> + IsLessOrEqual<H::BlockSize>,
Transforms a password and domain separation tag (DST) into a curve point
§Errors
Error::Input if the input is empty or longer
then u16::MAX.
Sourcefn hash_to_scalar<H>(
input: &[&[u8]],
dst: &[&[u8]],
) -> Result<Self::Scalar, InternalError>where
H: BlockSizeUser + Default + FixedOutput + HashMarker,
H::OutputSize: IsLess<U256> + IsLessOrEqual<H::BlockSize>,
fn hash_to_scalar<H>(
input: &[&[u8]],
dst: &[&[u8]],
) -> Result<Self::Scalar, InternalError>where
H: BlockSizeUser + Default + FixedOutput + HashMarker,
H::OutputSize: IsLess<U256> + IsLessOrEqual<H::BlockSize>,
Hashes a slice of pseudo-random bytes to a scalar
§Errors
Error::Input if the input is empty or longer
then u16::MAX.
Sourcefn identity_elem() -> Self::Elem
fn identity_elem() -> Self::Elem
Returns the identity group element
Sourcefn serialize_elem(elem: Self::Elem) -> GenericArray<u8, Self::ElemLen>
fn serialize_elem(elem: Self::Elem) -> GenericArray<u8, Self::ElemLen>
Serializes the self group element
Sourcefn deserialize_elem(element_bits: &[u8]) -> Result<Self::Elem>
fn deserialize_elem(element_bits: &[u8]) -> Result<Self::Elem>
Return an element from its fixed-length bytes representation. If the element is the identity element, return an error.
§Errors
Error::Deserialization if the element
is not a valid point on the group or the identity element.
Sourcefn invert_scalar(scalar: Self::Scalar) -> Self::Scalar
fn invert_scalar(scalar: Self::Scalar) -> Self::Scalar
The multiplicative inverse of this scalar
Sourcefn is_zero_scalar(scalar: Self::Scalar) -> Choice
fn is_zero_scalar(scalar: Self::Scalar) -> Choice
Returns true if the scalar is zero.
Sourcefn serialize_scalar(scalar: Self::Scalar) -> GenericArray<u8, Self::ScalarLen>
fn serialize_scalar(scalar: Self::Scalar) -> GenericArray<u8, Self::ScalarLen>
Serializes a scalar to bytes
Sourcefn deserialize_scalar(scalar_bits: &[u8]) -> Result<Self::Scalar>
fn deserialize_scalar(scalar_bits: &[u8]) -> Result<Self::Scalar>
Return a scalar from its fixed-length bytes representation. If the scalar is zero or invalid, then return an error.
§Errors
Error::Deserialization if the scalar
is not a valid point on the group or zero.
Provided Methods§
Sourcefn is_identity_elem(elem: Self::Elem) -> Choice
fn is_identity_elem(elem: Self::Elem) -> Choice
Returns true if the element is equal to the identity element
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
Source§impl Group for Ristretto255
Available on crate feature ristretto255 only.
impl Group for Ristretto255
ristretto255 only.