Skip to content

Commit a842210

Browse files
committed
btcec/schnorr: fix signing and verifying to match BIP340 and libsecp256k1
behavior Sign, and Verify: accept variable length messages, as required by BIP340 and implemented by libsecp256k1 Sign: don't use RFC6979 when auxRand bytes are not passed by the caller, instead, match BIP340 spec and libsecp256k1 implementation by making not passing CustomNonce equivalent to passing a zeroed 32 byte array. Deprecated CustomNonce functional option, replaced by AuxRand due to misleading name.
1 parent 1966c38 commit a842210

3 files changed

Lines changed: 183 additions & 186 deletions

File tree

btcec/schnorr/bench_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,17 @@ func BenchmarkSign(b *testing.B) {
136136
b.ResetTimer()
137137
for i := 0; i < b.N; i++ {
138138
sig, err = Sign(
139-
privKey, msgHash, CustomNonce(auxBytes), FastSign(),
139+
privKey, msgHash, AuxRand(auxBytes), FastSign(),
140140
)
141141
}
142142

143143
testSig = sig
144144
testErr = err
145145
}
146146

147-
// BenchmarkSignRfc6979 benchmarks how long it takes to sign a message.
148-
func BenchmarkSignRfc6979(b *testing.B) {
147+
// BenchmarkSignDefault benchmarks how long it takes to sign a message when
148+
// AuxRand is not passed in
149+
func BenchmarkSignDefault(b *testing.B) {
149150
// Randomly generated keypair.
150151
d := hexToModNScalar("9e0699c91ca1e3b7e3c9ba71eb71c89890872be97576010fe593fbf3fd57e66d")
151152
privKey := secp256k1.NewPrivateKey(d)

0 commit comments

Comments
 (0)