-
Couldn't load subscription status.
- Fork 391
Improve comments on high/low-S handling #1601
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
Conversation
of secp256k1_verify/secp256k1_recover_pubkey
f8a172e to
07a01eb
Compare
packages/crypto/src/secp256k1.rs
Outdated
| let message_hash = Sha256::digest(message); | ||
| assert_eq!(hash.as_slice(), message_hash.as_slice()); | ||
|
|
||
| // Since the recovery param is mossing in the test vectors, we try both 0 and 1 |
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.
| // Since the recovery param is mossing in the test vectors, we try both 0 and 1 | |
| // Since the recovery param is missing in the test vectors, we try both 0 and 1 |
I understand that in a real scenario you need to know the recovery param. Otherwise, you can get a recovered pubkey that is not the right one.
I also understand that this is not related to the high/low-S comments, but another issue / improvement.
Will read more about all this and comment back if needed.
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.
I understand that in a real scenario you need to know the recovery param. Otherwise, you can get a recovered pubkey that is not the right one.
Will read more about all this and comment back if needed.
Here are some references about the recovery param:
- https://ethereum.stackexchange.com/questions/42455/during-ecdsa-signing-how-do-i-generate-the-recovery-id
- https://bitcoin.stackexchange.com/questions/38351/ecdsa-v-r-s-what-is-v
So, it seems that there's a small probability of getting two valid pub keys for different recovery params.
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.
I also understand that this is not related to the high/low-S comments, but another issue / improvement.
Exactly. The only reason they are mixed together here is because I pull in the COSMOS_SECP256K1_TESTS_JSON tests which are missing the recovery param.
Co-authored-by: Mauro Lacy <[email protected]>
Co-authored-by: Mauro Lacy <[email protected]>
Co-authored-by: Mauro Lacy <[email protected]>
Co-authored-by: Mauro Lacy <[email protected]>
Co-authored-by: Mauro Lacy <[email protected]>
Co-authored-by: Mauro Lacy <[email protected]>
|
Thanks a lot for the thorough review, @maurolacy! |
of secp256k1_verify/secp256k1_recover_pubkey