File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1214,7 +1214,10 @@ func (s *loopInSwap) setState(state loopdb.SwapState) {
12141214}
12151215
12161216// sharedSecretFromHash derives the shared secret from the swap hash using the
1217- // swap.KeyFamily family and zero as index.
1217+ // swap.KeyFamily family and zero as index. The swap hash is first interpreted
1218+ // with btcec.PrivKeyFromBytes semantics, so the derived ephemeral pubkey uses
1219+ // the same modulo-N normalization as the internal-key code paths that consume
1220+ // the resulting shared secret.
12181221func sharedSecretFromHash (ctx context.Context , signer lndclient.SignerClient ,
12191222 hash lntypes.Hash ) ([32 ]byte , error ) {
12201223
Original file line number Diff line number Diff line change @@ -10,15 +10,19 @@ import (
1010)
1111
1212// MuSig2Sign will create a MuSig2 signature for the passed message using the
13- // passed raw private keys. It expects at least two signing keys.
13+ // passed raw private keys. Raw keys are interpreted with
14+ // btcec.PrivKeyFromBytes semantics, which normalize 32-byte inputs modulo the
15+ // secp256k1 group order instead of rejecting out-of-range values. It expects
16+ // at least two signing keys.
1417func MuSig2Sign (version input.MuSig2Version , keys [][32 ]byte ,
1518 tweaks * input.MuSig2Tweaks , msg [32 ]byte ) ([]byte , error ) {
1619
1720 privKeys := make ([]* btcec.PrivateKey , len (keys ))
1821 pubKeys := make ([]* btcec.PublicKey , len (keys ))
1922
2023 // First parse the raw private keys and also create the corresponding
21- // public keys.
24+ // public keys. This preserves the same normalization semantics used
25+ // when these raw keys are turned into pubkeys elsewhere in the protocol.
2226 for i , key := range keys {
2327 privKeys [i ], pubKeys [i ] = btcec .PrivKeyFromBytes (key [:])
2428
You can’t perform that action at this time.
0 commit comments