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

chore: fix small bias in EOTS private key generation #328

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

gitferry
Copy link
Member

@gitferry gitferry changed the title chore: fix random generation bias chore: fix small bias in EOTS private key generation Feb 10, 2025

// increase iteration count and sample again until overflow does not
// happen. It is fine as the chance of overflow is very small (2^-128)
if overflow := randScalar.SetByteSlice(randPre); !overflow {

Choose a reason for hiding this comment

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

I think we also need to check if the generated scalar is not 0. Good example of the generation can be find in decred library itself - https://github.com/decred/dcrd/blob/172eeb5fe1493e1d5cff6dc304c94de5befd0d21/dcrec/secp256k1/nonce.go#L245

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice reference! Fixed

@gitferry gitferry force-pushed the gai/fix-bias-randomness-generation branch from 61063d7 to d92c928 Compare February 10, 2025 13:51
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 this pull request may close these issues.

3 participants