Skip to content
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

Draft
wants to merge 2 commits into
base: feat/add-ip-and-p256-verify-precompiles
Choose a base branch
from

Conversation

jia57b
Copy link
Owner

@jia57b jia57b commented Sep 19, 2024

apply Kingter's change on Leeren's PR for geth upgrade test

@jia57b jia57b marked this pull request as draft September 19, 2024 04:00
Comment on lines -1269 to -1303

// 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
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are the deleted?

Comment on lines +148 to +171
//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{},
//}

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

Comment on lines -206 to -208
for k := range PrecompiledContractsNostoi {
PrecompiledAddressesNostoi = append(PrecompiledAddressesNostoi, k)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not delete these

Comment on lines -214 to -215
case rules.IsStoryNostoi:
return PrecompiledAddressesNostoi

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"

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants