-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply kingster's change to Leeren's branch #1
base: feat/add-ip-and-p256-verify-precompiles
Are you sure you want to change the base?
Conversation
…nd-p256-verify-precompiles branch
|
||
// P256VERIFY (secp256r1 signature verification) | ||
// implemented as a native contract | ||
type p256Verify struct{} | ||
|
||
// RequiredGas returns the gas required to execute the precompiled contract | ||
func (c *p256Verify) RequiredGas(input []byte) uint64 { | ||
return params.P256VerifyGas | ||
} | ||
|
||
// Run executes the precompiled contract with the given input and EVM context, returning the output and the used gas | ||
func (c *p256Verify) Run(evm *EVM, input []byte) ([]byte, error) { | ||
// Required input length is 160 bytes | ||
const p256VerifyInputLength = 160 | ||
|
||
// Check the input length | ||
if len(input) != p256VerifyInputLength { | ||
// Input length is invalid | ||
return nil, nil | ||
} | ||
|
||
// Extract the hash, r, s, x, y from the input | ||
hash := input[0:32] | ||
r, s := new(big.Int).SetBytes(input[32:64]), new(big.Int).SetBytes(input[64:96]) | ||
x, y := new(big.Int).SetBytes(input[96:128]), new(big.Int).SetBytes(input[128:160]) | ||
|
||
// Verify the secp256r1 signature | ||
if secp256r1.Verify(hash, r, s, x, y) { | ||
// Signature is valid | ||
return common.LeftPadBytes([]byte{1}, 32), nil | ||
} else { | ||
// Signature is invalid | ||
return nil, nil | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are the deleted?
//var PrecompiledContractsNostoi = map[common.Address]PrecompiledContract{ | ||
// common.BytesToAddress([]byte{0x01}): &ecrecover{}, | ||
// common.BytesToAddress([]byte{0x02}): &sha256hash{}, | ||
// common.BytesToAddress([]byte{0x03}): &ripemd160hash{}, | ||
// common.BytesToAddress([]byte{0x04}): &dataCopy{}, | ||
// common.BytesToAddress([]byte{0x05}): &bigModExp{eip2565: true}, | ||
// common.BytesToAddress([]byte{0x06}): &bn256AddIstanbul{}, | ||
// common.BytesToAddress([]byte{0x07}): &bn256ScalarMulIstanbul{}, | ||
// common.BytesToAddress([]byte{0x08}): &bn256PairingIstanbul{}, | ||
// common.BytesToAddress([]byte{0x09}): &blake2F{}, | ||
// common.BytesToAddress([]byte{0x0a}): &kzgPointEvaluation{}, | ||
// common.BytesToAddress([]byte{0x0b}): &bls12381G1Add{}, | ||
// common.BytesToAddress([]byte{0x0c}): &bls12381G1Mul{}, | ||
// common.BytesToAddress([]byte{0x0d}): &bls12381G1MultiExp{}, | ||
// common.BytesToAddress([]byte{0x0e}): &bls12381G2Add{}, | ||
// common.BytesToAddress([]byte{0x0f}): &bls12381G2Mul{}, | ||
// common.BytesToAddress([]byte{0x10}): &bls12381G2MultiExp{}, | ||
// common.BytesToAddress([]byte{0x11}): &bls12381Pairing{}, | ||
// common.BytesToAddress([]byte{0x12}): &bls12381MapG1{}, | ||
// common.BytesToAddress([]byte{0x13}): &bls12381MapG2{}, | ||
// common.BytesToAddress([]byte{0x1a}): &ipGraphDynamicGas{}, // redirect 0x1a to ipGraphDynamicGas | ||
// common.BytesToAddress([]byte{0x1b}): &ipGraphWithPolicyKind{}, | ||
// common.BytesToAddress([]byte{0x01, 0x00}): &p256Verify{}, | ||
//} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These need to be activated
for k := range PrecompiledContractsNostoi { | ||
PrecompiledAddressesNostoi = append(PrecompiledAddressesNostoi, k) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not delete these
case rules.IsStoryNostoi: | ||
return PrecompiledAddressesNostoi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not delete this
@@ -34,7 +35,8 @@ import ( | |||
"github.com/ethereum/go-ethereum/crypto/blake2b" | |||
"github.com/ethereum/go-ethereum/crypto/bn256" | |||
"github.com/ethereum/go-ethereum/crypto/kzg4844" | |||
"github.com/ethereum/go-ethereum/crypto/secp256r1" | |||
|
|||
// "github.com/ethereum/go-ethereum/crypto/secp256r1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not delete this
|
||
var PrecompiledContractsBLS = PrecompiledContractsPrague | ||
|
||
var PrecompiledContractsVerkle = PrecompiledContractsPrague | ||
|
||
var ( | ||
PrecompiledAddressesNostoi []common.Address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not delete this
@@ -629,6 +629,7 @@ func DeveloperGenesisBlock(gasLimit uint64, faucet *common.Address) *Genesis { | |||
common.BytesToAddress([]byte{8}): {Balance: big.NewInt(1)}, // ECPairing | |||
common.BytesToAddress([]byte{9}): {Balance: big.NewInt(1)}, // BLAKE2b | |||
common.BytesToAddress([]byte{26}): {Balance: big.NewInt(1)}, // ipGraph | |||
common.BytesToAddress([]byte{27}): {Balance: big.NewInt(1)}, // ipGraphWithKind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add to genesis
apply Kingter's change on Leeren's PR for geth upgrade test