Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schnorr: Remove generalized Verify. #2123

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions dcrec/secp256k1/schnorr/ecdsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,3 @@ func schnorrVerify(sig []byte,

return true, nil
}

// Verify is the generalized and exported function for the verification of a
// secp256k1 Schnorr signature. BLAKE256 is used as the hashing function.
func Verify(pubkey *secp256k1.PublicKey,
msg []byte, r *big.Int, s *big.Int) bool {
sig := NewSignature(r, s)
ok, _ := schnorrVerify(sig.Serialize(), pubkey, msg,
chainhash.HashB)

return ok
}
14 changes: 6 additions & 8 deletions dcrec/secp256k1/schnorr/ecdsa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func TestSignatures(t *testing.T) {
t.Fatalf("expected an error, got %v", err)
}

ok := Verify(pubkey, tv.msg, sig.R, sig.S)
ok := sig.Verify(tv.msg, pubkey)
if !ok {
t.Fatalf("expected %v, got %v", true, ok)
}
Expand Down Expand Up @@ -325,13 +325,11 @@ func benchmarkVerification(b *testing.B) {
sigList := randSigList(numSigs)

for n := 0; n < b.N; n++ {
randIndex := r.Intn(numSigs - 1)
ver := Verify(sigList[randIndex].pubkey,
sigList[randIndex].msg,
sigList[randIndex].sig.R,
sigList[randIndex].sig.S)
if !ver {
panic("made invalid sig")
sigEntry := sigList[r.Intn(numSigs-1)]
sig := sigEntry.sig
verified := sig.Verify(sigEntry.msg, sigEntry.pubkey)
if !verified {
b.Fatalf("made invalid sig -- %x", sig.Serialize())
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions dcrec/secp256k1/schnorr/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ func (sig Signature) IsEqual(otherSig *Signature) bool {
// Verify is the generalized and exported function for the verification of a
// secp256k1 Schnorr signature. BLAKE256 is used as the hashing function.
func (sig Signature) Verify(msg []byte, pubkey *secp256k1.PublicKey) bool {
ok, _ := schnorrVerify(sig.Serialize(), pubkey, msg,
chainhash.HashB)

ok, _ := schnorrVerify(sig.Serialize(), pubkey, msg, chainhash.HashB)
return ok
}
2 changes: 1 addition & 1 deletion txscript/opcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -2886,7 +2886,7 @@ func opcodeCheckSigAlt(op *opcode, data []byte, vm *Engine) error {
vm.dstack.PushBool(false)
return nil
}
ok := schnorr.Verify(pubKeySec, hash, sigSec.R, sigSec.S)
ok := sigSec.Verify(hash, pubKeySec)
vm.dstack.PushBool(ok)
return nil
}
Expand Down