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
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
|
"address": "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
|
"address": "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK",
|
"address": "NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEQtBE43vrw==",
|
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEQtBE43vrw==",
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NWvKSwutC8D6VKmmPxAEgFKx2NLvFhn8q5",
|
"address": "NUREbqw2kfbPgDeEz8Dac2QxntGGqqFMm7",
|
||||||
"key": "6PYKEHagXJ3mDLdga1FoyTGRtPdJgPz6Gb8sjEFwZvRu7ncD9PVZfHtMzL",
|
"key": "6PYXADog3RQCwKRhqQsobwZEFopdcCJuMfPosM9pXPaDWSguKvznLdpADk",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4LQZVEDXg=",
|
"script": "DCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG5BdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYKEHagXJ3mDLdga1FoyTGRtPdJgPz6Gb8sjEFwZvRu7ncD9PVZfHtMzL",
|
"key": "6PYXADog3RQCwKRhqQsobwZEFopdcCJuMfPosM9pXPaDWSguKvznLdpADk",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NNB3RsnTABEwoKEudNG92njds91WtiCuxd",
|
"address": "NQP81vKVRmwZHveX8C9Rbf2qejSpT1W1Eu",
|
||||||
"key": "6PYLjn1Zw3RQmP3CkDxoZvYtMpu7ZUdjHnvu7wPuohUcXWCMh9vY661R8A",
|
"key": "6PYScv3Vgvdi9EkhDNvHXdvQeuaXK9gRwXDmytCswZMNpTzMLvfgR3U5dK",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5pkLQZVEDXg=",
|
"script": "DCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5plBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYLjn1Zw3RQmP3CkDxoZvYtMpu7ZUdjHnvu7wPuohUcXWCMh9vY661R8A",
|
"key": "6PYScv3Vgvdi9EkhDNvHXdvQeuaXK9gRwXDmytCswZMNpTzMLvfgR3U5dK",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "Nfzo95iBXfeAGx5rdjPedZRAqHKh9hwMdR",
|
"address": "NLA34vf8eXGGUhRjVaYe5f8YsyYHTehbDZ",
|
||||||
"key": "6PYLbYYg9jUgzJQpKhpvNExa2UEgtp4356XPg56pHuCpE7gQmj84ESNjYW",
|
"key": "6PYVwp1Sdg9DfTzvg42PZxgzMDf5a5FYBgT6ynKKzwmSHuhGkipoNjyW3a",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWILQZVEDXg=",
|
"script": "DCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYLbYYg9jUgzJQpKhpvNExa2UEgtp4356XPg56pHuCpE7gQmj84ESNjYW",
|
"key": "6PYVwp1Sdg9DfTzvg42PZxgzMDf5a5FYBgT6ynKKzwmSHuhGkipoNjyW3a",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
|
@ -51,7 +51,7 @@ func TestNEP17Balance(t *testing.T) {
|
||||||
})
|
})
|
||||||
t.Run("all accounts", func(t *testing.T) {
|
t.Run("all accounts", func(t *testing.T) {
|
||||||
e.Run(t, cmdbase...)
|
e.Run(t, cmdbase...)
|
||||||
addr1, err := address.StringToUint160("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc")
|
addr1, err := address.StringToUint160("NTh9TnZTstvAePEYWDGLLxidBikJE24uTo")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
e.checkNextLine(t, "^Account "+address.Uint160ToString(addr1))
|
e.checkNextLine(t, "^Account "+address.Uint160ToString(addr1))
|
||||||
e.checkNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)")
|
e.checkNextLine(t, "^\\s*GAS:\\s+GasToken \\("+e.Chain.UtilityTokenHash().StringLE()+"\\)")
|
||||||
|
@ -136,7 +136,7 @@ func TestNEP17Transfer(t *testing.T) {
|
||||||
require.Equal(t, big.NewInt(1), b)
|
require.Equal(t, big.NewInt(1), b)
|
||||||
|
|
||||||
t.Run("default address", func(t *testing.T) {
|
t.Run("default address", func(t *testing.T) {
|
||||||
const validatorDefault = "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc"
|
const validatorDefault = "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo"
|
||||||
e.In.WriteString("one\r")
|
e.In.WriteString("one\r")
|
||||||
e.Run(t, "neo-go", "wallet", "nep17", "multitransfer",
|
e.Run(t, "neo-go", "wallet", "nep17", "multitransfer",
|
||||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||||
|
|
BIN
cli/testdata/chain50x2.acc
vendored
BIN
cli/testdata/chain50x2.acc
vendored
Binary file not shown.
32
cli/testdata/testwallet.json
vendored
32
cli/testdata/testwallet.json
vendored
|
@ -1 +1,31 @@
|
||||||
{"version":"3.0","accounts":[{"address":"NNuJqXDnRqvwgzhSzhH4jnVFWB1DyZ34EM","key":"6PYT6enT6eh4gu4ew3Mx58pFFDQNhuR1qQPuU594Eo5u4sA2ZvE4MqJV12","label":"kek","contract":{"script":"DCECl3UyEIq6T5RRIXS6z4tNdZPTzQ7NvXyx7FwK05d9UyYLQZVEDXg=","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}}
|
{
|
||||||
|
"version" : "3.0",
|
||||||
|
"extra" : {
|
||||||
|
"Tokens" : null
|
||||||
|
},
|
||||||
|
"accounts" : [
|
||||||
|
{
|
||||||
|
"lock" : false,
|
||||||
|
"isdefault" : false,
|
||||||
|
"key" : "6PYRjaxsdSrW8zBzPynkC9uJRHpkhFHiQTuYY33gNL1wTimTbpN8S8eCNc",
|
||||||
|
"address" : "NUSEsqon6PikQA5mDFaV4njemF9Su8JEmf",
|
||||||
|
"contract" : {
|
||||||
|
"parameters" : [
|
||||||
|
{
|
||||||
|
"type" : "Signature",
|
||||||
|
"name" : "parameter0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"script" : "DCECl3UyEIq6T5RRIXS6z4tNdZPTzQ7NvXyx7FwK05d9UyZBdHR2qg==",
|
||||||
|
"deployed" : false
|
||||||
|
},
|
||||||
|
"label" : "kek"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scrypt" : {
|
||||||
|
"r" : 8,
|
||||||
|
"p" : 8,
|
||||||
|
"n" : 16384
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
14
cli/testdata/wallet1_solo.json
vendored
14
cli/testdata/wallet1_solo.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
|
"address": "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK",
|
"address": "NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEQtBE43vrw==",
|
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEQtBE43vrw==",
|
||||||
|
@ -62,10 +62,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address" : "NWTDxsHVde5qSjRkTRUAg6i8xC3JSWEC9k",
|
"address" : "NWTDxsHVde5qSjRkTRUAg6i8xC3JSWEC9k",
|
||||||
"key" : "6PYXDze5Ak4HahYKygcNzk6n65ACjWdDCYLSuKgA5KG8vyMJSFboUNSiPD",
|
"key" : "6PYSgdjUPVjo3ZJLg2CsheXnEZzyvUuSm4jCtXP6X7FT82sAQHWt2wpu5A",
|
||||||
"label" : "",
|
"label" : "",
|
||||||
"contract" : {
|
"contract" : {
|
||||||
"script" : "VwEAEUBXAANA",
|
"script" : "VwMAQS1RCDAhcAwUVVQtU+0PVUb61E1umZEoZwIvzl7bMHFoE87bKGnbKJdA",
|
||||||
"deployed" : true,
|
"deployed" : true,
|
||||||
"parameters" : []
|
"parameters" : []
|
||||||
},
|
},
|
||||||
|
|
8
cli/testdata/wallets/testwallet_NEO3.json
vendored
8
cli/testdata/wallets/testwallet_NEO3.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
|
"address": "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
|
@ -318,7 +318,7 @@ func TestWalletDump(t *testing.T) {
|
||||||
w := new(wallet.Wallet)
|
w := new(wallet.Wallet)
|
||||||
require.NoError(t, json.Unmarshal([]byte(rawStr), w))
|
require.NoError(t, json.Unmarshal([]byte(rawStr), w))
|
||||||
require.Equal(t, 1, len(w.Accounts))
|
require.Equal(t, 1, len(w.Accounts))
|
||||||
require.Equal(t, "NNuJqXDnRqvwgzhSzhH4jnVFWB1DyZ34EM", w.Accounts[0].Address)
|
require.Equal(t, "NUSEsqon6PikQA5mDFaV4njemF9Su8JEmf", w.Accounts[0].Address)
|
||||||
|
|
||||||
t.Run("with decrypt", func(t *testing.T) {
|
t.Run("with decrypt", func(t *testing.T) {
|
||||||
cmd = append(cmd, "--decrypt")
|
cmd = append(cmd, "--decrypt")
|
||||||
|
@ -333,7 +333,7 @@ func TestWalletDump(t *testing.T) {
|
||||||
w := new(wallet.Wallet)
|
w := new(wallet.Wallet)
|
||||||
require.NoError(t, json.Unmarshal([]byte(rawStr), w))
|
require.NoError(t, json.Unmarshal([]byte(rawStr), w))
|
||||||
require.Equal(t, 1, len(w.Accounts))
|
require.Equal(t, 1, len(w.Accounts))
|
||||||
require.Equal(t, "NNuJqXDnRqvwgzhSzhH4jnVFWB1DyZ34EM", w.Accounts[0].Address)
|
require.Equal(t, "NUSEsqon6PikQA5mDFaV4njemF9Su8JEmf", w.Accounts[0].Address)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,7 +343,7 @@ func TestDumpKeys(t *testing.T) {
|
||||||
pubRegex := "^0[23][a-hA-H0-9]{64}$"
|
pubRegex := "^0[23][a-hA-H0-9]{64}$"
|
||||||
t.Run("all", func(t *testing.T) {
|
t.Run("all", func(t *testing.T) {
|
||||||
e.Run(t, cmd...)
|
e.Run(t, cmd...)
|
||||||
e.checkNextLine(t, "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc")
|
e.checkNextLine(t, "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo")
|
||||||
e.checkNextLine(t, pubRegex)
|
e.checkNextLine(t, pubRegex)
|
||||||
e.checkNextLine(t, "^\\s*$")
|
e.checkNextLine(t, "^\\s*$")
|
||||||
e.checkNextLine(t, "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY")
|
e.checkNextLine(t, "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY")
|
||||||
|
@ -356,7 +356,7 @@ func TestDumpKeys(t *testing.T) {
|
||||||
e.checkEOF(t)
|
e.checkEOF(t)
|
||||||
})
|
})
|
||||||
t.Run("simple signature", func(t *testing.T) {
|
t.Run("simple signature", func(t *testing.T) {
|
||||||
cmd := append(cmd, "--address", "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc")
|
cmd := append(cmd, "--address", "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo")
|
||||||
e.Run(t, cmd...)
|
e.Run(t, cmd...)
|
||||||
e.checkNextLine(t, "simple signature contract")
|
e.checkNextLine(t, "simple signature contract")
|
||||||
e.checkNextLine(t, pubRegex)
|
e.checkNextLine(t, pubRegex)
|
||||||
|
|
|
@ -14,36 +14,36 @@ type Ktype struct {
|
||||||
// Arr contains a set of known keys in Ktype format.
|
// Arr contains a set of known keys in Ktype format.
|
||||||
var Arr = []Ktype{
|
var Arr = []Ktype{
|
||||||
{
|
{
|
||||||
Address: "NNWAo5vdVJz1oyCuNiaTBA3amBHnWCF4Yk",
|
Address: "NQrEVKgpx2qEg6DpVMT5H8kFa7kc2DFgqS",
|
||||||
PrivateKey: "7d128a6d096f0c14c3a25a2b0c41cf79661bfcb4a8cc95aaaea28bde4d732344",
|
PrivateKey: "7d128a6d096f0c14c3a25a2b0c41cf79661bfcb4a8cc95aaaea28bde4d732344",
|
||||||
PublicKey: "02028a99826edc0c97d18e22b6932373d908d323aa7f92656a77ec26e8861699ef",
|
PublicKey: "02028a99826edc0c97d18e22b6932373d908d323aa7f92656a77ec26e8861699ef",
|
||||||
Wif: "L1QqQJnpBwbsPGAuutuzPTac8piqvbR1HRjrY5qHup48TBCBFe4g",
|
Wif: "L1QqQJnpBwbsPGAuutuzPTac8piqvbR1HRjrY5qHup48TBCBFe4g",
|
||||||
Passphrase: "city of zion",
|
Passphrase: "city of zion",
|
||||||
EncryptedWif: "6PYSeMMbJtfMRD81eHzriwrRKquu2dgLNurYcAbmJa7YqAiThgA2vGQu5o",
|
EncryptedWif: "6PYWaEBMd9UTVFKi1YahYXY5NMLDg9U6w2gpQYUnx8wvaFgdo8EeVPaD7o",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Address: "NiwvMyWYeNghLG8tDyKkWwuZV3wS8CPrrV",
|
Address: "NYaVsrMV9GS8aaspRS4odXf1WHZdMmJiPC",
|
||||||
PrivateKey: "9ab7e154840daca3a2efadaf0df93cd3a5b51768c632f5433f86909d9b994a69",
|
PrivateKey: "9ab7e154840daca3a2efadaf0df93cd3a5b51768c632f5433f86909d9b994a69",
|
||||||
PublicKey: "031d8e1630ce640966967bc6d95223d21f44304133003140c3b52004dc981349c9",
|
PublicKey: "031d8e1630ce640966967bc6d95223d21f44304133003140c3b52004dc981349c9",
|
||||||
Wif: "L2QTooFoDFyRFTxmtiVHt5CfsXfVnexdbENGDkkrrgTTryiLsPMG",
|
Wif: "L2QTooFoDFyRFTxmtiVHt5CfsXfVnexdbENGDkkrrgTTryiLsPMG",
|
||||||
Passphrase: "我的密码",
|
Passphrase: "我的密码",
|
||||||
EncryptedWif: "6PYKWKaq5NMyjt8cjvnJnvmV13inhFuePpWZMkddFAMCgjC3ETt7kX16V9",
|
EncryptedWif: "6PYUpn5uxTpsoawM3YKEWamk2oiKeafQBBK3Vutsowogy8a86jPu71xhE9",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Address: "NTWHAzB82LRGWNuuqjVyyzpGvF3WxbbPoG",
|
Address: "NWcpK2143ZjgzDYyQJhoKrodJUymHTxPzR",
|
||||||
PrivateKey: "3edee7036b8fd9cef91de47386b191dd76db2888a553e7736bb02808932a915b",
|
PrivateKey: "3edee7036b8fd9cef91de47386b191dd76db2888a553e7736bb02808932a915b",
|
||||||
PublicKey: "02232ce8d2e2063dce0451131851d47421bfc4fc1da4db116fca5302c0756462fa",
|
PublicKey: "02232ce8d2e2063dce0451131851d47421bfc4fc1da4db116fca5302c0756462fa",
|
||||||
Wif: "KyKvWLZsNwBJx5j9nurHYRwhYfdQUu9tTEDsLCUHDbYBL8cHxMiG",
|
Wif: "KyKvWLZsNwBJx5j9nurHYRwhYfdQUu9tTEDsLCUHDbYBL8cHxMiG",
|
||||||
Passphrase: "MyL33tP@33w0rd",
|
Passphrase: "MyL33tP@33w0rd",
|
||||||
EncryptedWif: "6PYSzKoJBQMj9uHUv1Sc2ZhMrydqDF8ZCTeE9FuPiNdEx7Lo9NoEuaXeyk",
|
EncryptedWif: "6PYRbKt55d4NXxCESqk8n9kURqopvixEY5nhAYe2ZJ4c1oDWAjtFX8hd1M",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Address: "xdf4UGKevVrMR1j3UkPsuoYKSC4ocoAkKx",
|
Address: "NWcpK2143ZjgzDYyQJhoKrodJUymHTxPzR",
|
||||||
PrivateKey: "zzdee7036b8fd9cef91de47386b191dd76db2888a553e7736bb02808932a915b",
|
PrivateKey: "3edee7036b8fd9cef91de47386b191dd76db2888a553e7736bb02808932a915",
|
||||||
PublicKey: "zz232ce8d2e2063dce0451131851d47421bfc4fc1da4db116fca5302c0756462fa",
|
PublicKey: "02232ce8d2e2063dce0451131851d47421bfc4fc1da4db116fca5302c0756462fa",
|
||||||
Wif: "zzKvWLZsNwBJx5j9nurHYRwhYfdQUu9tTEDsLCUHDbYBL8cHxMiG",
|
Wif: "KyKvWLZsNwBJx5j9nurHYRwhYfdQUu9tTEDsLCUHDbYBL8cHxMiS",
|
||||||
Passphrase: "zzL33tP@33w0rd",
|
Passphrase: "invalid_pass_but_valid_wif",
|
||||||
EncryptedWif: "6PYSzKoJBQMj9uHUv1Sc2ZhMrydqDF8ZCTeE9FuPiNdEx7Lo9NoEuaXeyk",
|
EncryptedWif: "6PYRbKt55d4NXxCESqk8n9kURqopvixEY5nhAYe2ZJ4c1oDWAjtFX8hd1M",
|
||||||
Invalid: true,
|
Invalid: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,44 +49,44 @@ func NewTransferFromOwner(bc blockchainer.Blockchainer, contractHash, to util.Ui
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDeployTx returns new deployment tx for contract with name with Go code read from r.
|
// NewDeployTx returns new deployment tx for contract with name with Go code read from r.
|
||||||
func NewDeployTx(bc blockchainer.Blockchainer, name string, sender util.Uint160, r gio.Reader) (*transaction.Transaction, util.Uint160, error) {
|
func NewDeployTx(bc blockchainer.Blockchainer, name string, sender util.Uint160, r gio.Reader) (*transaction.Transaction, util.Uint160, []byte, error) {
|
||||||
// nef.NewFile() cares about version a lot.
|
// nef.NewFile() cares about version a lot.
|
||||||
config.Version = "0.90.0-test"
|
config.Version = "0.90.0-test"
|
||||||
|
|
||||||
avm, di, err := compiler.CompileWithDebugInfo(name, r)
|
avm, di, err := compiler.CompileWithDebugInfo(name, r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, util.Uint160{}, err
|
return nil, util.Uint160{}, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
ne, err := nef.NewFile(avm)
|
ne, err := nef.NewFile(avm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, util.Uint160{}, err
|
return nil, util.Uint160{}, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
m, err := di.ConvertToManifest(&compiler.Options{Name: name})
|
m, err := di.ConvertToManifest(&compiler.Options{Name: name})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, util.Uint160{}, err
|
return nil, util.Uint160{}, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
rawManifest, err := json.Marshal(m)
|
rawManifest, err := json.Marshal(m)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, util.Uint160{}, err
|
return nil, util.Uint160{}, nil, err
|
||||||
}
|
}
|
||||||
neb, err := ne.Bytes()
|
neb, err := ne.Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, util.Uint160{}, err
|
return nil, util.Uint160{}, nil, err
|
||||||
}
|
}
|
||||||
buf := io.NewBufBinWriter()
|
buf := io.NewBufBinWriter()
|
||||||
emit.AppCall(buf.BinWriter, bc.ManagementContractHash(), "deploy", callflag.All, neb, rawManifest)
|
emit.AppCall(buf.BinWriter, bc.ManagementContractHash(), "deploy", callflag.All, neb, rawManifest)
|
||||||
if buf.Err != nil {
|
if buf.Err != nil {
|
||||||
return nil, util.Uint160{}, buf.Err
|
return nil, util.Uint160{}, nil, buf.Err
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := transaction.New(Network(), buf.Bytes(), 100*native.GASFactor)
|
tx := transaction.New(Network(), buf.Bytes(), 100*native.GASFactor)
|
||||||
tx.Signers = []transaction.Signer{{Account: sender}}
|
tx.Signers = []transaction.Signer{{Account: sender}}
|
||||||
h := state.CreateContractHash(tx.Sender(), ne.Checksum, name)
|
h := state.CreateContractHash(tx.Sender(), ne.Checksum, name)
|
||||||
|
|
||||||
return tx, h, nil
|
return tx, h, avm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// SignTx signs provided transactions with validator keys.
|
// SignTx signs provided transactions with validator keys.
|
||||||
|
|
|
@ -89,8 +89,6 @@ func TestSyscallExecution(t *testing.T) {
|
||||||
"storage.GetReadOnlyContext": {interopnames.SystemStorageGetReadOnlyContext, nil, false},
|
"storage.GetReadOnlyContext": {interopnames.SystemStorageGetReadOnlyContext, nil, false},
|
||||||
"storage.Put": {interopnames.SystemStoragePut, []string{sctx, b, b}, true},
|
"storage.Put": {interopnames.SystemStoragePut, []string{sctx, b, b}, true},
|
||||||
"storage.ConvertContextToReadOnly": {interopnames.SystemStorageAsReadOnly, []string{sctx}, false},
|
"storage.ConvertContextToReadOnly": {interopnames.SystemStorageAsReadOnly, []string{sctx}, false},
|
||||||
"crypto.ECDsaSecp256r1Verify": {interopnames.NeoCryptoVerifyWithECDsaSecp256r1, []string{b, pub, sig}, false},
|
|
||||||
"crypto.ECDsaSecp256k1Verify": {interopnames.NeoCryptoVerifyWithECDsaSecp256k1, []string{b, pub, sig}, false},
|
|
||||||
"crypto.ECDSASecp256r1CheckMultisig": {interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1, []string{b, pubs, sigs}, false},
|
"crypto.ECDSASecp256r1CheckMultisig": {interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1, []string{b, pubs, sigs}, false},
|
||||||
"crypto.ECDSASecp256k1CheckMultisig": {interopnames.NeoCryptoCheckMultisigWithECDsaSecp256k1, []string{b, pubs, sigs}, false},
|
"crypto.ECDSASecp256k1CheckMultisig": {interopnames.NeoCryptoCheckMultisigWithECDsaSecp256k1, []string{b, pubs, sigs}, false},
|
||||||
"crypto.CheckSig": {interopnames.NeoCryptoCheckSig, []string{pub, sig}, false},
|
"crypto.CheckSig": {interopnames.NeoCryptoCheckSig, []string{pub, sig}, false},
|
||||||
|
|
|
@ -16,11 +16,10 @@ import (
|
||||||
func TestVerifyGood(t *testing.T) {
|
func TestVerifyGood(t *testing.T) {
|
||||||
msg := []byte("test message")
|
msg := []byte("test message")
|
||||||
pub, sig := signMessage(t, msg)
|
pub, sig := signMessage(t, msg)
|
||||||
src := getVerifyProg(pub, sig, msg)
|
src := getVerifyProg(pub, sig)
|
||||||
|
|
||||||
v, p := vmAndCompileInterop(t, src)
|
v, p := vmAndCompileInterop(t, src)
|
||||||
p.interops[interopnames.ToID([]byte(interopnames.NeoCryptoVerifyWithECDsaSecp256r1))] = func(v *vm.VM) error {
|
p.interops[interopnames.ToID([]byte(interopnames.NeoCryptoCheckSig))] = func(v *vm.VM) error {
|
||||||
assert.Equal(t, msg, v.Estack().Pop().Bytes())
|
|
||||||
assert.Equal(t, pub, v.Estack().Pop().Bytes())
|
assert.Equal(t, pub, v.Estack().Pop().Bytes())
|
||||||
assert.Equal(t, sig, v.Estack().Pop().Bytes())
|
assert.Equal(t, sig, v.Estack().Pop().Bytes())
|
||||||
v.Estack().PushVal(true)
|
v.Estack().PushVal(true)
|
||||||
|
@ -40,10 +39,9 @@ func signMessage(t *testing.T, msg []byte) ([]byte, []byte) {
|
||||||
return pub, sig
|
return pub, sig
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVerifyProg(pub, sig, msg []byte) string {
|
func getVerifyProg(pub, sig []byte) string {
|
||||||
pubS := fmt.Sprintf("%#v", pub)
|
pubS := fmt.Sprintf("%#v", pub)
|
||||||
sigS := fmt.Sprintf("%#v", sig)
|
sigS := fmt.Sprintf("%#v", sig)
|
||||||
msgS := fmt.Sprintf("%#v", msg)
|
|
||||||
|
|
||||||
return `
|
return `
|
||||||
package hello
|
package hello
|
||||||
|
@ -53,8 +51,7 @@ func getVerifyProg(pub, sig, msg []byte) string {
|
||||||
func Main() bool {
|
func Main() bool {
|
||||||
pub := ` + pubS + `
|
pub := ` + pubS + `
|
||||||
sig := ` + sigS + `
|
sig := ` + sigS + `
|
||||||
msg := ` + msgS + `
|
return crypto.CheckSig(pub, sig)
|
||||||
return crypto.ECDsaSecp256r1Verify(msg, pub, sig)
|
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
25
pkg/consensus/testdata/wallet1.json
vendored
25
pkg/consensus/testdata/wallet1.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
|
"address": "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
@ -42,23 +42,6 @@
|
||||||
},
|
},
|
||||||
"lock": false,
|
"lock": false,
|
||||||
"isdefault": false
|
"isdefault": false
|
||||||
},
|
|
||||||
{
|
|
||||||
"address": "NVNvVRW5Q5naSx2k2iZm7xRgtRNGuZppAK",
|
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
|
||||||
"label": "",
|
|
||||||
"contract": {
|
|
||||||
"script": "EQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CEQtBE43vrw==",
|
|
||||||
"parameters": [
|
|
||||||
{
|
|
||||||
"name": "parameter0",
|
|
||||||
"type": "Signature"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"deployed": false
|
|
||||||
},
|
|
||||||
"lock": false,
|
|
||||||
"isdefault": false
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"scrypt": {
|
"scrypt": {
|
||||||
|
|
8
pkg/consensus/testdata/wallet2.json
vendored
8
pkg/consensus/testdata/wallet2.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NWvKSwutC8D6VKmmPxAEgFKx2NLvFhn8q5",
|
"address": "NUREbqw2kfbPgDeEz8Dac2QxntGGqqFMm7",
|
||||||
"key": "6PYKEHagXJ3mDLdga1FoyTGRtPdJgPz6Gb8sjEFwZvRu7ncD9PVZfHtMzL",
|
"key": "6PYXADog3RQCwKRhqQsobwZEFopdcCJuMfPosM9pXPaDWSguKvznLdpADk",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4LQZVEDXg=",
|
"script": "DCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG5BdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYKEHagXJ3mDLdga1FoyTGRtPdJgPz6Gb8sjEFwZvRu7ncD9PVZfHtMzL",
|
"key": "6PYXADog3RQCwKRhqQsobwZEFopdcCJuMfPosM9pXPaDWSguKvznLdpADk",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
8
pkg/consensus/testdata/wallet3.json
vendored
8
pkg/consensus/testdata/wallet3.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NNB3RsnTABEwoKEudNG92njds91WtiCuxd",
|
"address": "NQP81vKVRmwZHveX8C9Rbf2qejSpT1W1Eu",
|
||||||
"key": "6PYLjn1Zw3RQmP3CkDxoZvYtMpu7ZUdjHnvu7wPuohUcXWCMh9vY661R8A",
|
"key": "6PYScv3Vgvdi9EkhDNvHXdvQeuaXK9gRwXDmytCswZMNpTzMLvfgR3U5dK",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5pkLQZVEDXg=",
|
"script": "DCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5plBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYLjn1Zw3RQmP3CkDxoZvYtMpu7ZUdjHnvu7wPuohUcXWCMh9vY661R8A",
|
"key": "6PYScv3Vgvdi9EkhDNvHXdvQeuaXK9gRwXDmytCswZMNpTzMLvfgR3U5dK",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
8
pkg/consensus/testdata/wallet4.json
vendored
8
pkg/consensus/testdata/wallet4.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "Nfzo95iBXfeAGx5rdjPedZRAqHKh9hwMdR",
|
"address": "NLA34vf8eXGGUhRjVaYe5f8YsyYHTehbDZ",
|
||||||
"key": "6PYLbYYg9jUgzJQpKhpvNExa2UEgtp4356XPg56pHuCpE7gQmj84ESNjYW",
|
"key": "6PYVwp1Sdg9DfTzvg42PZxgzMDf5a5FYBgT6ynKKzwmSHuhGkipoNjyW3a",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWILQZVEDXg=",
|
"script": "DCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYLbYYg9jUgzJQpKhpvNExa2UEgtp4356XPg56pHuCpE7gQmj84ESNjYW",
|
"key": "6PYVwp1Sdg9DfTzvg42PZxgzMDf5a5FYBgT6ynKKzwmSHuhGkipoNjyW3a",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
|
@ -1229,7 +1229,7 @@ func TestIsTxStillRelevant(t *testing.T) {
|
||||||
currentHeight := contract.Call(addr, "currentIndex", contract.ReadStates)
|
currentHeight := contract.Call(addr, "currentIndex", contract.ReadStates)
|
||||||
return currentHeight.(int) < %d
|
return currentHeight.(int) < %d
|
||||||
}`, bc.BlockHeight()+2) // deploy + next block
|
}`, bc.BlockHeight()+2) // deploy + next block
|
||||||
txDeploy, h, err := testchain.NewDeployTx(bc, "TestVerify", neoOwner, strings.NewReader(src))
|
txDeploy, h, _, err := testchain.NewDeployTx(bc, "TestVerify", neoOwner, strings.NewReader(src))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
txDeploy.ValidUntilBlock = bc.BlockHeight() + 1
|
txDeploy.ValidUntilBlock = bc.BlockHeight() + 1
|
||||||
addSigners(neoOwner, txDeploy)
|
addSigners(neoOwner, txDeploy)
|
||||||
|
|
|
@ -18,7 +18,7 @@ func Calculate(base int64, script []byte) (int64, int) {
|
||||||
)
|
)
|
||||||
if vm.IsSignatureContract(script) {
|
if vm.IsSignatureContract(script) {
|
||||||
size += 67 + io.GetVarSize(script)
|
size += 67 + io.GetVarSize(script)
|
||||||
netFee += Opcode(base, opcode.PUSHDATA1, opcode.PUSHNULL, opcode.PUSHDATA1) + base*ECDSAVerifyPrice
|
netFee += Opcode(base, opcode.PUSHDATA1, opcode.PUSHDATA1) + base*ECDSAVerifyPrice
|
||||||
} else if m, pubs, ok := vm.ParseMultiSigContract(script); ok {
|
} else if m, pubs, ok := vm.ParseMultiSigContract(script); ok {
|
||||||
n := len(pubs)
|
n := len(pubs)
|
||||||
sizeInv := 66 * m
|
sizeInv := 66 * m
|
||||||
|
|
|
@ -2,6 +2,7 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/base64"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -268,7 +269,7 @@ func TestCreateBasicChain(t *testing.T) {
|
||||||
require.NoError(t, acc0.SignTx(txSendRaw))
|
require.NoError(t, acc0.SignTx(txSendRaw))
|
||||||
bw := io.NewBufBinWriter()
|
bw := io.NewBufBinWriter()
|
||||||
txSendRaw.EncodeBinary(bw.BinWriter)
|
txSendRaw.EncodeBinary(bw.BinWriter)
|
||||||
t.Logf("sendrawtransaction: %s", hex.EncodeToString(bw.Bytes()))
|
t.Logf("sendrawtransaction: %s", base64.StdEncoding.EncodeToString(bw.Bytes()))
|
||||||
require.False(t, saveChain)
|
require.False(t, saveChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,6 +450,9 @@ func initBasicChain(t *testing.T, bc *Blockchain) {
|
||||||
require.NoError(t, ntr.Accounts[0].Decrypt("one"))
|
require.NoError(t, ntr.Accounts[0].Decrypt("one"))
|
||||||
bc.setNodesByRole(t, true, native.RoleP2PNotary, keys.PublicKeys{ntr.Accounts[0].PrivateKey().PublicKey()})
|
bc.setNodesByRole(t, true, native.RoleP2PNotary, keys.PublicKeys{ntr.Accounts[0].PrivateKey().PublicKey()})
|
||||||
t.Logf("Designated Notary node: %s", hex.EncodeToString(ntr.Accounts[0].PrivateKey().PublicKey().Bytes()))
|
t.Logf("Designated Notary node: %s", hex.EncodeToString(ntr.Accounts[0].PrivateKey().PublicKey().Bytes()))
|
||||||
|
|
||||||
|
// Compile contract to test `invokescript` RPC call
|
||||||
|
_, _ = newDeployTx(t, bc, priv0ScriptHash, prefix+"invokescript_contract.go", "ContractForInvokescriptTest")
|
||||||
}
|
}
|
||||||
|
|
||||||
func newNEP17Transfer(sc, from, to util.Uint160, amount int64, additionalArgs ...interface{}) *transaction.Transaction {
|
func newNEP17Transfer(sc, from, to util.Uint160, amount int64, additionalArgs ...interface{}) *transaction.Transaction {
|
||||||
|
@ -466,9 +470,9 @@ func newNEP17Transfer(sc, from, to util.Uint160, amount int64, additionalArgs ..
|
||||||
func newDeployTx(t *testing.T, bc *Blockchain, sender util.Uint160, name, ctrName string) (*transaction.Transaction, util.Uint160) {
|
func newDeployTx(t *testing.T, bc *Blockchain, sender util.Uint160, name, ctrName string) (*transaction.Transaction, util.Uint160) {
|
||||||
c, err := ioutil.ReadFile(name)
|
c, err := ioutil.ReadFile(name)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
tx, h, err := testchain.NewDeployTx(bc, ctrName, sender, bytes.NewReader(c))
|
tx, h, avm, err := testchain.NewDeployTx(bc, ctrName, sender, bytes.NewReader(c))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Logf("contractHash (%s): %s", name, h.StringLE())
|
t.Logf("contract (%s): \n\tHash: %s\n\tAVM: %s", name, h.StringLE(), base64.StdEncoding.EncodeToString(avm))
|
||||||
return tx, h
|
return tx, h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,34 +16,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ECDSASecp256r1Verify checks ECDSA signature using Secp256r1 elliptic curve.
|
|
||||||
func ECDSASecp256r1Verify(ic *interop.Context) error {
|
|
||||||
return ecdsaVerify(ic, elliptic.P256())
|
|
||||||
}
|
|
||||||
|
|
||||||
// ECDSASecp256k1Verify checks ECDSA signature using Secp256k1 elliptic curve
|
|
||||||
func ECDSASecp256k1Verify(ic *interop.Context) error {
|
|
||||||
return ecdsaVerify(ic, btcec.S256())
|
|
||||||
}
|
|
||||||
|
|
||||||
// ecdsaVerify is internal representation of ECDSASecp256k1Verify and
|
|
||||||
// ECDSASecp256r1Verify.
|
|
||||||
func ecdsaVerify(ic *interop.Context, curve elliptic.Curve) error {
|
|
||||||
hashToCheck, err := getMessageHash(ic, ic.VM.Estack().Pop().Item())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
keyb := ic.VM.Estack().Pop().Bytes()
|
|
||||||
signature := ic.VM.Estack().Pop().Bytes()
|
|
||||||
pkey, err := keys.NewPublicKeyFromBytes(keyb, curve)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
res := pkey.Verify(signature, hashToCheck.BytesBE())
|
|
||||||
ic.VM.Estack().PushVal(res)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ECDSASecp256r1CheckMultisig checks multiple ECDSA signatures at once using
|
// ECDSASecp256r1CheckMultisig checks multiple ECDSA signatures at once using
|
||||||
// Secp256r1 elliptic curve.
|
// Secp256r1 elliptic curve.
|
||||||
func ECDSASecp256r1CheckMultisig(ic *interop.Context) error {
|
func ECDSASecp256r1CheckMultisig(ic *interop.Context) error {
|
||||||
|
|
|
@ -20,104 +20,6 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestECDSASecp256r1Verify(t *testing.T) {
|
|
||||||
testECDSAVerify(t, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestECDSASecp256k1Verify(t *testing.T) {
|
|
||||||
testECDSAVerify(t, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testECDSAVerify(t *testing.T, isR1 bool) {
|
|
||||||
var priv *keys.PrivateKey
|
|
||||||
var err error
|
|
||||||
if isR1 {
|
|
||||||
priv, err = keys.NewPrivateKey()
|
|
||||||
} else {
|
|
||||||
priv, err = keys.NewSecp256k1PrivateKey()
|
|
||||||
}
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
verifyFunc := ECDSASecp256r1Verify
|
|
||||||
if !isR1 {
|
|
||||||
verifyFunc = ECDSASecp256k1Verify
|
|
||||||
}
|
|
||||||
d := dao.NewSimple(storage.NewMemoryStore(), netmode.UnitTestNet, false)
|
|
||||||
ic := &interop.Context{DAO: dao.NewCached(d)}
|
|
||||||
runCase := func(t *testing.T, isErr bool, result interface{}, args ...interface{}) {
|
|
||||||
ic.SpawnVM()
|
|
||||||
for i := range args {
|
|
||||||
ic.VM.Estack().PushVal(args[i])
|
|
||||||
}
|
|
||||||
|
|
||||||
var err error
|
|
||||||
func() {
|
|
||||||
defer func() {
|
|
||||||
if r := recover(); r != nil {
|
|
||||||
err = fmt.Errorf("panic: %v", r)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
err = verifyFunc(ic)
|
|
||||||
}()
|
|
||||||
|
|
||||||
if isErr {
|
|
||||||
require.Error(t, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.Equal(t, 1, ic.VM.Estack().Len())
|
|
||||||
require.Equal(t, result, ic.VM.Estack().Pop().Value().(bool))
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := []byte("test message")
|
|
||||||
|
|
||||||
t.Run("success", func(t *testing.T) {
|
|
||||||
sign := priv.Sign(msg)
|
|
||||||
runCase(t, false, true, sign, priv.PublicKey().Bytes(), msg)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("signed interop item", func(t *testing.T) {
|
|
||||||
tx := transaction.New(netmode.UnitTestNet, []byte{0, 1, 2}, 1)
|
|
||||||
msg := tx.GetSignedPart()
|
|
||||||
sign := priv.Sign(msg)
|
|
||||||
runCase(t, false, true, sign, priv.PublicKey().Bytes(), stackitem.NewInterop(tx))
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("signed script container", func(t *testing.T) {
|
|
||||||
tx := transaction.New(netmode.UnitTestNet, []byte{0, 1, 2}, 1)
|
|
||||||
msg := tx.GetSignedPart()
|
|
||||||
sign := priv.Sign(msg)
|
|
||||||
ic.Container = tx
|
|
||||||
runCase(t, false, true, sign, priv.PublicKey().Bytes(), stackitem.Null{})
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("missing arguments", func(t *testing.T) {
|
|
||||||
runCase(t, true, false)
|
|
||||||
sign := priv.Sign(msg)
|
|
||||||
runCase(t, true, false, sign)
|
|
||||||
runCase(t, true, false, sign, priv.PublicKey().Bytes())
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("invalid signature", func(t *testing.T) {
|
|
||||||
sign := priv.Sign(msg)
|
|
||||||
sign[0] = ^sign[0]
|
|
||||||
runCase(t, false, false, sign, priv.PublicKey().Bytes(), msg)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("invalid public key", func(t *testing.T) {
|
|
||||||
sign := priv.Sign(msg)
|
|
||||||
pub := priv.PublicKey().Bytes()
|
|
||||||
pub[0] = 0xFF // invalid prefix
|
|
||||||
runCase(t, true, false, sign, pub, msg)
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("invalid message", func(t *testing.T) {
|
|
||||||
sign := priv.Sign(msg)
|
|
||||||
runCase(t, true, false, sign, priv.PublicKey().Bytes(),
|
|
||||||
stackitem.NewArray([]stackitem.Item{stackitem.NewByteArray(msg)}))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func initCHECKMULTISIG(isR1 bool, msg []byte, n int) ([]stackitem.Item, []stackitem.Item, map[string]*keys.PublicKey, error) {
|
func initCHECKMULTISIG(isR1 bool, msg []byte, n int) ([]stackitem.Item, []stackitem.Item, map[string]*keys.PublicKey, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ecdsaSecp256r1VerifyID = interopnames.ToID([]byte(interopnames.NeoCryptoVerifyWithECDsaSecp256r1))
|
|
||||||
ecdsaSecp256k1VerifyID = interopnames.ToID([]byte(interopnames.NeoCryptoVerifyWithECDsaSecp256k1))
|
|
||||||
ecdsaSecp256r1CheckMultisigID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1))
|
ecdsaSecp256r1CheckMultisigID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1))
|
||||||
ecdsaSecp256k1CheckMultisigID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckMultisigWithECDsaSecp256k1))
|
ecdsaSecp256k1CheckMultisigID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckMultisigWithECDsaSecp256k1))
|
||||||
neoCryptoCheckSigID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckSig))
|
neoCryptoCheckSigID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckSig))
|
||||||
)
|
)
|
||||||
|
|
||||||
var cryptoInterops = []interop.Function{
|
var cryptoInterops = []interop.Function{
|
||||||
{ID: ecdsaSecp256r1VerifyID, Func: ECDSASecp256r1Verify},
|
|
||||||
{ID: ecdsaSecp256k1VerifyID, Func: ECDSASecp256k1Verify},
|
|
||||||
{ID: ecdsaSecp256r1CheckMultisigID, Func: ECDSASecp256r1CheckMultisig},
|
{ID: ecdsaSecp256r1CheckMultisigID, Func: ECDSASecp256r1CheckMultisig},
|
||||||
{ID: ecdsaSecp256k1CheckMultisigID, Func: ECDSASecp256k1CheckMultisig},
|
{ID: ecdsaSecp256k1CheckMultisigID, Func: ECDSASecp256k1CheckMultisig},
|
||||||
{ID: neoCryptoCheckSigID, Func: ECDSASecp256r1CheckSig},
|
{ID: neoCryptoCheckSigID, Func: ECDSASecp256r1CheckSig},
|
||||||
|
|
|
@ -37,8 +37,6 @@ const (
|
||||||
SystemStorageGetReadOnlyContext = "System.Storage.GetReadOnlyContext"
|
SystemStorageGetReadOnlyContext = "System.Storage.GetReadOnlyContext"
|
||||||
SystemStoragePut = "System.Storage.Put"
|
SystemStoragePut = "System.Storage.Put"
|
||||||
SystemStorageAsReadOnly = "System.Storage.AsReadOnly"
|
SystemStorageAsReadOnly = "System.Storage.AsReadOnly"
|
||||||
NeoCryptoVerifyWithECDsaSecp256r1 = "Neo.Crypto.VerifyWithECDsaSecp256r1"
|
|
||||||
NeoCryptoVerifyWithECDsaSecp256k1 = "Neo.Crypto.VerifyWithECDsaSecp256k1"
|
|
||||||
NeoCryptoCheckMultisigWithECDsaSecp256r1 = "Neo.Crypto.CheckMultisigWithECDsaSecp256r1"
|
NeoCryptoCheckMultisigWithECDsaSecp256r1 = "Neo.Crypto.CheckMultisigWithECDsaSecp256r1"
|
||||||
NeoCryptoCheckMultisigWithECDsaSecp256k1 = "Neo.Crypto.CheckMultisigWithECDsaSecp256k1"
|
NeoCryptoCheckMultisigWithECDsaSecp256k1 = "Neo.Crypto.CheckMultisigWithECDsaSecp256k1"
|
||||||
NeoCryptoCheckSig = "Neo.Crypto.CheckSig"
|
NeoCryptoCheckSig = "Neo.Crypto.CheckSig"
|
||||||
|
@ -80,8 +78,6 @@ var names = []string{
|
||||||
SystemStorageGetReadOnlyContext,
|
SystemStorageGetReadOnlyContext,
|
||||||
SystemStoragePut,
|
SystemStoragePut,
|
||||||
SystemStorageAsReadOnly,
|
SystemStorageAsReadOnly,
|
||||||
NeoCryptoVerifyWithECDsaSecp256r1,
|
|
||||||
NeoCryptoVerifyWithECDsaSecp256k1,
|
|
||||||
NeoCryptoCheckMultisigWithECDsaSecp256r1,
|
NeoCryptoCheckMultisigWithECDsaSecp256r1,
|
||||||
NeoCryptoCheckMultisigWithECDsaSecp256k1,
|
NeoCryptoCheckMultisigWithECDsaSecp256k1,
|
||||||
NeoCryptoCheckSig,
|
NeoCryptoCheckSig,
|
||||||
|
|
|
@ -75,10 +75,6 @@ var systemInterops = []interop.Function{
|
||||||
}
|
}
|
||||||
|
|
||||||
var neoInterops = []interop.Function{
|
var neoInterops = []interop.Function{
|
||||||
{Name: interopnames.NeoCryptoVerifyWithECDsaSecp256r1, Func: crypto.ECDSASecp256r1Verify,
|
|
||||||
Price: fee.ECDSAVerifyPrice, ParamCount: 3},
|
|
||||||
{Name: interopnames.NeoCryptoVerifyWithECDsaSecp256k1, Func: crypto.ECDSASecp256k1Verify,
|
|
||||||
Price: fee.ECDSAVerifyPrice, ParamCount: 3},
|
|
||||||
{Name: interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1, Func: crypto.ECDSASecp256r1CheckMultisig, Price: 0, ParamCount: 3},
|
{Name: interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1, Func: crypto.ECDSASecp256r1CheckMultisig, Price: 0, ParamCount: 3},
|
||||||
{Name: interopnames.NeoCryptoCheckMultisigWithECDsaSecp256k1, Func: crypto.ECDSASecp256k1CheckMultisig, Price: 0, ParamCount: 3},
|
{Name: interopnames.NeoCryptoCheckMultisigWithECDsaSecp256k1, Func: crypto.ECDSASecp256k1CheckMultisig, Price: 0, ParamCount: 3},
|
||||||
{Name: interopnames.NeoCryptoCheckSig, Func: crypto.ECDSASecp256r1CheckSig, Price: fee.ECDSAVerifyPrice, ParamCount: 2},
|
{Name: interopnames.NeoCryptoCheckSig, Func: crypto.ECDSASecp256r1CheckSig, Price: fee.ECDSAVerifyPrice, ParamCount: 2},
|
||||||
|
|
|
@ -2,9 +2,12 @@ package native
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
"math"
|
||||||
|
"math/big"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
"github.com/nspcc-dev/neo-go/pkg/vm/stackitem"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -39,3 +42,81 @@ func TestRIPEMD160(t *testing.T) {
|
||||||
require.Equal(t, "213492c0c6fc5d61497cf17249dd31cd9964b8a3", hex.EncodeToString(c.ripemd160(ic, []stackitem.Item{stackitem.NewByteArray([]byte{1, 0})}).Value().([]byte)))
|
require.Equal(t, "213492c0c6fc5d61497cf17249dd31cd9964b8a3", hex.EncodeToString(c.ripemd160(ic, []stackitem.Item{stackitem.NewByteArray([]byte{1, 0})}).Value().([]byte)))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCryptoLibVerifyWithECDsa(t *testing.T) {
|
||||||
|
t.Run("R1", func(t *testing.T) {
|
||||||
|
testECDSAVerify(t, Secp256r1)
|
||||||
|
})
|
||||||
|
t.Run("K1", func(t *testing.T) {
|
||||||
|
testECDSAVerify(t, Secp256k1)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func testECDSAVerify(t *testing.T, curve NamedCurve) {
|
||||||
|
var (
|
||||||
|
priv *keys.PrivateKey
|
||||||
|
err error
|
||||||
|
c = newCrypto()
|
||||||
|
ic = &interop.Context{VM: vm.New()}
|
||||||
|
actual stackitem.Item
|
||||||
|
)
|
||||||
|
switch curve {
|
||||||
|
case Secp256k1:
|
||||||
|
priv, err = keys.NewSecp256k1PrivateKey()
|
||||||
|
case Secp256r1:
|
||||||
|
priv, err = keys.NewPrivateKey()
|
||||||
|
default:
|
||||||
|
t.Fatal("unknown curve")
|
||||||
|
}
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
runCase := func(t *testing.T, isErr bool, result interface{}, args ...interface{}) {
|
||||||
|
argsArr := make([]stackitem.Item, len(args))
|
||||||
|
for i := range args {
|
||||||
|
argsArr[i] = stackitem.Make(args[i])
|
||||||
|
}
|
||||||
|
if isErr {
|
||||||
|
require.Panics(t, func() {
|
||||||
|
_ = c.verifyWithECDsa(ic, argsArr)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
require.NotPanics(t, func() {
|
||||||
|
actual = c.verifyWithECDsa(ic, argsArr)
|
||||||
|
})
|
||||||
|
require.Equal(t, stackitem.Make(result), actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg := []byte("test message")
|
||||||
|
sign := priv.Sign(msg)
|
||||||
|
|
||||||
|
t.Run("bad message item", func(t *testing.T) {
|
||||||
|
runCase(t, true, false, stackitem.NewInterop("cheburek"), priv.PublicKey().Bytes(), sign, int64(curve))
|
||||||
|
})
|
||||||
|
t.Run("bad pubkey item", func(t *testing.T) {
|
||||||
|
runCase(t, true, false, msg, stackitem.NewInterop("cheburek"), sign, int64(curve))
|
||||||
|
})
|
||||||
|
t.Run("bad pubkey bytes", func(t *testing.T) {
|
||||||
|
runCase(t, true, false, msg, []byte{1, 2, 3}, sign, int64(curve))
|
||||||
|
})
|
||||||
|
t.Run("bad signature item", func(t *testing.T) {
|
||||||
|
runCase(t, true, false, msg, priv.PublicKey().Bytes(), stackitem.NewInterop("cheburek"), int64(curve))
|
||||||
|
})
|
||||||
|
t.Run("bad curve item", func(t *testing.T) {
|
||||||
|
runCase(t, true, false, msg, priv.PublicKey().Bytes(), sign, stackitem.NewInterop("cheburek"))
|
||||||
|
})
|
||||||
|
t.Run("bad curve value", func(t *testing.T) {
|
||||||
|
runCase(t, true, false, msg, priv.PublicKey().Bytes(), sign, new(big.Int).Add(big.NewInt(math.MaxInt64), big.NewInt(1)))
|
||||||
|
})
|
||||||
|
t.Run("unknown curve", func(t *testing.T) {
|
||||||
|
runCase(t, true, false, msg, priv.PublicKey().Bytes(), sign, int64(123))
|
||||||
|
})
|
||||||
|
t.Run("invalid signature", func(t *testing.T) {
|
||||||
|
s := priv.Sign(msg)
|
||||||
|
s[0] = ^s[0]
|
||||||
|
runCase(t, false, false, s, priv.PublicKey().Bytes(), msg, int64(curve))
|
||||||
|
})
|
||||||
|
t.Run("success", func(t *testing.T) {
|
||||||
|
runCase(t, false, true, msg, priv.PublicKey().Bytes(), sign, int64(curve))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// coordLen is the number of bytes in serialized X or Y coordinate.
|
// coordLen is the number of bytes in serialized X or Y coordinate.
|
||||||
|
@ -317,8 +316,7 @@ func (p *PublicKey) GetVerificationScript() []byte {
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
emit.Bytes(buf.BinWriter, b)
|
emit.Bytes(buf.BinWriter, b)
|
||||||
emit.Opcodes(buf.BinWriter, opcode.PUSHNULL)
|
emit.Syscall(buf.BinWriter, interopnames.NeoCryptoCheckSig)
|
||||||
emit.Syscall(buf.BinWriter, interopnames.NeoCryptoVerifyWithECDsaSecp256r1)
|
|
||||||
|
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ func TestPubkeyToAddress(t *testing.T) {
|
||||||
pubKey, err := NewPublicKeyFromString("031ee4e73a17d8f76dc02532e2620bcb12425b33c0c9f9694cc2caa8226b68cad4")
|
pubKey, err := NewPublicKeyFromString("031ee4e73a17d8f76dc02532e2620bcb12425b33c0c9f9694cc2caa8226b68cad4")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
actual := pubKey.Address()
|
actual := pubKey.Address()
|
||||||
expected := "NcKJdJTEDeCSV9BJAKWWxkBMcHTeVnSzJo"
|
expected := "NWmVWWvFA6RxvTs4kgY1NnwTXeLYwWxPb1"
|
||||||
require.Equal(t, expected, actual)
|
require.Equal(t, expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,18 +8,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/interop/neogointernal"
|
"github.com/nspcc-dev/neo-go/pkg/interop/neogointernal"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ECDsaSecp256r1Verify checks that sig is correct msg's signature for a given pub
|
|
||||||
// (serialized public key). It uses `Neo.Crypto.VerifyWithECDsaSecp256r1` syscall.
|
|
||||||
func ECDsaSecp256r1Verify(msg []byte, pub interop.PublicKey, sig interop.Signature) bool {
|
|
||||||
return neogointernal.Syscall3("Neo.Crypto.VerifyWithECDsaSecp256r1", msg, pub, sig).(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ECDsaSecp256k1Verify checks that sig is correct msg's signature for a given pub
|
|
||||||
// (serialized public key). It uses `Neo.Crypto.VerifyWithECDsaSecp256k1` syscall.
|
|
||||||
func ECDsaSecp256k1Verify(msg []byte, pub interop.PublicKey, sig interop.Signature) bool {
|
|
||||||
return neogointernal.Syscall3("Neo.Crypto.VerifyWithECDsaSecp256k1", msg, pub, sig).(bool)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ECDSASecp256r1CheckMultisig checks multiple ECDSA signatures at once. It uses
|
// ECDSASecp256r1CheckMultisig checks multiple ECDSA signatures at once. It uses
|
||||||
// `Neo.Crypto.CheckMultisigWithECDsaSecp256r1` syscall.
|
// `Neo.Crypto.CheckMultisigWithECDsaSecp256r1` syscall.
|
||||||
func ECDSASecp256r1CheckMultisig(msg []byte, pubs []interop.PublicKey, sigs []interop.Signature) bool {
|
func ECDSASecp256r1CheckMultisig(msg []byte, pubs []interop.PublicKey, sigs []interop.Signature) bool {
|
||||||
|
|
|
@ -1113,7 +1113,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
||||||
name: "getnep17transfers_invalid_params_error 2",
|
name: "getnep17transfers_invalid_params_error 2",
|
||||||
invoke: func(c *Client) (interface{}, error) {
|
invoke: func(c *Client) (interface{}, error) {
|
||||||
var stop uint32
|
var stop uint32
|
||||||
return c.GetNEP17Transfers("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", nil, &stop, nil, nil)
|
return c.GetNEP17Transfers("NTh9TnZTstvAePEYWDGLLxidBikJE24uTo", nil, &stop, nil, nil)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1121,7 +1121,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
||||||
invoke: func(c *Client) (interface{}, error) {
|
invoke: func(c *Client) (interface{}, error) {
|
||||||
var start uint32
|
var start uint32
|
||||||
var limit int
|
var limit int
|
||||||
return c.GetNEP17Transfers("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", &start, nil, &limit, nil)
|
return c.GetNEP17Transfers("NTh9TnZTstvAePEYWDGLLxidBikJE24uTo", &start, nil, &limit, nil)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1129,7 +1129,7 @@ var rpcClientErrorCases = map[string][]rpcClientErrorCase{
|
||||||
invoke: func(c *Client) (interface{}, error) {
|
invoke: func(c *Client) (interface{}, error) {
|
||||||
var start, stop uint32
|
var start, stop uint32
|
||||||
var page int
|
var page int
|
||||||
return c.GetNEP17Transfers("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc", &start, &stop, nil, &page)
|
return c.GetNEP17Transfers("NTh9TnZTstvAePEYWDGLLxidBikJE24uTo", &start, &stop, nil, &page)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@ package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/base64"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/testchain"
|
"github.com/nspcc-dev/neo-go/internal/testchain"
|
||||||
|
@ -139,8 +139,10 @@ func TestAddNetworkFee(t *testing.T) {
|
||||||
priv := testchain.PrivateKeyByID(0)
|
priv := testchain.PrivateKeyByID(0)
|
||||||
acc1 := wallet.NewAccountFromPrivateKey(priv)
|
acc1 := wallet.NewAccountFromPrivateKey(priv)
|
||||||
acc1.Contract.Deployed = true
|
acc1.Contract.Deployed = true
|
||||||
acc1.Contract.Script, _ = hex.DecodeString(verifyContractAVM)
|
acc1.Contract.Script, err = base64.StdEncoding.DecodeString(verifyContractAVM)
|
||||||
h, _ := util.Uint160DecodeStringLE(verifyContractHash)
|
require.NoError(t, err)
|
||||||
|
h, err := util.Uint160DecodeStringLE(verifyContractHash)
|
||||||
|
require.NoError(t, err)
|
||||||
tx.ValidUntilBlock = chain.BlockHeight() + 10
|
tx.ValidUntilBlock = chain.BlockHeight() + 10
|
||||||
|
|
||||||
t.Run("Valid", func(t *testing.T) {
|
t.Run("Valid", func(t *testing.T) {
|
||||||
|
|
|
@ -59,13 +59,13 @@ type rpcTestCase struct {
|
||||||
check func(t *testing.T, e *executor, result interface{})
|
check func(t *testing.T, e *executor, result interface{})
|
||||||
}
|
}
|
||||||
|
|
||||||
const testContractHash = "500858b96054d3c302078882c30e76915aac1c83"
|
const testContractHash = "1e1c3024bd955ff3baf7cb92e3b7608c7bb3712b"
|
||||||
const deploymentTxHash = "e5503038c2cd602c100690e266b75e2a9d3dda90a63791fd5ab3008ff053eaae"
|
const deploymentTxHash = "9b14d575ae0f45a4e2765929a28a118693428edb8143615cc2ae58d5039d1c38"
|
||||||
const genesisBlockHash = "9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5"
|
const genesisBlockHash = "9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5"
|
||||||
|
|
||||||
const verifyContractHash = "03ffc0897543b9b709e0f8cab4a7682dae0ba943"
|
const verifyContractHash = "5bb4bac40e961e334ba7bd36d2496010f67e246e"
|
||||||
const verifyContractAVM = "570300412d51083021700c14aa8acf859d4fe402b34e673f2156821796a488ebdb30716813cedb2869db289740"
|
const verifyContractAVM = "VwMAQS1RCDAhcAwUVVQtU+0PVUb61E1umZEoZwIvzl7bMHFoE87bKGnbKJdA"
|
||||||
const testVerifyContractAVM = "VwcADBQBDAMOBQYMDQIODw0DDgcJAAAAANswcGgRVUH4J+yMIaonBwAAABFADBQNDwMCCQACAQMHAwQFAgEADgYMCdswcWkRVUH4J+yMIaonBwAAABJAE0A="
|
const invokescriptContractAVM = "VwcADBQBDAMOBQYMDQIODw0DDgcJAAAAANswcGhB+CfsjCGqJgQRQAwUDQ8DAgkAAgEDBwMEBQIBAA4GDAnbMHFpQfgn7IwhqiYEEkATQA=="
|
||||||
|
|
||||||
var rpcTestCases = map[string][]rpcTestCase{
|
var rpcTestCases = map[string][]rpcTestCase{
|
||||||
"getapplicationlog": {
|
"getapplicationlog": {
|
||||||
|
@ -743,8 +743,8 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "positive, good witness",
|
name: "positive, good witness",
|
||||||
// script is base64-encoded `test_verify.avm` representation, hashes are hex-encoded LE bytes of hashes used in the contract with `0x` prefix
|
// script is base64-encoded `invokescript_contract.avm` representation, hashes are hex-encoded LE bytes of hashes used in the contract with `0x` prefix
|
||||||
params: fmt.Sprintf(`["%s",["0x0000000009070e030d0f0e020d0c06050e030c01","0x090c060e00010205040307030102000902030f0d"]]`, testVerifyContractAVM),
|
params: fmt.Sprintf(`["%s",["0x0000000009070e030d0f0e020d0c06050e030c01","0x090c060e00010205040307030102000902030f0d"]]`, invokescriptContractAVM),
|
||||||
result: func(e *executor) interface{} { return &result.Invoke{} },
|
result: func(e *executor) interface{} { return &result.Invoke{} },
|
||||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||||
res, ok := inv.(*result.Invoke)
|
res, ok := inv.(*result.Invoke)
|
||||||
|
@ -756,7 +756,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "positive, bad witness of second hash",
|
name: "positive, bad witness of second hash",
|
||||||
params: fmt.Sprintf(`["%s",["0x0000000009070e030d0f0e020d0c06050e030c01"]]`, testVerifyContractAVM),
|
params: fmt.Sprintf(`["%s",["0x0000000009070e030d0f0e020d0c06050e030c01"]]`, invokescriptContractAVM),
|
||||||
result: func(e *executor) interface{} { return &result.Invoke{} },
|
result: func(e *executor) interface{} { return &result.Invoke{} },
|
||||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||||
res, ok := inv.(*result.Invoke)
|
res, ok := inv.(*result.Invoke)
|
||||||
|
@ -768,7 +768,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "positive, no good hashes",
|
name: "positive, no good hashes",
|
||||||
params: fmt.Sprintf(`["%s"]`, testVerifyContractAVM),
|
params: fmt.Sprintf(`["%s"]`, invokescriptContractAVM),
|
||||||
result: func(e *executor) interface{} { return &result.Invoke{} },
|
result: func(e *executor) interface{} { return &result.Invoke{} },
|
||||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||||
res, ok := inv.(*result.Invoke)
|
res, ok := inv.(*result.Invoke)
|
||||||
|
@ -780,7 +780,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "positive, bad hashes witness",
|
name: "positive, bad hashes witness",
|
||||||
params: fmt.Sprintf(`["%s",["0x0000000009070e030d0f0e020d0c06050e030c02"]]`, testVerifyContractAVM),
|
params: fmt.Sprintf(`["%s",["0x0000000009070e030d0f0e020d0c06050e030c02"]]`, invokescriptContractAVM),
|
||||||
result: func(e *executor) interface{} { return &result.Invoke{} },
|
result: func(e *executor) interface{} { return &result.Invoke{} },
|
||||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||||
res, ok := inv.(*result.Invoke)
|
res, ok := inv.(*result.Invoke)
|
||||||
|
@ -817,7 +817,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
assert.NotNil(t, res.Script)
|
assert.NotNil(t, res.Script)
|
||||||
assert.Equal(t, "HALT", res.State)
|
assert.Equal(t, "HALT", res.State)
|
||||||
assert.NotEqual(t, 0, res.GasConsumed)
|
assert.NotEqual(t, 0, res.GasConsumed)
|
||||||
assert.Equal(t, true, res.Stack[0].Value().(bool))
|
assert.Equal(t, true, res.Stack[0].Value().(bool), fmt.Sprintf("check address in verification_contract.go: expected %s", testchain.PrivateKeyByID(0).Address()))
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -865,12 +865,12 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
"sendrawtransaction": {
|
"sendrawtransaction": {
|
||||||
{
|
{
|
||||||
name: "positive",
|
name: "positive",
|
||||||
params: `["AAsAAACAlpgAAAAAACYcEwAAAAAAsAQAAAGqis+FnU/kArNOZz8hVoIXlqSI6wEAXQMA6HZIFwAAAAwUeLpMJACf5RDhNsmZWi4FIV4b5NwMFKqKz4WdT+QCs05nPyFWgheWpIjrE8AMCHRyYW5zZmVyDBQlBZ7LSHjTqHX5HFHO3tMw1Fdf3kFifVtSOAFCDEDqL1as9/ZGKdySLWWmAXbzljr9S3wlnyAXo6UTk0b46lRwRiRZCDKst3lAaaspg93IYrA7ajPUQozUxFy8CUHCKQwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CC0GVRA14"]`,
|
params: `["ADQSAADA2KcAAAAAABDiEgAAAAAAgBYAAAFVVC1T7Q9VRvrUTW6ZkShnAi/OXgEAYBDAAwDodkgXAAAADBRdSe/t0S4+BgGLRljbEKiXX8gLTgwUVVQtU+0PVUb61E1umZEoZwIvzl4UwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQFCDEAppqgOf7RZvrS+uOVzVNlcQAQnyujtzHzv9/Za+FFkxWFd8mZ6AvWnFXAL0W5NafW4xyP7Kp/qgWCmZrHINaLkKAwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CQXR0dqo="]`,
|
||||||
result: func(e *executor) interface{} { return &result.RelayResult{} },
|
result: func(e *executor) interface{} { return &result.RelayResult{} },
|
||||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||||
res, ok := inv.(*result.RelayResult)
|
res, ok := inv.(*result.RelayResult)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
expectedHash, err := util.Uint256DecodeStringLE("ab5573cfc8d70774f04aa7d5521350cfc1aa1239c44c24e490e139408cd46a57")
|
expectedHash, err := util.Uint256DecodeStringLE("3b133d0c2912da4f99680ae3a5f0e178bc761f2c360662a1fabbe1a8dbe309ea")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Equal(t, expectedHash, res.Hash)
|
assert.Equal(t, expectedHash, res.Hash)
|
||||||
},
|
},
|
||||||
|
@ -1598,7 +1598,7 @@ func checkNep17Balances(t *testing.T, e *executor, acc interface{}) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Asset: e.chain.UtilityTokenHash(),
|
Asset: e.chain.UtilityTokenHash(),
|
||||||
Amount: "78994294100",
|
Amount: "78994302340",
|
||||||
LastUpdated: 8,
|
LastUpdated: 8,
|
||||||
}},
|
}},
|
||||||
Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(),
|
Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(),
|
||||||
|
|
BIN
pkg/rpc/server/testdata/test_verify.avm
vendored
BIN
pkg/rpc/server/testdata/test_verify.avm
vendored
Binary file not shown.
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
|
@ -6,9 +6,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Verify is a verification contract method.
|
// Verify is a verification contract method.
|
||||||
// It returns true iff it is signed by NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc (id-0 private key from testchain).
|
// It returns true iff it is signed by NTh9TnZTstvAePEYWDGLLxidBikJE24uTo (id-0 private key from testchain).
|
||||||
func Verify() bool {
|
func Verify() bool {
|
||||||
tx := runtime.GetScriptContainer()
|
tx := runtime.GetScriptContainer()
|
||||||
addr := util.FromAddress("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc")
|
addr := util.FromAddress("NTh9TnZTstvAePEYWDGLLxidBikJE24uTo")
|
||||||
return util.Equals(string(tx.Sender), string(addr))
|
return util.Equals(string(tx.Sender), string(addr))
|
||||||
}
|
}
|
||||||
|
|
66
pkg/services/notary/testdata/notary1.json
vendored
66
pkg/services/notary/testdata/notary1.json
vendored
|
@ -1 +1,65 @@
|
||||||
{"version":"3.0","accounts":[{"address":"NSbjd7dSePTZ6QpADAuM5722QpBmL5124W","key":"6PYVWTfkNCYvyQhyFLHH5dyRyT6jSi8u8Z8kn122PACfsDWi4QgkGm8FyW","label":"NotaryNode1","contract":{"script":"DCEDm5PmbOfVPmYXTSVW903XnOhhNBTsF9oDlVYusIH/ui0LQZVEDXg=","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false},{"address":"NisSvmSd2Lp28tjr8EqCZB5ahHDvBExo2j","key":"6PYLvgnZNwhiiZPiSCw3B3bHSFwbSXgh3MkGt4gL69MD8Sw7LMnuUgM9KQ","label":"three","contract":{"script":"DCEDHRWEIGXHCwUU2Fc7B0qrYPezXR0sfdEduRExyzIKVC8LQZVEDXg=","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false},{"address":"NRCCdGifyUWKnFotZhcgKpmxhhVJSJb94r","key":"6PYKXkuJ7G6bTj62bjy8fsBLF5okYNdAEBhKPCv8nmcALCtk2yPtBo835p","label":"four","contract":{"script":"DCECmUfs/gqKHd3AdJm5+Ev6zkubV8pP8DZzgu8+t5WdphILQZVEDXg=","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}}
|
{
|
||||||
|
"scrypt" : {
|
||||||
|
"n" : 16384,
|
||||||
|
"r" : 8,
|
||||||
|
"p" : 8
|
||||||
|
},
|
||||||
|
"accounts" : [
|
||||||
|
{
|
||||||
|
"contract" : {
|
||||||
|
"parameters" : [
|
||||||
|
{
|
||||||
|
"type" : "Signature",
|
||||||
|
"name" : "parameter0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"deployed" : false,
|
||||||
|
"script" : "DCEDm5PmbOfVPmYXTSVW903XnOhhNBTsF9oDlVYusIH/ui1BdHR2qg=="
|
||||||
|
},
|
||||||
|
"label" : "NotaryNode1",
|
||||||
|
"address" : "NS6vb4uE8wdQfcQbFcRY7yquSbwbVcMSV3",
|
||||||
|
"isdefault" : false,
|
||||||
|
"lock" : false,
|
||||||
|
"key" : "6PYMGBef95jMZJTQcH9ZP5PuecWa2H86HFbdnfe7VQs8uPZ3S6pu4D5NpP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contract" : {
|
||||||
|
"script" : "DCEDHRWEIGXHCwUU2Fc7B0qrYPezXR0sfdEduRExyzIKVC9BdHR2qg==",
|
||||||
|
"deployed" : false,
|
||||||
|
"parameters" : [
|
||||||
|
{
|
||||||
|
"name" : "parameter0",
|
||||||
|
"type" : "Signature"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"label" : "three",
|
||||||
|
"address" : "NakELwR1i6brB7EmYLc6yPbvk78Qi5Qbpi",
|
||||||
|
"isdefault" : false,
|
||||||
|
"lock" : false,
|
||||||
|
"key" : "6PYLm6kse9FVpKoBbhYYSFHhFUUL2bZYePU95x7Ncknu798WEHYmTuUijR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"contract" : {
|
||||||
|
"parameters" : [
|
||||||
|
{
|
||||||
|
"name" : "parameter0",
|
||||||
|
"type" : "Signature"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"deployed" : false,
|
||||||
|
"script" : "DCECmUfs/gqKHd3AdJm5+Ev6zkubV8pP8DZzgu8+t5WdphJBdHR2qg=="
|
||||||
|
},
|
||||||
|
"key" : "6PYWBWehojbBn8U2XWcXxuWqPrnp9qwQ5rD3RKQza1iR5ZBCPHXxCQonYm",
|
||||||
|
"isdefault" : false,
|
||||||
|
"lock" : false,
|
||||||
|
"address" : "NLWXE5CMEqJzEVtscF4BoTvSbiBr1FwtBb",
|
||||||
|
"label" : "four"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra" : {
|
||||||
|
"Tokens" : null
|
||||||
|
},
|
||||||
|
"version" : "3.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
31
pkg/services/notary/testdata/notary2.json
vendored
31
pkg/services/notary/testdata/notary2.json
vendored
|
@ -1 +1,30 @@
|
||||||
{"version":"3.0","accounts":[{"address":"NfFcJvWcHe8SSS92hNZhyQUJ6cg3pb36Tf","key":"6PYU2QoD52Xt9Z6QmNGUJWn89qUD1W6QqAL4Y8nfTWtTKvmVpQh8wsH6qY","label":"NotaryNode2","contract":{"script":"DCECIcKj0GFdv4b1NZrw9X6zLNLWzmNKAxtw6olIMZxpPRQLQZVEDXg=","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}}
|
{
|
||||||
|
"scrypt" : {
|
||||||
|
"r" : 8,
|
||||||
|
"p" : 8,
|
||||||
|
"n" : 16384
|
||||||
|
},
|
||||||
|
"version" : "3.0",
|
||||||
|
"extra" : {
|
||||||
|
"Tokens" : null
|
||||||
|
},
|
||||||
|
"accounts" : [
|
||||||
|
{
|
||||||
|
"address" : "NYt1oLCMMvqxnAVMJCSk87kZTP693GxK11",
|
||||||
|
"key" : "6PYWejAoqoF4JT5P9N3EcqC5tRC1MXx2gZ1R2WWryjDUH1bMAo3Bd68nCo",
|
||||||
|
"lock" : false,
|
||||||
|
"isdefault" : false,
|
||||||
|
"contract" : {
|
||||||
|
"parameters" : [
|
||||||
|
{
|
||||||
|
"name" : "parameter0",
|
||||||
|
"type" : "Signature"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"deployed" : false,
|
||||||
|
"script" : "DCECIcKj0GFdv4b1NZrw9X6zLNLWzmNKAxtw6olIMZxpPRRBdHR2qg=="
|
||||||
|
},
|
||||||
|
"label" : "NotaryNode2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
31
pkg/services/oracle/testdata/oracle1.json
vendored
31
pkg/services/oracle/testdata/oracle1.json
vendored
|
@ -1 +1,30 @@
|
||||||
{"version":"3.0","accounts":[{"address":"NMy1PN9GCdGc26YFG7JruYg7UBStw2pPKN","key":"6PYML6dDTMXJBD7ywRwiCAhseCPToWkMfvPUViuxiXM6s5oi7ggf4ho3AK","label":"","contract":{"script":"DCEDNxK01e1DnGA+TiGU3H4DKUuGliSz89/NuZCbVvA2u0wLQZVEDXg=","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}}
|
{
|
||||||
|
"accounts" : [
|
||||||
|
{
|
||||||
|
"address" : "NPcxgUcZorwb1njfRGL7JEyc6SsTku42ek",
|
||||||
|
"key" : "6PYPy72Gnoif27u9Uy5r2sqMwTTYMLRBGwPcJmB1GP1FTPp4U3M9fZVdtg",
|
||||||
|
"lock" : false,
|
||||||
|
"isdefault" : false,
|
||||||
|
"contract" : {
|
||||||
|
"parameters" : [
|
||||||
|
{
|
||||||
|
"type" : "Signature",
|
||||||
|
"name" : "parameter0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"script" : "DCEDNxK01e1DnGA+TiGU3H4DKUuGliSz89/NuZCbVvA2u0xBdHR2qg==",
|
||||||
|
"deployed" : false
|
||||||
|
},
|
||||||
|
"label" : ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"extra" : {
|
||||||
|
"Tokens" : null
|
||||||
|
},
|
||||||
|
"version" : "3.0",
|
||||||
|
"scrypt" : {
|
||||||
|
"n" : 16384,
|
||||||
|
"p" : 8,
|
||||||
|
"r" : 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
31
pkg/services/oracle/testdata/oracle2.json
vendored
31
pkg/services/oracle/testdata/oracle2.json
vendored
|
@ -1 +1,30 @@
|
||||||
{"version":"3.0","accounts":[{"address":"NU7QxQXULbmZU7kaWUaeF3r9v3zimU42bV","key":"6PYKv77p5wihN64XaPB5Nbci1sCLV5CrzSu8GKv7UHXHRtytfLt8zfrMgT","label":"","contract":{"script":"DCEDEXzwIl4Jhvsj98GYIPFFiedeb1QdP8T79uSBSDNsiswLQZVEDXg=","parameters":[{"name":"parameter0","type":"Signature"}],"deployed":false},"lock":false,"isdefault":false}],"scrypt":{"n":16384,"r":8,"p":8},"extra":{"Tokens":null}}
|
{
|
||||||
|
"version" : "3.0",
|
||||||
|
"extra" : {
|
||||||
|
"Tokens" : null
|
||||||
|
},
|
||||||
|
"accounts" : [
|
||||||
|
{
|
||||||
|
"isdefault" : false,
|
||||||
|
"label" : "",
|
||||||
|
"key" : "6PYTgfwm5kuahFNN391D6p21ivKrHpvr8Wnn1mBpMnavn6PxkK2prSsxye",
|
||||||
|
"address" : "NhSCnPJdgLdxnQaYHmW9A3WFLT9DiicBfK",
|
||||||
|
"lock" : false,
|
||||||
|
"contract" : {
|
||||||
|
"script" : "DCEDEXzwIl4Jhvsj98GYIPFFiedeb1QdP8T79uSBSDNsisxBdHR2qg==",
|
||||||
|
"deployed" : false,
|
||||||
|
"parameters" : [
|
||||||
|
{
|
||||||
|
"type" : "Signature",
|
||||||
|
"name" : "parameter0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"scrypt" : {
|
||||||
|
"p" : 8,
|
||||||
|
"n" : 16384,
|
||||||
|
"r" : 8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
verifyInteropID = interopnames.ToID([]byte(interopnames.NeoCryptoVerifyWithECDsaSecp256r1))
|
verifyInteropID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckSig))
|
||||||
multisigInteropID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1))
|
multisigInteropID = interopnames.ToID([]byte(interopnames.NeoCryptoCheckMultisigWithECDsaSecp256r1))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ func IsSignatureContract(script []byte) bool {
|
||||||
// ParseSignatureContract parses simple signature contract and returns
|
// ParseSignatureContract parses simple signature contract and returns
|
||||||
// public key.
|
// public key.
|
||||||
func ParseSignatureContract(script []byte) ([]byte, bool) {
|
func ParseSignatureContract(script []byte) ([]byte, bool) {
|
||||||
if len(script) != 41 {
|
if len(script) != 40 {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,10 +122,6 @@ func ParseSignatureContract(script []byte) ([]byte, bool) {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
pub := param
|
pub := param
|
||||||
instr, _, err = ctx.Next()
|
|
||||||
if err != nil || instr != opcode.PUSHNULL {
|
|
||||||
return nil, false
|
|
||||||
}
|
|
||||||
instr, param, err = ctx.Next()
|
instr, param, err = ctx.Next()
|
||||||
if err != nil || instr != opcode.SYSCALL || binary.LittleEndian.Uint32(param) != verifyInteropID {
|
if err != nil || instr != opcode.SYSCALL || binary.LittleEndian.Uint32(param) != verifyInteropID {
|
||||||
return nil, false
|
return nil, false
|
||||||
|
|
|
@ -16,12 +16,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func testSignatureContract() []byte {
|
func testSignatureContract() []byte {
|
||||||
prog := make([]byte, 41)
|
prog := make([]byte, 40)
|
||||||
prog[0] = byte(opcode.PUSHDATA1)
|
prog[0] = byte(opcode.PUSHDATA1)
|
||||||
prog[1] = 33
|
prog[1] = 33
|
||||||
prog[35] = byte(opcode.PUSHNULL)
|
prog[35] = byte(opcode.SYSCALL)
|
||||||
prog[36] = byte(opcode.SYSCALL)
|
binary.LittleEndian.PutUint32(prog[36:], verifyInteropID)
|
||||||
binary.LittleEndian.PutUint32(prog[37:], verifyInteropID)
|
|
||||||
return prog
|
return prog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ func TestIsSignatureContract(t *testing.T) {
|
||||||
|
|
||||||
t.Run("invalid interop ID", func(t *testing.T) {
|
t.Run("invalid interop ID", func(t *testing.T) {
|
||||||
prog := testSignatureContract()
|
prog := testSignatureContract()
|
||||||
binary.LittleEndian.PutUint32(prog[37:], ^verifyInteropID)
|
binary.LittleEndian.PutUint32(prog[36:], ^verifyInteropID)
|
||||||
assert.False(t, IsSignatureContract(prog))
|
assert.False(t, IsSignatureContract(prog))
|
||||||
assert.False(t, IsStandardContract(prog))
|
assert.False(t, IsStandardContract(prog))
|
||||||
})
|
})
|
||||||
|
@ -55,13 +54,6 @@ func TestIsSignatureContract(t *testing.T) {
|
||||||
assert.False(t, IsStandardContract(prog))
|
assert.False(t, IsStandardContract(prog))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("no PUSHNULL", func(t *testing.T) {
|
|
||||||
prog := testSignatureContract()
|
|
||||||
prog[35] = byte(opcode.PUSH1)
|
|
||||||
assert.False(t, IsSignatureContract(prog))
|
|
||||||
assert.False(t, IsStandardContract(prog))
|
|
||||||
})
|
|
||||||
|
|
||||||
t.Run("invalid length", func(t *testing.T) {
|
t.Run("invalid length", func(t *testing.T) {
|
||||||
prog := testSignatureContract()
|
prog := testSignatureContract()
|
||||||
prog = append(prog, 0)
|
prog = append(prog, 0)
|
||||||
|
|
|
@ -135,11 +135,11 @@ func convertPubs(t *testing.T, hexKeys []string) []*keys.PublicKey {
|
||||||
|
|
||||||
func compareFields(t *testing.T, tk keytestcases.Ktype, acc *Account) {
|
func compareFields(t *testing.T, tk keytestcases.Ktype, acc *Account) {
|
||||||
want, have := tk.Address, acc.Address
|
want, have := tk.Address, acc.Address
|
||||||
require.Equalf(t, want, have, "expected %s got %s", want, have)
|
require.Equalf(t, want, have, "expected address %s got %s", want, have)
|
||||||
want, have = tk.Wif, acc.wif
|
want, have = tk.Wif, acc.wif
|
||||||
require.Equalf(t, want, have, "expected %s got %s", want, have)
|
require.Equalf(t, want, have, "expected wif %s got %s", want, have)
|
||||||
want, have = tk.PublicKey, hex.EncodeToString(acc.publicKey)
|
want, have = tk.PublicKey, hex.EncodeToString(acc.publicKey)
|
||||||
require.Equalf(t, want, have, "expected %s got %s", want, have)
|
require.Equalf(t, want, have, "expected pub key %s got %s", want, have)
|
||||||
want, have = tk.PrivateKey, acc.privateKey.String()
|
want, have = tk.PrivateKey, acc.privateKey.String()
|
||||||
require.Equalf(t, want, have, "expected %s got %s", want, have)
|
require.Equalf(t, want, have, "expected priv key %s got %s", want, have)
|
||||||
}
|
}
|
||||||
|
|
8
pkg/wallet/testdata/wallet1.json
vendored
8
pkg/wallet/testdata/wallet1.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
|
"address": "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
|
14
pkg/wallet/testdata/wallet2.json
vendored
14
pkg/wallet/testdata/wallet2.json
vendored
|
@ -2,11 +2,11 @@
|
||||||
"version": "3.0",
|
"version": "3.0",
|
||||||
"accounts": [
|
"accounts": [
|
||||||
{
|
{
|
||||||
"address": "NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc",
|
"address": "NTh9TnZTstvAePEYWDGLLxidBikJE24uTo",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcILQZVEDXg=",
|
"script": "DCECs2Ir9AF73+MXxYrtX0x1PyBrfbiWBG+n13S7xL9/jcJBdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
"address": "NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY",
|
||||||
"key": "6PYN7LvaWqBNw7Xb7a52LSbPnP91kyuzYi3HncGvQwQoYAY2W8DncTgpux",
|
"key": "6PYL8Gnjsz4RBKX18jx5ZAQTDH7PKkZwEVjPKEkjNzCDNFE6TKZwaFLibL",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
"script": "EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw==",
|
||||||
|
@ -44,11 +44,11 @@
|
||||||
"isdefault": false
|
"isdefault": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"address": "NWvKSwutC8D6VKmmPxAEgFKx2NLvFhn8q5",
|
"address": "NUREbqw2kfbPgDeEz8Dac2QxntGGqqFMm7",
|
||||||
"key": "6PYKEHagXJ3mDLdga1FoyTGRtPdJgPz6Gb8sjEFwZvRu7ncD9PVZfHtMzL",
|
"key": "6PYXADog3RQCwKRhqQsobwZEFopdcCJuMfPosM9pXPaDWSguKvznLdpADk",
|
||||||
"label": "",
|
"label": "",
|
||||||
"contract": {
|
"contract": {
|
||||||
"script": "DCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4LQZVEDXg=",
|
"script": "DCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG5BdHR2qg==",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"name": "parameter0",
|
"name": "parameter0",
|
||||||
|
|
|
@ -186,14 +186,14 @@ func TestWalletGetChangeAddress(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sh := w1.GetChangeAddress()
|
sh := w1.GetChangeAddress()
|
||||||
// No default address, the first one is used.
|
// No default address, the first one is used.
|
||||||
expected, err := address.StringToUint160("NbTiM6h8r99kpRtb428XcsUk1TzKed2gTc")
|
expected, err := address.StringToUint160("NTh9TnZTstvAePEYWDGLLxidBikJE24uTo")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, expected, sh)
|
require.Equal(t, expected, sh)
|
||||||
w2, err := NewWalletFromFile("testdata/wallet2.json")
|
w2, err := NewWalletFromFile("testdata/wallet2.json")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
sh = w2.GetChangeAddress()
|
sh = w2.GetChangeAddress()
|
||||||
// Default address.
|
// Default address.
|
||||||
expected, err = address.StringToUint160("NWvKSwutC8D6VKmmPxAEgFKx2NLvFhn8q5")
|
expected, err = address.StringToUint160("NUREbqw2kfbPgDeEz8Dac2QxntGGqqFMm7")
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, expected, sh)
|
require.Equal(t, expected, sh)
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ func main() {
|
||||||
handleError("can't tranfser GAS", err)
|
handleError("can't tranfser GAS", err)
|
||||||
lastBlock = addBlock(bc, lastBlock, valScript, txMoveNeo, txMoveGas)
|
lastBlock = addBlock(bc, lastBlock, valScript, txMoveNeo, txMoveGas)
|
||||||
|
|
||||||
tx, contractHash, err := testchain.NewDeployTx(bc, "DumpContract", h, strings.NewReader(contract))
|
tx, contractHash, _, err := testchain.NewDeployTx(bc, "DumpContract", h, strings.NewReader(contract))
|
||||||
handleError("can't create deploy tx", err)
|
handleError("can't create deploy tx", err)
|
||||||
tx.NetworkFee = 10_000_000
|
tx.NetworkFee = 10_000_000
|
||||||
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
tx.ValidUntilBlock = bc.BlockHeight() + 1
|
||||||
|
|
Loading…
Reference in a new issue