Merge pull request #1017 from nspcc-dev/neox/recover_interop

compiler: add recover interops
This commit is contained in:
Roman Khimov 2020-06-06 22:59:13 +03:00 committed by GitHub
commit 8e785feeb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -11,6 +11,10 @@ var syscalls = map[string]map[string]string{
"GetUsage": "Neo.Attribute.GetUsage", "GetUsage": "Neo.Attribute.GetUsage",
"GetData": "Neo.Attribute.GetData", "GetData": "Neo.Attribute.GetData",
}, },
"crypto": {
"Secp256k1Recover": "Neo.Cryptography.Secp256k1Recover",
"Secp256r1Recover": "Neo.Cryptography.Secp256r1Recover",
},
"enumerator": { "enumerator": {
"Concat": "Neo.Enumerator.Concat", "Concat": "Neo.Enumerator.Concat",
"Create": "Neo.Enumerator.Create", "Create": "Neo.Enumerator.Create",

View file

@ -1,5 +1,5 @@
/* /*
Package crypto provides an interface to VM cryptographic instructions. Package crypto provides an interface to VM cryptographic instructions and syscalls.
*/ */
package crypto package crypto
@ -30,3 +30,23 @@ func Hash256(b []byte) []byte {
func VerifySignature(msg []byte, sig []byte, pub []byte) bool { func VerifySignature(msg []byte, sig []byte, pub []byte) bool {
return false return false
} }
// Secp256k1Recover recovers public key from the given signature (r, s) on the
// given message hash using Secp256k1 elliptic curve. Flag isEven denotes Y's
// least significant bit in decompression algorithm. The return value is byte
// array representation of the public key which is either empty (if it's not
// possible to recover key) or contains 32 bytes in BE for X point (in case of
// success). This function uses Neo.Cryptography.Secp256k1Recover syscall.
func Secp256k1Recover(r []byte, s []byte, messageHash []byte, isEven bool) []byte {
return nil
}
// Secp256r1Recover recovers public key from the given signature (r, s) on the
// given message hash using Secp256r1 elliptic curve. Flag isEven denotes Y's
// least significant bit in decompression algorithm. The return value is byte
// array representation of the public key which is either empty (if it's not
// possible to recover key) or contains 32 bytes in BE for X point (in case of
// success). This function uses Neo.Cryptography.Secp256r1Recover syscall.
func Secp256r1Recover(r []byte, s []byte, messageHash []byte, isEven bool) []byte {
return nil
}