Skip to main content

MLDSAPublicKeyTrait

Trait MLDSAPublicKeyTrait 

Source
pub trait MLDSAPublicKeyTrait<const k: usize, const PK_LEN: usize>: SignaturePublicKey {
    // Required methods
    fn pk_encode(&self) -> [u8; PK_LEN];
    fn pk_decode(pk: &[u8; PK_LEN]) -> Self;
    fn compute_tr(&self) -> [u8; 64];
}
Expand description

General trait for all ML-DSA public keys types.

Required MethodsΒ§

Source

fn pk_encode(&self) -> [u8; PK_LEN]

Algorithm 22 pkEncode(𝜌, 𝐭1) Encodes a public key for ML-DSA into a byte string. Input:𝜌 ∈ 𝔹32, 𝐭1 ∈ π‘…π‘˜ with coefficients in [0, 2bitlen (π‘žβˆ’1)βˆ’π‘‘ βˆ’ 1]. Output: Public key π‘π‘˜ ∈ 𝔹32+32π‘˜(bitlen (π‘žβˆ’1)βˆ’π‘‘).

Source

fn pk_decode(pk: &[u8; PK_LEN]) -> Self

Algorithm 23 pkDecode(π‘π‘˜) Reverses the procedure pkEncode. Input: Public key π‘π‘˜ ∈ 𝔹32+32π‘˜(bitlen (π‘žβˆ’1)βˆ’π‘‘). Output: 𝜌 ∈ 𝔹32, 𝐭1 ∈ π‘…π‘˜ with coefficients in [0, 2bitlen (π‘žβˆ’1)βˆ’π‘‘ βˆ’ 1].

Source

fn compute_tr(&self) -> [u8; 64]

Compute the public key hash (tr) from the public key.

This is exposed as a public API for a few reasons:

  1. tr is required for some external-prehashing schemes such as the so-called β€œexternal mu” signing mode.
  2. tr is the canonical fingerprint of an ML-DSA public key, so would be an appropriate value to use, for example, to build a public key lookup or deny-listing table.

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<const k: usize, const PK_LEN: usize> MLDSAPublicKeyTrait<k, PK_LEN> for MLDSAPublicKey<k, PK_LEN>