|
|
@ -105,10 +105,10 @@ var PrecompiledContractsBLS = map[common.Address]PrecompiledContract{ |
|
|
|
common.BytesToAddress([]byte{18}): &bls12381MapG2{}, |
|
|
|
common.BytesToAddress([]byte{18}): &bls12381MapG2{}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// PrecompiledContractsEcverify contains the precompiled Ethereum
|
|
|
|
// PrecompiledContractsP256Verify contains the precompiled Ethereum
|
|
|
|
// contract specified in EIP-N. This is exported for testing purposes.
|
|
|
|
// contract specified in EIP-N. This is exported for testing purposes.
|
|
|
|
var PrecompiledContractsEcverify = map[common.Address]PrecompiledContract{ |
|
|
|
var PrecompiledContractsP256Verify = map[common.Address]PrecompiledContract{ |
|
|
|
common.BytesToAddress([]byte{19}): &ecverify{}, |
|
|
|
common.BytesToAddress([]byte{19}): &p256Verify{}, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var ( |
|
|
|
var ( |
|
|
@ -1056,22 +1056,22 @@ func (c *bls12381MapG2) Run(input []byte) ([]byte, error) { |
|
|
|
return g.EncodePoint(r), nil |
|
|
|
return g.EncodePoint(r), nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ECVERIFY (secp256r1 signature verification)
|
|
|
|
// P256VERIFY (secp256r1 signature verification)
|
|
|
|
// implemented as a native contract
|
|
|
|
// implemented as a native contract
|
|
|
|
type ecverify struct{} |
|
|
|
type p256Verify struct{} |
|
|
|
|
|
|
|
|
|
|
|
// RequiredGas returns the gas required to execute the precompiled contract
|
|
|
|
// RequiredGas returns the gas required to execute the precompiled contract
|
|
|
|
func (c *ecverify) RequiredGas(input []byte) uint64 { |
|
|
|
func (c *p256Verify) RequiredGas(input []byte) uint64 { |
|
|
|
return params.EcverifyGas |
|
|
|
return params.P256VerifyGas |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Run executes the precompiled contract, returning the output and the used gas
|
|
|
|
// Run executes the precompiled contract, returning the output and the used gas
|
|
|
|
func (c *ecverify) Run(input []byte) ([]byte, error) { |
|
|
|
func (c *p256Verify) Run(input []byte) ([]byte, error) { |
|
|
|
// Required input length is 160 bytes
|
|
|
|
// Required input length is 160 bytes
|
|
|
|
const ecverifyInputLength = 160 |
|
|
|
const p256VerifyInputLength = 160 |
|
|
|
|
|
|
|
|
|
|
|
// "input" is (hash, r, s, x, y), each 32 bytes
|
|
|
|
// "input" is (hash, r, s, x, y), each 32 bytes
|
|
|
|
input = common.RightPadBytes(input, ecverifyInputLength) |
|
|
|
input = common.RightPadBytes(input, p256VerifyInputLength) |
|
|
|
|
|
|
|
|
|
|
|
// Extract the hash, r, s, x, y from the input
|
|
|
|
// Extract the hash, r, s, x, y from the input
|
|
|
|
hash := input[0:32] |
|
|
|
hash := input[0:32] |
|
|
|