Skip to content

Initializer

init(seedRepresentation:publicKey:)

Creates an MLDSA.PrivateKey instance using the seed it is derived from.
init(seedRepresentation: some DataProtocol, publicKey: KeyType.PrivateKey.PublicKey? = nil) throws

Parameters

seedRepresentation

The 32-byte seed the private key is derived from.

publicKey

An optional public key to check the derived key against. When provided, a consistency check is performed between it and the public key derived from the seed.

Discussion

MLDSA private keys are stored and transmitted as the 32-byte seed they are derived from, rather than as the expanded key itself. The key is derived from the seed following the ML-DSA.KeyGen_internal algorithm of FIPS 204.

Throws

If the seed isn’t valid for the key’s parameter set, or if the provided public key doesn’t match the one derived from the seed.