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

Display a clearer error message when the private key passed to the addr cheatcode is greater than the secp256k1 curve order #2158

Closed
PaulRBerg opened this issue Jun 29, 2022 · 0 comments · Fixed by #2164
Labels
T-feature Type: feature

Comments

@PaulRBerg
Copy link
Contributor

Component

Forge

Describe the feature you would like

The order of the secp256k1 curve is a little bit smaller than 2^256, which means that not all uint256 values can be used as private keys. The order has this value:

0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141

Currently, when we pass a value greater than this to the vm.addr cheatcode, we got the following error:

signature error

It would be nice to display a clearer, more specific error, to let users that what happened is that the private key is greater than what is permitted by secp256k1.

Additional context

It is quite easy for a user to end up passing a value greater than the curve order:

  1. Fuzz the private key as an uint256 argument in a test function
  2. Use the vm.addr cheatcode to generate an address from the fuzzed private key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant