Skip to main content

GroupDigest

Trait GroupDigest 

Source
pub trait GroupDigest: MapToCurve {
    type ExpandMsg: ExpandMsg<Self::SecurityLevel>;

    const HASH_TO_CURVE_ID: &[u8];
    const ENCODE_TO_CURVE_ID: &[u8];

    // Provided methods
    fn hash_from_bytes(
        msg: &[&[u8]],
        dst: &[&[u8]],
    ) -> Result<ProjectivePoint<Self>, <Self::ExpandMsg as ExpandMsg<Self::SecurityLevel>>::Error> { ... }
    fn encode_from_bytes(
        msg: &[&[u8]],
        dst: &[&[u8]],
    ) -> Result<ProjectivePoint<Self>, <Self::ExpandMsg as ExpandMsg<Self::SecurityLevel>>::Error> { ... }
}
Expand description

Hash arbitrary byte sequences to a valid group element.

Required Associated Constants§

Required Associated Types§

Source

type ExpandMsg: ExpandMsg<Self::SecurityLevel>

The expand_message function to use.

Provided Methods§

Source

fn hash_from_bytes( msg: &[&[u8]], dst: &[&[u8]], ) -> Result<ProjectivePoint<Self>, <Self::ExpandMsg as ExpandMsg<Self::SecurityLevel>>::Error>

Computes the hash to curve routine, with message equal to the concatenation of the elements in msg, and domain separator equal to the concatenation of the elements in dst.

From https://www.rfc-editor.org/rfc/rfc9380.html:

Uniform encoding from byte strings to points in G. That is, the distribution of its output is statistically close to uniform in G. This function is suitable for most applications requiring a random oracle returning points in G assuming a cryptographically secure hash function is used.

§Errors

When the chosen ExpandMsg implementation returns an error. See ExpandMsgXmdError and ExpandMsgXofError for examples.

Source

fn encode_from_bytes( msg: &[&[u8]], dst: &[&[u8]], ) -> Result<ProjectivePoint<Self>, <Self::ExpandMsg as ExpandMsg<Self::SecurityLevel>>::Error>

Computes the encode to curve routine, with message equal to the concatenation of the elements in msg, and domain separator equal to the concatenation of the elements in dst.

From https://www.rfc-editor.org/rfc/rfc9380.html:

Nonuniform encoding from byte strings to points in G. That is, the distribution of its output is not uniformly random in G: the set of possible outputs of encode_to_curve is only a fraction of the points in G, and some points in this set are more likely to be output than others.

§Errors

When the chosen ExpandMsg implementation returns an error. See ExpandMsgXmdError and ExpandMsgXofError for examples.

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§