One Logo Pool Ball
CryptoKit · IOS API REFERENCE

MLDSA87.PrivateKey

struct · iOS 26.0+ · SDK 27.1

struct PrivateKey

The private key for MLDSA87.

Members (8)

get · iOS 26.0+

publicKey

TypeScript
get publicKey(): MLDSA87_PublicKey
Swift declaration
var publicKey: MLDSA87.PublicKey { get }

The associated public key.

init · iOS 26.0+

init

TypeScript
static initSeedRepresentationPublicKey(seedRepresentation: ArrayBuffer, publicKey?: (MLDSA87_PublicKey) | null): MLDSA87_PrivateKey
Swift declaration
init<D>(seedRepresentation: D, publicKey: MLDSA87.PublicKey?) throws where D : DataProtocol

Initializes a private key from the seed representation. - Parameter seedRepresentation: The seed representation of the private key. This parameter needs to be 32 bytes long. - Parameter publicKey: The public key associated with the secret key. This initializer implements the `ML-DSA.KeyGen_internal` algorithm (Algorithm 16) of FIPS 204. If a public key is provided, a consistency check is performed between it and the derived public key.

get · iOS 26.0+

seedRepresentation

TypeScript
get seedRepresentation(): ArrayBuffer
Swift declaration
var seedRepresentation: Data { get }

The seed representation of the private key. The seed representation is 32 bytes long, and is the parameter for the `ML-DSA.KeyGen_internal` algorithm (Algorithm 16) of FIPS 204.

get · iOS 26.0+

integrityCheckedRepresentation

TypeScript
get integrityCheckedRepresentation(): ArrayBuffer
Swift declaration
var integrityCheckedRepresentation: Data { get }

The integrity-checked data representation of the private key. This representation is 64 bytes long, and contains the seed and a hash of the public key.

init · iOS 26.0+

init

TypeScript
static initIntegrityCheckedRepresentation(integrityCheckedRepresentation: ArrayBuffer): MLDSA87_PrivateKey
Swift declaration
init<D>(integrityCheckedRepresentation: D) throws where D : DataProtocol

Initializes a private key from an integrity-checked data representation. - Parameter integrityCheckedRepresentation: The integrity-checked data representation of the private key. The parameter needs to be 64 bytes long, and contain the seed and a hash of the public key.

method · iOS 26.0+

signature

TypeScript
signatureFor(data: ArrayBuffer): ArrayBuffer
Swift declaration
func signature<D>(for data: D) throws -> Data where D : DataProtocol

Generates a MLDSA87 signature. - Parameters: - data: The data to sign. - Returns: The MLDSA87 signature. This method throws if CryptoKit encounters an error producing the signature.

method · iOS 26.0+

signature

TypeScript
signatureForContext(data: ArrayBuffer, context: ArrayBuffer): ArrayBuffer
Swift declaration
func signature<D, C>(for data: D, context: C) throws -> Data where D : DataProtocol, C : DataProtocol

Generates a MLDSA87 signature, with context. - Parameters: - data: The data to sign. - context: Context for the signature. - Returns: The MLDSA87 signature. This method throws if CryptoKit encounters an error producing the signature.

init · iOS 26.0+

init

TypeScript
static init(): MLDSA87_PrivateKey
Swift declaration
init() throws

Creates a random MLDSA87 private key. This initializer is marked `throws` to support use in generic contexts, but key generation itself doesn't produce errors. When you call this initializer directly on a concrete type, rather than through a generic type parameter, you can safely call `try!` to create the key: ```swift let privateKey = try! MLDSA87.PrivateKey() ```

Skipped declarations

No declarations were skipped in this snapshot.

All CryptoKit types →