Skip to content

You're viewing documentation for a pre-release version. View the latest stable version

Initializer

init(seedRepresentation:publicKey:)

iOS 26.0+ macOS 26.0+ tvOS 26.0+ watchOS 26.0+
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.