Instance Method
add(mldsa:kid:parser:serializer:)
MLDSAKey.@discardableResult func add(mldsa key: some MLDSAKey, kid: JWKIdentifier? = nil, parser: some JWTParser = DefaultJWTParser(), serializer: some JWTSerializer = DefaultJWTSerializer()) -> Self
Parameters
keyThe
MLDSAKeyused for MLDSA signing. Passing a private key allows both signing and verifying, while passing a public key only allows verifying.kidAn optional
JWKIdentifier(Key ID). Providing this identifier allows the JWTkidheader field to reference this specific signer.parserAn optional custom parser that conforms to
JWTParser. If not specified, aDefaultJWTParseris used for parsing JWTs.serializerAn optional custom serializer that conforms to
JWTSerializer. If not specified, aDefaultJWTSerializeris used for serializing JWTs.
Return Value
The same instance of the collection (Self), useful for chaining multiple configuration calls.
Discussion
This method incorporates an MLDSA (Module-Lattice-Based Digital Signature Algorithm) signer into the collection. MLDSA is a post-quantum signature scheme, whose use in JWTs is defined by RFC 9964.
Usage Example:
let privateKey = try MLDSA87PrivateKey(seedRepresentation: seed)
let collection = await JWTKeyCollection()
.add(mldsa: privateKey)