Skip to content

Commit

Permalink
Make Short Weierstrass random sampling result in an element with unkn…
Browse files Browse the repository at this point in the history
…own discrete log (#188)

* fix: make sw random sampling the same as twisted edwards

* update changelog

Co-authored-by: Weikeng Chen <[email protected]>
  • Loading branch information
kobigurk and weikengchen authored Jan 27, 2021
1 parent a5f7efd commit 2c814ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ The main features of this release are:
- #166 (ark-ff) Add a `to_bytes_be()` and `to_bytes_le` methods to `BigInt`.
- #169 (ark-poly) Improve radix-2 FFTs by moving to a faster algorithm by Riad S. Wahby.
- #171, #173, #176 (ark-poly) Apply significant further speedups to the new radix-2 FFT.
- #188 (ark-ec) Make Short Weierstrass random sampling result in an element with unknown discrete log

### Bug fixes
- #36 (ark-ec) In Short-Weierstrass curves, include an infinity bit in `ToConstraintField`.
Expand Down
12 changes: 8 additions & 4 deletions ec/src/models/short_weierstrass_jacobian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,14 @@ impl<P: Parameters> PartialEq for GroupProjective<P> {
impl<P: Parameters> Distribution<GroupProjective<P>> for Standard {
#[inline]
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> GroupProjective<P> {
let mut res = GroupProjective::prime_subgroup_generator();
res.mul_assign(P::ScalarField::rand(rng));
debug_assert!(GroupAffine::from(res).is_in_correct_subgroup_assuming_on_curve());
res
loop {
let x = P::BaseField::rand(rng);
let greatest = rng.gen();

if let Some(p) = GroupAffine::get_point_from_x(x, greatest) {
return p.scale_by_cofactor().into();
}
}
}
}

Expand Down

0 comments on commit 2c814ab

Please sign in to comment.