2020-04-14 14:24:21 +00:00
|
|
|
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 (
|
2020-07-10 06:56:15 +00:00
|
|
|
ecdsaSecp256r1VerifyID = emit.InteropNameToID([]byte("Neo.Crypto.VerifyWithECDsaSecp256r1"))
|
2020-07-13 10:39:36 +00:00
|
|
|
ecdsaSecp256r1CheckMultisigID = emit.InteropNameToID([]byte("Neo.Crypto.CheckMultisigWithECDsaSecp256r1"))
|
|
|
|
sha256ID = emit.InteropNameToID([]byte("Neo.Crypto.SHA256"))
|
2020-04-14 14:24:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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 {
|
2020-07-10 06:56:15 +00:00
|
|
|
case ecdsaSecp256r1VerifyID:
|
2020-04-14 14:24:21 +00:00
|
|
|
return &vm.InteropFuncPrice{
|
|
|
|
Func: func(v *vm.VM) error {
|
2020-07-10 06:56:15 +00:00
|
|
|
return ECDSASecp256r1Verify(ic, v)
|
2020-04-14 14:24:21 +00:00
|
|
|
},
|
|
|
|
}
|
2020-07-13 10:39:36 +00:00
|
|
|
case ecdsaSecp256r1CheckMultisigID:
|
2020-04-14 14:24:21 +00:00
|
|
|
return &vm.InteropFuncPrice{
|
|
|
|
Func: func(v *vm.VM) error {
|
2020-07-13 10:39:36 +00:00
|
|
|
return ECDSASecp256r1CheckMultisig(ic, v)
|
2020-04-14 14:24:21 +00:00
|
|
|
},
|
|
|
|
}
|
2020-04-28 13:37:42 +00:00
|
|
|
case sha256ID:
|
|
|
|
return &vm.InteropFuncPrice{
|
|
|
|
Func: func(v *vm.VM) error {
|
|
|
|
return Sha256(ic, v)
|
|
|
|
},
|
|
|
|
}
|
2020-04-14 14:24:21 +00:00
|
|
|
default:
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|