pub trait Ciphersuite: 'static + Send + Sync + Clone + Copy + PartialEq + Eq + Debug + Zeroize {
    type F: PrimeField + PrimeFieldBits + Zeroize;
    type G: Group<Scalar = Self::F> + GroupOps + PrimeGroup + Zeroize + ConstantTimeEq;
    type H: Send + Clone + BlockSizeUser + Digest + HashMarker + SecureDigest;

    const ID: &'static [u8];

    // Required methods
    fn generator() -> Self::G;
    fn hash_to_F(dst: &[u8], msg: &[u8]) -> Self::F;

    // Provided methods
    fn random_nonzero_F<R: RngCore + CryptoRng>(rng: &mut R) -> Self::F { ... }
    fn read_F<R: Read>(reader: &mut R) -> Result<Self::F> { ... }
    fn read_G<R: Read>(reader: &mut R) -> Result<Self::G> { ... }
}
Expand description

Unified trait defining a ciphersuite around an elliptic curve.

Required Associated Types§

source

type F: PrimeField + PrimeFieldBits + Zeroize

Scalar field element type.

source

type G: Group<Scalar = Self::F> + GroupOps + PrimeGroup + Zeroize + ConstantTimeEq

Group element type.

source

type H: Send + Clone + BlockSizeUser + Digest + HashMarker + SecureDigest

Hash algorithm used with this curve.

Required Associated Constants§

source

const ID: &'static [u8]

ID for this curve.

Required Methods§

source

fn generator() -> Self::G

Generator for the group.

source

fn hash_to_F(dst: &[u8], msg: &[u8]) -> Self::F

Hash the provided domain-separation tag and message to a scalar. Ciphersuites MAY naively prefix the tag to the message, enabling transpotion between the two. Accordingly, this function should NOT be used in any scheme where one tag is a valid substring of another UNLESS the specific Ciphersuite is verified to handle the DST securely.

Verifying specific ciphersuites have secure tag handling is not recommended, due to it breaking the intended modularity of ciphersuites. Instead, component-specific tags with further purpose tags are recommended (“Schnorr-nonce”, “Schnorr-chal”).

Provided Methods§

source

fn random_nonzero_F<R: RngCore + CryptoRng>(rng: &mut R) -> Self::F

Generate a random non-zero scalar.

source

fn read_F<R: Read>(reader: &mut R) -> Result<Self::F>

Available on crate features alloc or std only.

Read a canonical scalar from something implementing std::io::Read.

source

fn read_G<R: Read>(reader: &mut R) -> Result<Self::G>

Available on crate features alloc or std only.

Read a canonical point from something implementing std::io::Read.

Implementors§

source§

impl Ciphersuite for Ed448

Available on crate feature ed448 only.
§

type F = Scalar

§

type G = Point

§

type H = Shake256_114

source§

const ID: &'static [u8] = b"ed448"

source§

impl Ciphersuite for Ed25519

Available on crate feature dalek only.
§

type F = Scalar

§

type G = EdwardsPoint

§

type H = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, OidSha512>>

source§

const ID: &'static [u8] = b"edwards25519"

source§

impl Ciphersuite for P256

Available on crate feature kp256 only.
§

type F = Scalar

§

type G = ProjectivePoint<NistP256>

§

type H = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>

source§

const ID: &'static [u8] = b"P-256"

source§

impl Ciphersuite for Ristretto

Available on crate feature dalek only.
§

type F = Scalar

§

type G = RistrettoPoint

§

type H = CoreWrapper<CtVariableCoreWrapper<Sha512VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, OidSha512>>

source§

const ID: &'static [u8] = b"ristretto"

source§

impl Ciphersuite for Secp256k1

Available on crate feature kp256 only.
§

type F = Scalar

§

type G = ProjectivePoint

§

type H = CoreWrapper<CtVariableCoreWrapper<Sha256VarCore, UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, OidSha256>>

source§

const ID: &'static [u8] = b"secp256k1"