Skip to content

fix NewRandomZr ignoring rng on bls12-381 - #53

Merged
adecaro merged 1 commit into
IBM:mainfrom
bhess:main
Jul 23, 2026
Merged

fix NewRandomZr ignoring rng on bls12-381#53
adecaro merged 1 commit into
IBM:mainfrom
bhess:main

Conversation

@bhess

@bhess bhess commented Jul 23, 2026

Copy link
Copy Markdown
Member

The BLS12-381 driver's NewRandomZr calls fr.Element.SetRandom(), which ignores the rng argument and always reads from crypto/rand. So unlike other drivers, it silently drops the caller's reader. This breaks reproducible (seeded) tests.

The PR changes this to sample with rand.Int(rng, &c.Modulus) like the common base driver does, and adds a test that checks the same seed gives the same scalar on every curve.

Signed-off-by: Basil Hess <bhe@zurich.ibm.com>
@adecaro
adecaro self-requested a review July 23, 2026 16:08
@adecaro adecaro self-assigned this Jul 23, 2026
@adecaro adecaro added the bug Something isn't working label Jul 23, 2026
@adecaro

adecaro commented Jul 23, 2026

Copy link
Copy Markdown
Member

Thanks for the effort, @bhess 🙏

@adecaro
adecaro merged commit 0148cd9 into IBM:main Jul 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants