Skip to content

Update ecrecover precompile#2696

Merged
zjb0807 merged 1 commit intoupdate-evmfrom
update-precompile
Jan 28, 2024
Merged

Update ecrecover precompile#2696
zjb0807 merged 1 commit intoupdate-evmfrom
update-precompile

Conversation

@zjb0807
Copy link
Copy Markdown
Contributor

@zjb0807 zjb0807 commented Jan 28, 2024

@zjb0807 zjb0807 merged commit 4027f4d into update-evm Jan 28, 2024
@zjb0807 zjb0807 deleted the update-precompile branch January 28, 2024 12:14
@ermalkaleci
Copy link
Copy Markdown
Contributor

ermalkaleci commented Jan 28, 2024

@zjb0807 we already have the correct version, what does this change?

@zjb0807
Copy link
Copy Markdown
Contributor Author

zjb0807 commented Jan 28, 2024

@ermalkaleci

sig[64] = match input[63] {
v if v > 26 && input[32..63] == [0; 31] => v - 27,
_ => {
return Ok((ExitSucceed::Returned, [0u8; 0].to_vec()));
}
};

If v > 26, then sig[64] = v - 27, let it be 0 or 1.
while geth version only accept 27 and 28.

zjb0807 added a commit that referenced this pull request Jan 29, 2024
* update PrecompileHandle ref: rust-ethereum/evm#122

* update fee calculation ref: rust-ethereum/evm#132

* add code_size/code_hash fn in StackState trait ref: rust-ethereum/evm#140

* update evm call stack ref: rust-ethereum/evm#136

* update evm call stack ref: rust-ethereum/evm#155

* add shanghai eips 3651, 3855, 3860 ref: rust-ethereum/evm#152

* update is_precompile ref: rust-ethereum/evm#157

* fix eip-3860 ref: rust-ethereum/evm#160

* update runtime config ref: rust-ethereum/evm#161

* add eip-4399 ref: rust-ethereum/evm#162

* fix eip-2618 ref: rust-ethereum/evm#163

* fix nonce back to U256 ref: rust-ethereum/evm#166

* remove exit_substate in create functions ref: rust-ethereum/evm#168

* record external cost ref: rust-ethereum/evm#170

* add record_external_operation ref: rust-ethereum/evm#171

* add storage_growth ref: rust-ethereum/evm#173

* update evm

* switch to shanghai hardfork

* update ecrecover ref: polkadot-evm/frontier#964 (#2696)
@ermalkaleci
Copy link
Copy Markdown
Contributor

if this is fixing an issue then there should be a test. where's v - 27 https://github.com/ethereum/go-ethereum/blob/a907d7e81aaeea15d80b2d3209ad8e08e3bf49e0/core/vm/contracts.go#L174?

@zjb0807
Copy link
Copy Markdown
Contributor Author

zjb0807 commented Jan 29, 2024

It checked that input[63] > 26, so if it is input[63] = 30, it need to continue to verify the signature.
Now strictly check input[63] is 27/28.

@ermalkaleci
Copy link
Copy Markdown
Contributor

It checked that input[63] > 26, so if it is input[63] = 30, it need to continue to verify the signature.

Now strictly check input[63] is 27/28.

If v > 26 then v - 27

@zjb0807
Copy link
Copy Markdown
Contributor Author

zjb0807 commented Jan 29, 2024

If v > 26 then v - 27

So v can be 27~255 to call secp256k1_ecdsa_recover. Now it is only allowed on 27/28.

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