mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-27 13:58:05 +00:00
519b31a704
All cryptography has moved to interops in NEO3. There is no SHA256 interop RN, but it is to appear later. Closes #777.
41 lines
1 KiB
Go
41 lines
1 KiB
Go
package crypto
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
|
"github.com/nspcc-dev/neo-go/pkg/vm/emit"
|
|
)
|
|
|
|
var (
|
|
ecdsaVerifyID = emit.InteropNameToID([]byte("Neo.Crypto.ECDsaVerify"))
|
|
ecdsaCheckMultisigID = emit.InteropNameToID([]byte("Neo.Crypto.ECDsaCheckMultiSig"))
|
|
sha256ID = emit.InteropNameToID([]byte("Neo.Crypto.SHA256"))
|
|
)
|
|
|
|
// GetInterop returns interop getter for crypto-related stuff.
|
|
func GetInterop(ic *interop.Context) func(uint32) *vm.InteropFuncPrice {
|
|
return func(id uint32) *vm.InteropFuncPrice {
|
|
switch id {
|
|
case ecdsaVerifyID:
|
|
return &vm.InteropFuncPrice{
|
|
Func: func(v *vm.VM) error {
|
|
return ECDSAVerify(ic, v)
|
|
},
|
|
}
|
|
case ecdsaCheckMultisigID:
|
|
return &vm.InteropFuncPrice{
|
|
Func: func(v *vm.VM) error {
|
|
return ECDSACheckMultisig(ic, v)
|
|
},
|
|
}
|
|
case sha256ID:
|
|
return &vm.InteropFuncPrice{
|
|
Func: func(v *vm.VM) error {
|
|
return Sha256(ic, v)
|
|
},
|
|
}
|
|
default:
|
|
return nil
|
|
}
|
|
}
|
|
}
|