forked from TrueCloudLab/neoneo-go
native: reduce callflag scope for Koblitz verification scripts
callflag.All is too wide. Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
parent
fb16891e2a
commit
fe292f3f39
1 changed files with 25 additions and 21 deletions
|
@ -1,6 +1,8 @@
|
||||||
package native_test
|
package native_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -166,7 +168,7 @@ func buildKoblitzVerificationScript(t *testing.T, pub *keys.PublicKey) []byte {
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.CAT) // this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
emit.Opcodes(vrf.BinWriter, opcode.CAT) // this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
||||||
// Continue construction of 'verifyWithECDsa' call.
|
// Continue construction of 'verifyWithECDsa' call.
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.All) // emit the call to 'verifyWithECDsa' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.NoneFlag) // emit the call to 'verifyWithECDsa' itself.
|
||||||
require.NoError(t, vrf.Err)
|
require.NoError(t, vrf.Err)
|
||||||
|
|
||||||
return vrf.Bytes()
|
return vrf.Bytes()
|
||||||
|
@ -189,7 +191,7 @@ func buildKoblitzVerificationScript(t *testing.T, pub *keys.PublicKey) []byte {
|
||||||
// 62 CAT
|
// 62 CAT
|
||||||
// 63 PUSH4
|
// 63 PUSH4
|
||||||
// 64 PACK
|
// 64 PACK
|
||||||
// 65 PUSH15
|
// 65 PUSH0
|
||||||
// 66 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
// 66 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
||||||
// 83 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 83 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 105 SYSCALL System.Contract.Call (627d5b52)
|
// 105 SYSCALL System.Contract.Call (627d5b52)
|
||||||
|
@ -223,7 +225,7 @@ func buildKoblitzVerificationScriptSimpleSingleHash(t *testing.T, pub *keys.Publ
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.CAT) // this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
emit.Opcodes(vrf.BinWriter, opcode.CAT) // this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
||||||
// Continue construction of 'verifyWithECDsa' call.
|
// Continue construction of 'verifyWithECDsa' call.
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.All) // emit the call to 'verifyWithECDsa' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.NoneFlag) // emit the call to 'verifyWithECDsa' itself.
|
||||||
require.NoError(t, vrf.Err)
|
require.NoError(t, vrf.Err)
|
||||||
|
|
||||||
return vrf.Bytes()
|
return vrf.Bytes()
|
||||||
|
@ -242,7 +244,7 @@ func buildKoblitzVerificationScriptSimpleSingleHash(t *testing.T, pub *keys.Publ
|
||||||
// 50 CAT
|
// 50 CAT
|
||||||
// 51 PUSH4
|
// 51 PUSH4
|
||||||
// 52 PACK
|
// 52 PACK
|
||||||
// 53 PUSH15
|
// 53 PUSH0
|
||||||
// 54 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
// 54 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
||||||
// 71 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 71 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 93 SYSCALL System.Contract.Call (627d5b52)
|
// 93 SYSCALL System.Contract.Call (627d5b52)
|
||||||
|
@ -279,7 +281,7 @@ func buildKoblitzVerificationScriptSimpleSingleHashStaticMagic(t *testing.T, pub
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.CAT) // this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
emit.Opcodes(vrf.BinWriter, opcode.CAT) // this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
||||||
// Continue construction of 'verifyWithECDsa' call.
|
// Continue construction of 'verifyWithECDsa' call.
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.All) // emit the call to 'verifyWithECDsa' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.NoneFlag) // emit the call to 'verifyWithECDsa' itself.
|
||||||
require.NoError(t, vrf.Err)
|
require.NoError(t, vrf.Err)
|
||||||
|
|
||||||
return vrf.Bytes()
|
return vrf.Bytes()
|
||||||
|
@ -298,7 +300,7 @@ func buildKoblitzVerificationScriptSimpleSingleHashStaticMagic(t *testing.T, pub
|
||||||
// 47 CAT
|
// 47 CAT
|
||||||
// 48 PUSH4
|
// 48 PUSH4
|
||||||
// 49 PACK
|
// 49 PACK
|
||||||
// 50 PUSH15
|
// 50 PUSH0
|
||||||
// 51 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
// 51 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
||||||
// 68 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 68 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 90 SYSCALL System.Contract.Call (627d5b52)
|
// 90 SYSCALL System.Contract.Call (627d5b52)
|
||||||
|
@ -336,10 +338,10 @@ func buildKoblitzVerificationScriptSimple(t *testing.T, pub *keys.PublicKey) []b
|
||||||
opcode.CAT, // concatenate network magic and transaction hash; this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
opcode.CAT, // concatenate network magic and transaction hash; this instruction will convert network magic to bytes using BigInteger rules of conversion.
|
||||||
opcode.PUSH1, // push 1 (the number of arguments of 'sha256' method of native CryptoLib).
|
opcode.PUSH1, // push 1 (the number of arguments of 'sha256' method of native CryptoLib).
|
||||||
opcode.PACK) // pack arguments for 'sha256' call.
|
opcode.PACK) // pack arguments for 'sha256' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "sha256", callflag.All) // emit the call to 'sha256' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "sha256", callflag.NoneFlag) // emit the call to 'sha256' itself.
|
||||||
// Continue construction of 'verifyWithECDsa' call.
|
// Continue construction of 'verifyWithECDsa' call.
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.All) // emit the call to 'verifyWithECDsa' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.NoneFlag) // emit the call to 'verifyWithECDsa' itself.
|
||||||
require.NoError(t, vrf.Err)
|
require.NoError(t, vrf.Err)
|
||||||
|
|
||||||
return vrf.Bytes()
|
return vrf.Bytes()
|
||||||
|
@ -358,13 +360,13 @@ func buildKoblitzVerificationScriptSimple(t *testing.T, pub *keys.PublicKey) []b
|
||||||
// 50 CAT
|
// 50 CAT
|
||||||
// 51 PUSH1
|
// 51 PUSH1
|
||||||
// 52 PACK
|
// 52 PACK
|
||||||
// 53 PUSH15
|
// 53 PUSH0
|
||||||
// 54 PUSHDATA1 736861323536 ("sha256")
|
// 54 PUSHDATA1 736861323536 ("sha256")
|
||||||
// 62 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 62 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 84 SYSCALL System.Contract.Call (627d5b52)
|
// 84 SYSCALL System.Contract.Call (627d5b52)
|
||||||
// 89 PUSH4
|
// 89 PUSH4
|
||||||
// 90 PACK
|
// 90 PACK
|
||||||
// 91 PUSH15
|
// 91 PUSH0
|
||||||
// 92 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
// 92 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
||||||
// 109 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 109 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 131 SYSCALL System.Contract.Call (627d5b52)
|
// 131 SYSCALL System.Contract.Call (627d5b52)
|
||||||
|
@ -437,10 +439,10 @@ func buildKoblitzVerificationScriptCompat(t *testing.T, pub *keys.PublicKey) []b
|
||||||
opcode.CAT, // concatenate network magic and transaction hash.
|
opcode.CAT, // concatenate network magic and transaction hash.
|
||||||
opcode.PUSH1, // push 1 (the number of arguments of 'sha256' method of native CryptoLib).
|
opcode.PUSH1, // push 1 (the number of arguments of 'sha256' method of native CryptoLib).
|
||||||
opcode.PACK) // pack arguments for 'sha256' call.
|
opcode.PACK) // pack arguments for 'sha256' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "sha256", callflag.All) // emit the call to 'sha256' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "sha256", callflag.NoneFlag) // emit the call to 'sha256' itself.
|
||||||
// Continue construction of 'verifyWithECDsa' call.
|
// Continue construction of 'verifyWithECDsa' call.
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
emit.Opcodes(vrf.BinWriter, opcode.PUSH4, opcode.PACK) // pack arguments for 'verifyWithECDsa' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.All) // emit the call to 'verifyWithECDsa' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, criptoLibH, "verifyWithECDsa", callflag.NoneFlag) // emit the call to 'verifyWithECDsa' itself.
|
||||||
require.NoError(t, vrf.Err)
|
require.NoError(t, vrf.Err)
|
||||||
|
|
||||||
return vrf.Bytes()
|
return vrf.Bytes()
|
||||||
|
@ -501,13 +503,13 @@ func buildKoblitzVerificationScriptCompat(t *testing.T, pub *keys.PublicKey) []b
|
||||||
// 100 CAT
|
// 100 CAT
|
||||||
// 101 PUSH1
|
// 101 PUSH1
|
||||||
// 102 PACK
|
// 102 PACK
|
||||||
// 103 PUSH15
|
// 103 PUSH0
|
||||||
// 104 PUSHDATA1 736861323536 ("sha256")
|
// 104 PUSHDATA1 736861323536 ("sha256")
|
||||||
// 112 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 112 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 134 SYSCALL System.Contract.Call (627d5b52)
|
// 134 SYSCALL System.Contract.Call (627d5b52)
|
||||||
// 139 PUSH4
|
// 139 PUSH4
|
||||||
// 140 PACK
|
// 140 PACK
|
||||||
// 141 PUSH15
|
// 141 PUSH0
|
||||||
// 142 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
// 142 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
||||||
// 159 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 159 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 181 SYSCALL System.Contract.Call (627d5b52)
|
// 181 SYSCALL System.Contract.Call (627d5b52)
|
||||||
|
@ -665,6 +667,8 @@ func TestCryptoLib_KoblitzMultisigVerificationScript(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(base64.StdEncoding.EncodeToString(vrfBytes))
|
||||||
|
|
||||||
// Add transaction to the chain. No error is expected on new block addition. Note, that this line performs
|
// Add transaction to the chain. No error is expected on new block addition. Note, that this line performs
|
||||||
// all those checks that are executed during transaction acceptance in the real network.
|
// all those checks that are executed during transaction acceptance in the real network.
|
||||||
e.AddNewBlock(t, tx)
|
e.AddNewBlock(t, tx)
|
||||||
|
@ -794,7 +798,7 @@ func buildKoblitzMultisigVerificationScript(t *testing.T, m int, pubs keys.Publi
|
||||||
opcode.PICKITEM, // pick pub at index pubCnt.
|
opcode.PICKITEM, // pick pub at index pubCnt.
|
||||||
opcode.LDLOC2, // load msg.
|
opcode.LDLOC2, // load msg.
|
||||||
opcode.PUSH4, opcode.PACK) // pack 4 arguments for 'verifyWithECDsa' call.
|
opcode.PUSH4, opcode.PACK) // pack 4 arguments for 'verifyWithECDsa' call.
|
||||||
emit.AppCallNoArgs(vrf.BinWriter, cryptoLibH, "verifyWithECDsa", callflag.All) // emit the call to 'verifyWithECDsa' itself.
|
emit.AppCallNoArgs(vrf.BinWriter, cryptoLibH, "verifyWithECDsa", callflag.NoneFlag) // emit the call to 'verifyWithECDsa' itself.
|
||||||
|
|
||||||
// Update loop variables.
|
// Update loop variables.
|
||||||
emit.Opcodes(vrf.BinWriter, opcode.LDLOC3, opcode.ADD, opcode.STLOC3, // increment sigCnt if signature is valid.
|
emit.Opcodes(vrf.BinWriter, opcode.LDLOC3, opcode.ADD, opcode.STLOC3, // increment sigCnt if signature is valid.
|
||||||
|
@ -876,7 +880,7 @@ func buildKoblitzMultisigVerificationScript(t *testing.T, m int, pubs keys.Publi
|
||||||
// 205 LDLOC2
|
// 205 LDLOC2
|
||||||
// 206 PUSH4
|
// 206 PUSH4
|
||||||
// 207 PACK
|
// 207 PACK
|
||||||
// 208 PUSH15
|
// 208 PUSH0
|
||||||
// 209 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
// 209 PUSHDATA1 766572696679576974684543447361 ("verifyWithECDsa")
|
||||||
// 226 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
// 226 PUSHDATA1 1bf575ab1189688413610a35a12886cde0b66c72 ("NNToUmdQBe5n8o53BTzjTFAnSEcpouyy3B", "0x726cb6e0cd8628a1350a611384688911ab75f51b")
|
||||||
// 248 SYSCALL System.Contract.Call (627d5b52)
|
// 248 SYSCALL System.Contract.Call (627d5b52)
|
||||||
|
|
Loading…
Reference in a new issue