pub trait MLDSAPrivateKeyTrait<const k: usize, const l: usize, const S1_PACKED_LEN: usize, const S2_PACKED_LEN: usize, const T1_PACKED_LEN: usize, const PK_LEN: usize, const SK_LEN: usize, const FULL_SK_LEN: usize>: SignaturePrivateKey<SK_LEN> {
// Required methods
fn from_keymaterial(seed: &KeyMaterial<32>) -> Result<Self, SignatureError>;
fn seed(&self) -> Option<&KeyMaterial<32>>;
fn tr(&self) -> [u8; 64];
fn derive_pk(&self) -> MLDSAPublicKey<k, T1_PACKED_LEN, PK_LEN>;
fn encode_full_sk(&self) -> [u8; FULL_SK_LEN];
fn encode_full_sk_out(&self, out: &mut [u8; FULL_SK_LEN]) -> usize;
fn sk_decode(sk: &[u8; SK_LEN]) -> Self;
}Expand description
General trait for all ML-DSA private keys types.
Required MethodsΒ§
Sourcefn from_keymaterial(seed: &KeyMaterial<32>) -> Result<Self, SignatureError>
fn from_keymaterial(seed: &KeyMaterial<32>) -> Result<Self, SignatureError>
New from KeyMaterial. Can throw a SignatureError if the KeyMaterial does not contain sufficient entropy.
Sourcefn seed(&self) -> Option<&KeyMaterial<32>>
fn seed(&self) -> Option<&KeyMaterial<32>>
Get a ref to the seed, if there is one stored with this private key
Sourcefn tr(&self) -> [u8; 64]
fn tr(&self) -> [u8; 64]
Get a copy of the key hash tr.
This is computationally intensive as it requires fully re-computing the public key (and then discarding it).
It is highly recommended that, if the user already has a copy of the public key, they should get tr from that,
or else compute tr once and store it.
Sourcefn derive_pk(&self) -> MLDSAPublicKey<k, T1_PACKED_LEN, PK_LEN>
fn derive_pk(&self) -> MLDSAPublicKey<k, T1_PACKED_LEN, PK_LEN>
Returns the full public key, and has the side-effect of setting the public key hash tr in this MLDSASeedSK object.
Sourcefn encode_full_sk(&self) -> [u8; FULL_SK_LEN]
fn encode_full_sk(&self) -> [u8; FULL_SK_LEN]
This produces the full private key in the encoding specified in FIPS 204 Algorithm 24 skEncode() so that it is compatible with other implementations.
Note that since this encoding does not include the seed, this is a one-way operation;
after exporting in this encoding, it will be impossible to re-import it into a MLDSASeedPrivateKey.
Sourcefn encode_full_sk_out(&self, out: &mut [u8; FULL_SK_LEN]) -> usize
fn encode_full_sk_out(&self, out: &mut [u8; FULL_SK_LEN]) -> usize
This produces the full private key in the encoding specified in FIPS 204 Algorithm 24 skEncode() so that it is compatible with other implementations.
Note that since this encoding does not include the seed, this is a one-way operation;
after exporting in this encoding, it will be impossible to re-import it into a MLDSASeedPrivateKey.
Sourcefn sk_decode(sk: &[u8; SK_LEN]) -> Self
fn sk_decode(sk: &[u8; SK_LEN]) -> Self
Algorithm 25 skDecode(π π) Reverses the procedure skEncode. Input: Private key π π β πΉ32+32+64+32β ((β+π)β bitlen (2π)+ππ). Output: π β πΉ32, πΎ β πΉ32, π‘π β πΉ64 , π¬1 β π β , π¬2 β π π , π0 β π π with coefficients in [β2πβ1 + 1, 2πβ1].
Note: this object contains only the simple decoding routine to unpack a semi-expanded key.
See MLDSATrait for key generation functions, including derive-from-seed and consistency-check functions.
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.