diff --git a/pkg/compiler/codegen.go b/pkg/compiler/codegen.go index 7f1b33eeb..34c3171ae 100644 --- a/pkg/compiler/codegen.go +++ b/pkg/compiler/codegen.go @@ -1063,10 +1063,6 @@ func (c *codegen) convertBuiltin(expr *ast.CallExpr) { emit.Opcode(c.prog.BinWriter, opcode.SHA256) case "SHA1": emit.Opcode(c.prog.BinWriter, opcode.SHA1) - case "Hash256": - emit.Opcode(c.prog.BinWriter, opcode.HASH256) - case "Hash160": - emit.Opcode(c.prog.BinWriter, opcode.HASH160) case "VerifySignature": emit.Opcode(c.prog.BinWriter, opcode.VERIFY) case "AppCall": diff --git a/pkg/compiler/util_test.go b/pkg/compiler/util_test.go index 90fc19c35..1f82c73f4 100644 --- a/pkg/compiler/util_test.go +++ b/pkg/compiler/util_test.go @@ -33,33 +33,3 @@ func TestSHA1(t *testing.T) { ` eval(t, src, []byte{0xfa, 0x13, 0x8a, 0xe3, 0x56, 0xd3, 0x5c, 0x8d, 0x77, 0x8, 0x3c, 0x40, 0x6a, 0x5b, 0xe7, 0x37, 0x45, 0x64, 0x3a, 0xae}) } - -func TestHash160(t *testing.T) { - src := ` - package foo - import ( - "github.com/nspcc-dev/neo-go/pkg/interop/crypto" - ) - func Main() []byte { - src := []byte{0x97} - hash := crypto.Hash160(src) - return hash - } - ` - eval(t, src, []byte{0x5f, 0xa4, 0x1c, 0x76, 0xf7, 0xe8, 0xca, 0x72, 0xb7, 0x18, 0xff, 0x59, 0x22, 0x91, 0xc2, 0x3a, 0x3a, 0xf5, 0x58, 0x6c}) -} - -func TestHash256(t *testing.T) { - src := ` - package foo - import ( - "github.com/nspcc-dev/neo-go/pkg/interop/crypto" - ) - func Main() []byte { - src := []byte{0x97} - hash := crypto.Hash256(src) - return hash - } - ` - eval(t, src, []byte{0xc0, 0x85, 0x26, 0xad, 0x17, 0x36, 0x53, 0xee, 0xb8, 0xc7, 0xf4, 0xae, 0x82, 0x8b, 0x6e, 0xa1, 0x84, 0xac, 0x5a, 0x3, 0x8a, 0xf6, 0xc3, 0x68, 0x23, 0xfa, 0x5f, 0x5d, 0xd9, 0x1b, 0x91, 0xa2}) -} diff --git a/pkg/interop/crypto/crypto.go b/pkg/interop/crypto/crypto.go index abfe586e8..fe8d527f5 100644 --- a/pkg/interop/crypto/crypto.go +++ b/pkg/interop/crypto/crypto.go @@ -13,16 +13,6 @@ func SHA256(b []byte) []byte { return nil } -// Hash160 computes the sha256 + ripemd160 of b. -func Hash160(b []byte) []byte { - return nil -} - -// Hash256 computes the sha256^2 hash of b. -func Hash256(b []byte) []byte { - return nil -} - // VerifySignature checks that sig is msg's signature with pub. func VerifySignature(msg []byte, sig []byte, pub []byte) bool { return false diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 7b2bc967b..4b56d1f8f 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -1332,14 +1332,6 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro b := v.estack.Pop().Bytes() v.estack.PushVal(hash.Sha256(b).BytesBE()) - case opcode.HASH160: - b := v.estack.Pop().Bytes() - v.estack.PushVal(hash.Hash160(b).BytesBE()) - - case opcode.HASH256: - b := v.estack.Pop().Bytes() - v.estack.PushVal(hash.DoubleSha256(b).BytesBE()) - case opcode.NOP: // unlucky ^^ diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index 4c55b88fd..e35b7d162 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -3035,28 +3035,6 @@ func TestSHA256(t *testing.T) { assert.Equal(t, res, hex.EncodeToString(vm.estack.Pop().Bytes())) } -func TestHASH160(t *testing.T) { - // 0x0100 hashes to fbc22d517f38e7612798ece8e5957cf6c41d8caf - res := "fbc22d517f38e7612798ece8e5957cf6c41d8caf" - prog := makeProgram(opcode.PUSHBYTES2, 1, 0, - opcode.HASH160) - vm := load(prog) - runVM(t, vm) - assert.Equal(t, 1, vm.estack.Len()) - assert.Equal(t, res, hex.EncodeToString(vm.estack.Pop().Bytes())) -} - -func TestHASH256(t *testing.T) { - // 0x0100 hashes to 677b2d718464ee0121475600b929c0b4155667486577d1320b18c2dc7d4b4f99 - res := "677b2d718464ee0121475600b929c0b4155667486577d1320b18c2dc7d4b4f99" - prog := makeProgram(opcode.PUSHBYTES2, 1, 0, - opcode.HASH256) - vm := load(prog) - runVM(t, vm) - assert.Equal(t, 1, vm.estack.Len()) - assert.Equal(t, res, hex.EncodeToString(vm.estack.Pop().Bytes())) -} - var opcodesTestCases = map[opcode.Opcode][]struct { name string args []interface{}