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

fix(forge): new error message for vm.addr() when passing invalid private keys #2164

Merged
merged 3 commits into from Jun 30, 2022

Conversation

0xvv
Copy link
Contributor

@0xvv 0xvv commented Jun 29, 2022

Fixes #2158

I thought about storing the curve order value in another way, like an array of bytes, but i think the marginal perf gain is not worth the less readable code.

U256::from_str("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141")
.unwrap();
if private_key > secp256k1_order {
return Err("Private key is greater than secp256k1 curve order.".to_string().encode().into())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I suspect most user's won't know what "curve order" means or what that value is. What do you think about:

Suggested change
return Err("Private key is greater than secp256k1 curve order.".to_string().encode().into())
return Err("Private key must be less than 115792089237316195423570985008687907852837564279074904382605163141518161494337.".to_string().encode().into())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it is already better but maybe there is a more usable way to print the value

evm/src/executor/inspector/cheatcodes/util.rs Outdated Show resolved Hide resolved
@0xvv
Copy link
Contributor Author

0xvv commented Jun 29, 2022

By the way does anybody know a dependency that re exports : https://docs.rs/secp256k1/latest/secp256k1/constants/constant.CURVE_ORDER.html

It would be the cleanest way to use the dep's constant

edit: i think ethers-rs does the job yet again

evm/src/executor/inspector/cheatcodes/util.rs Outdated Show resolved Hide resolved
evm/src/executor/inspector/cheatcodes/util.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants