mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-07 23:10:32 +00:00
core: use Neo.Crypto.CheckSig for standard signature verification
This commit is contained in:
parent
4e6c1092b8
commit
cdaca7be3e
49 changed files with 404 additions and 322 deletions
|
@ -16,11 +16,10 @@ import (
|
|||
func TestVerifyGood(t *testing.T) {
|
||||
msg := []byte("test message")
|
||||
pub, sig := signMessage(t, msg)
|
||||
src := getVerifyProg(pub, sig, msg)
|
||||
src := getVerifyProg(pub, sig)
|
||||
|
||||
v, p := vmAndCompileInterop(t, src)
|
||||
p.interops[interopnames.ToID([]byte(interopnames.NeoCryptoVerifyWithECDsaSecp256r1))] = func(v *vm.VM) error {
|
||||
assert.Equal(t, msg, v.Estack().Pop().Bytes())
|
||||
p.interops[interopnames.ToID([]byte(interopnames.NeoCryptoCheckSig))] = func(v *vm.VM) error {
|
||||
assert.Equal(t, pub, v.Estack().Pop().Bytes())
|
||||
assert.Equal(t, sig, v.Estack().Pop().Bytes())
|
||||
v.Estack().PushVal(true)
|
||||
|
@ -40,10 +39,9 @@ func signMessage(t *testing.T, msg []byte) ([]byte, []byte) {
|
|||
return pub, sig
|
||||
}
|
||||
|
||||
func getVerifyProg(pub, sig, msg []byte) string {
|
||||
func getVerifyProg(pub, sig []byte) string {
|
||||
pubS := fmt.Sprintf("%#v", pub)
|
||||
sigS := fmt.Sprintf("%#v", sig)
|
||||
msgS := fmt.Sprintf("%#v", msg)
|
||||
|
||||
return `
|
||||
package hello
|
||||
|
@ -53,8 +51,7 @@ func getVerifyProg(pub, sig, msg []byte) string {
|
|||
func Main() bool {
|
||||
pub := ` + pubS + `
|
||||
sig := ` + sigS + `
|
||||
msg := ` + msgS + `
|
||||
return crypto.ECDsaSecp256r1Verify(msg, pub, sig)
|
||||
return crypto.CheckSig(pub, sig)
|
||||
}
|
||||
`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue