Type Method
generate(sessionID:secretKey:publicKey:msg32:extraInput32:)
Generates a fresh nonce pair for one MuSig2 signing session using a caller-supplied session ID.
- iOS 13.0+
- macCatalyst 13.0+
- macOS 10.15+
- tvOS 13.0+
- visionOS 1.0+
- watchOS 6.0+
static func generate(sessionID: [UInt8], secretKey: P256K.Schnorr.PrivateKey?, publicKey: P256K.Schnorr.PublicKey, msg32: [UInt8], extraInput32: [UInt8]?) throws -> P256K.MuSig.NonceResult
Parameters
-
sessionID
-
Uniformly random bytes used as session_secrand32; must never repeat. Invalidated after the call.
-
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, if known at nonce generation time.
-
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. The sessionID must be unique across all calls to this function — it is consumed (zeroed) by secp256k1_musig_nonce_gen to prevent reuse at the C level. Never store or serialize the secret nonce. The returned P256K.MuSig.NonceResult is ~Copyable.
Throws
secp256k1Error.underlyingCryptoError if secp256k1_musig_nonce_gen fails.