Skip to content

Commit

Permalink
musig2: fix early nonce gen option
Browse files Browse the repository at this point in the history
Previously the early nonce generation option was not being respected
when creating the context, with the WithKnownSigners option being
used. This commit fixes that.
  • Loading branch information
sputn1ck committed Jul 11, 2023
1 parent f5eeb10 commit 8f84bb0
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions btcec/schnorr/musig2/context.go
Expand Up @@ -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
}

Expand Down

0 comments on commit 8f84bb0

Please sign in to comment.