musig2: fix early nonce gen option

Previously the early nonce generation option was not being respected
when creating the context, with the WithKnownSigners option being
used. This commit fixes that.
This commit is contained in:
sputn1ck 2023-07-10 16:40:26 +02:00
parent f5eeb10d03
commit 8f84bb0e9b
No known key found for this signature in database
GPG key ID: 671103D881A5F0E4

View file

@ -234,24 +234,23 @@ func NewContext(signingKey *btcec.PrivateKey, shouldSort bool,
opts.keySet = make([]*btcec.PublicKey, 0, opts.numSigners)
opts.keySet = append(opts.keySet, pubKey)
// If early nonce generation is specified, then we'll generate
// the nonce now to pass in to the session once all the callers
// are known.
if opts.earlyNonce {
var err error
ctx.sessionNonce, err = GenNonces(
WithPublicKey(ctx.pubKey),
WithNonceSecretKeyAux(signingKey),
)
if err != nil {
return nil, err
}
}
default:
return nil, ErrSignersNotSpecified
}
// If early nonce generation is specified, then we'll generate the
// nonce now to pass in to the session once all the callers are known.
if opts.earlyNonce {
var err error
ctx.sessionNonce, err = GenNonces(
WithPublicKey(ctx.pubKey),
WithNonceSecretKeyAux(signingKey),
)
if err != nil {
return nil, err
}
}
return ctx, nil
}