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

Please explain variable p in Deriving the ES256 public key algortihm #12

Open
merijndejonge opened this issue May 10, 2022 · 1 comment

Comments

@merijndejonge
Copy link

Could you please explain the variable p in the algorithm?
It seems to be used without further introduction.

@nickray
Copy link

nickray commented May 22, 2022

p is the order of the curve P256. Perhaps this reference implementation helps understanding: https://github.com/solokeys/seedweed/blob/main/seedweed/reference.py#L52

For context, the goal is to get an unbiased random secret key (=scalar). The NIST-approved way to do this is rejection sampling as done here. A slightly biased key could be obtained by taking random 32 bytes and reducing modulo p. Alternative approaches would be to reduce a 64 byte hash such as SHA-512 (which has negligible bias), or more generally using an expanding function to get sufficiently many bytes to reduce. This latter approach described in https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hash-to-curve-14#section-5 has the advantage (over rejection sampling) of being constant time.

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

No branches or pull requests

2 participants