<PackageReference Include="BouncyCastle.Cryptography" Version="2.7.0" />

Org.BouncyCastle.Crypto.Parameters.MLDsaPrivateKeyParameters

ML-DSA private key (FIPS 204). The expanded key holds (ρ, K, tr, s₁, s₂, t₀) derived from a 32-byte seed; the corresponding t₁ half of the public key is cached for fast public-key recovery. A key built from a seed retains the seed so it can be re-encoded in the seed format.
public enum Format

Storage format selector for serialised private keys. Per RFC 9881 §8.1 the seed form is preferred for storage efficiency.

public static readonly Format DefaultFormat

Default Format applied when a key is constructed from a seed.

public Format PreferredFormat { get; }

The serialisation format this key was last asked to prefer.

public static MLDsaPrivateKeyParameters FromEncoding(MLDsaParameters parameters, byte[] encoding)

Decode a private key from its expanded byte representation. The expected length is the parameter set's PrivateKeyLength; the returned key has EncodingOnly as its preferred format because the seed is not recoverable from the encoding.

public static MLDsaPrivateKeyParameters FromSeed(MLDsaParameters parameters, byte[] seed)

Expand a 32-byte seed into a private key, defaulting to DefaultFormat ( SeedOnly).

public static MLDsaPrivateKeyParameters FromSeed(MLDsaParameters parameters, byte[] seed, Format preferredFormat)

Expand a 32-byte seed into a private key with the supplied preferredFormat.

public byte[] GetEncoded()

Return a fresh copy of the expanded ρ || K || tr || s₁ || s₂ || t₀ encoding.

Return the public key derived during key expansion.

public byte[] GetPublicKeyEncoded()

Return a fresh copy of the public key encoding (ρ || t₁).

public byte[] GetSeed()

Return a fresh copy of the 32-byte seed if one was retained at construction; null for keys imported via FromEncoding.

Return a key equivalent to this one but with PreferredFormat changed to preferredFormat. Returns the receiver when the format is unchanged.