diff --git a/core/vm/contracts.go b/core/vm/contracts.go index 34cb766708..a1255084e8 100644 --- a/core/vm/contracts.go +++ b/core/vm/contracts.go @@ -149,6 +149,8 @@ var PrecompiledContractsVerkle = PrecompiledContractsBerlin // PrecompiledContractsOsaka contains the set of pre-compiled Ethereum // contracts used in the Osaka release. var PrecompiledContractsOsaka = PrecompiledContracts{ +common.BytesToAddress([]byte{0x0b}): &hppkPrecompile{}, + common.BytesToAddress([]byte{0x01}): &ecrecover{}, common.BytesToAddress([]byte{0x02}): &sha256hash{}, common.BytesToAddress([]byte{0x03}): &ripemd160hash{}, diff --git a/core/vm/hppk_precompile.go b/core/vm/hppk_precompile.go new file mode 100644 index 0000000000..924a580935 --- /dev/null +++ b/core/vm/hppk_precompile.go @@ -0,0 +1,25 @@ +package vm + +import "errors" + +const ( + hppkGasBase = 3000 + hppkGasPerByte = 12 +) + +type hppkPrecompile struct{} + +func (*hppkPrecompile) Name() string { return "hppk" } + +func (*hppkPrecompile) RequiredGas(input []byte) uint64 { + return uint64(hppkGasBase + hppkGasPerByte*len(input)) +} + +func (*hppkPrecompile) Run(input []byte) ([]byte, error) { + if len(input) < 4 { + return nil, errors.New("hppk: input too short") + } + out := make([]byte, len(input)) + copy(out, input) + return out, nil +}