Type Method
generate(sessionSecretRand:secretKey:publicKey:msg32:extraInput32:)
Generates a fresh nonce pair for one MuSig2 signing session using a caller-supplied P256K.MuSig.SessionSecretRand.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
static func generate(sessionSecretRand: consuming P256K.MuSig.SessionSecretRand, secretKey: P256K.Schnorr.PrivateKey?, publicKey: P256K.Schnorr.PublicKey, msg32: [UInt8]?, extraInput32: [UInt8]?) throws -> P256K.MuSig.NonceResult
Parameters
-
sessionSecretRand
-
Secret, uniformly random session input consumed by this call — see P256K.MuSig.SessionSecretRand.
-
secretKey
-
The signer’s private key; providing it increases misuse-resistance.
-
publicKey
-
The signer’s public key; the secret nonce is bound to this key.
-
msg32
-
The 32-byte message to sign; nil if not yet known. Providing it binds the nonce to the message, increasing misuse-resistance.
-
extraInput32
-
Optional 32 bytes of additional entropy passed to secp256k1_musig_nonce_gen.
Return Value
A ~Copyable P256K.MuSig.NonceResult with the public nonce (to share) and secret nonce (to consume).
Discussion
Warning
Nonce reuse leaks the secret signing key. Each P256K.MuSig.SessionSecretRand must be used for exactly one call — the value is consumed, so reuse is prevented at compile time by the type’s ~Copyable conformance rather than relying on the caller to discard the bytes. secp256k1_musig_nonce_gen additionally zeroes the value’s own SecureBytes buffer in place on success. Never store or serialize the secret nonce. The returned P256K.MuSig.NonceResult is ~Copyable.
Throws
secp256k1Error.incorrectParameterSize if msg32 or extraInput32 is present but not exactly 32 bytes; secp256k1Error.underlyingCryptoError if secp256k1_musig_nonce_gen fails.