mirror of
https://github.com/btcsuite/btcd.git
synced 2024-11-19 18:00:11 +01:00
schnorr: simplify some signing math
We reuse the Bytes() function rather than duplicating its logic.
This commit is contained in:
parent
6ea604df63
commit
a4236c5010
@ -302,13 +302,9 @@ func schnorrSign(privKey, nonce *btcec.ModNScalar, pubKey *btcec.PublicKey, hash
|
||||
// Step 12.
|
||||
//
|
||||
// e = tagged_hash("BIP0340/challenge", bytes(R) || bytes(P) || m) mod n
|
||||
var rBytes [32]byte
|
||||
r := &R.X
|
||||
r.PutBytesUnchecked(rBytes[:])
|
||||
pBytes := SerializePubKey(pubKey)
|
||||
|
||||
commitment := chainhash.TaggedHash(
|
||||
chainhash.TagBIP0340Challenge, rBytes[:], pBytes, hash,
|
||||
chainhash.TagBIP0340Challenge, R.X.Bytes()[:], pBytes, hash,
|
||||
)
|
||||
|
||||
var e btcec.ModNScalar
|
||||
@ -324,7 +320,7 @@ func schnorrSign(privKey, nonce *btcec.ModNScalar, pubKey *btcec.PublicKey, hash
|
||||
s := new(btcec.ModNScalar).Mul2(&e, privKey).Add(&k)
|
||||
k.Zero()
|
||||
|
||||
sig := NewSignature(r, s)
|
||||
sig := NewSignature(&R.X, s)
|
||||
|
||||
// Step 14.
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user