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

secp256r1 public key recovery #7

Open
mikekelly opened this issue May 10, 2024 · 10 comments · May be fixed by #9
Open

secp256r1 public key recovery #7

mikekelly opened this issue May 10, 2024 · 10 comments · May be fixed by #9

Comments

@mikekelly
Copy link

Hi there, I'm confused about how this library works. It looks like accurate recovery is implemented for secp256k1 via recover_compressed_key which includes the odd/even byte, but secp256r1 can't be accurately recovered because the function only takes the raw X coordinate via recover_compact_key without the odd/even byte and therefore can't know which Y coordinate is the public key. Is there a specific reason that this library has that limitation?

@madninja
Copy link
Member

the standard allows for even/odd compression as a feature, but compact keys are a different feature. It allows the Y co-ordinate to be recovered from the X coordinate. See here.

@mikekelly
Copy link
Author

hi @madninja, yes that makes sense - I was wondering why you chose to support only k1 for compressed and r1 for compact?

@madninja
Copy link
Member

madninja commented May 10, 2024 via email

@mikekelly
Copy link
Author

the library doesn't support point compression for r1?

@mikekelly
Copy link
Author

sorry I meant specifically recovery for compressed r1 public keys

@madninja
Copy link
Member

madninja commented May 10, 2024 via email

@mikekelly
Copy link
Author

understood - I was suprised to see there was support for compression, it's just confusing why this was added with only support for k1. Wondered if there was some specific reason why

@madninja
Copy link
Member

madninja commented May 10, 2024 via email

@mikekelly mikekelly linked a pull request May 13, 2024 that will close this issue
@ke6jjj
Copy link
Contributor

ke6jjj commented May 17, 2024

@mikekelly This library was originally developed for the Helium blockchain, where only secp256r1 and ed25519 were used, and even then, secp256r1 was only used for compact keys for the specific reason that point compression was something the developers wanted to avoid putting in the library.

Much later, when it looked like the Certicom patents around point compression had safely expired, and when there was some discussion about allowing the chain to recognize secp256k1 keys in order to help create transaction bridges to other blockchains, I added secp256k1 support, complete with point compression/decompression routines, as an experiment. Even with this addition there was no need to back-port the point compression support to secp256r1 as no one was planning for the blockchain to change to support it.

Hopefully that explains the history a bit better.

@mikekelly
Copy link
Author

yes, that's perfect - thanks @ke6jjj

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 a pull request may close this issue.

3 participants