[][src]Struct hash2curve::DomainSeparationTag

pub struct DomainSeparationTag { /* fields omitted */ }

Represents a domain separation tag suitable for use in hash_to_curve or encode_to_curve functions as describe in section 3.1 in https://datatracker.ietf.org/doc/draft-irtf-cfrg-hash-to-curve/?include_text=1

As an example, consider a fictional protocol named Quux that defines several different ciphersuites. A reasonable choice of tag is "QUUX- V-CS", where and are two-digit numbers indicating the version and ciphersuite, respectively.

As another example, consider a fictional protocol named Baz that requires two independent random oracles, where one oracle outputs points on the curve E1 and the other outputs points on the curve E2. Reasonable choices of tags for the E1 and E2 oracles are "BAZ-V- CS-E1" and "BAZ-V-CS-E2", respectively, where and are as described above.

use hash2curve::DomainSeparationTag;

let dst = DomainSeparationTag::new(b"MySuperAwesomeProtocol", None, None, None);

assert!(dst.is_ok());

let dst = DomainSeparationTag::new(b"", None, None, None);

assert!(dst.is_err());

Methods

impl DomainSeparationTag[src]

pub fn new(
    protocol_id: &[u8],
    protocol_version: Option<&[u8]>,
    ciphersuite_id: Option<&[u8]>,
    encoding_id: Option<&[u8]>
) -> Result<Self, HashingError>
[src]

Convenience function for creating a domain separation tag

pub fn to_bytes(&self) -> Vec<u8>[src]

Convert the tag to bytes. All fields cannot be longer than 255 bytes in length If a domain separation tag longer than 255 bytes must be used (e.g., because of requirements imposed by an invoking protocol), this computes the H("H2C-OVERSIZE-DST-" || protocol_id || procotol_version || ciphersuite_id || encoding_id) D must be a cryptographically secure hash function like SHA256, SHA3-256, or BLAKE2.

Trait Implementations

impl Clone for DomainSeparationTag[src]

impl Debug for DomainSeparationTag[src]

impl Eq for DomainSeparationTag[src]

impl From<DomainSeparationTag> for Bls12381G1Sswu[src]

impl PartialEq<DomainSeparationTag> for DomainSeparationTag[src]

impl StructuralEq for DomainSeparationTag[src]

impl StructuralPartialEq for DomainSeparationTag[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.