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

faster is_in_correct_subgroup_assuming_on_curve when cofactor is one #771

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
### Improvements

- [\#736](https://github.com/arkworks-rs/algebra/pull/736) (`ark-ff`) Deprecate `divn()`, and use `core::ops::{Shr, ShrAssign}` instead.
- [\#739](https://github.com/arkworks-rs/algebra/pull/739) (`ark-ff`) Deprecate `muln()`, and use `core::ops::{Shl, ShlAssign}` instead.
- [\#739](https://github.com/arkworks-rs/algebra/pull/739) (`ark-ff`) Deprecate
`muln()`, and use `core::ops::{Shl, ShlAssign}` instead.
- [\#771](https://github.com/arkworks-rs/algebra/pull/771) (`ark-ec`) Omit expensive
scalar multiplication in `is_in_correct_subgroup_assuming_on_curve()` for
short Weierstrass curves of cofactor one.
Pratyush marked this conversation as resolved.
Show resolved Hide resolved

### Bugfixes

Expand Down
9 changes: 7 additions & 2 deletions ec/src/models/short_weierstrass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,18 @@ pub trait SWCurveConfig: super::CurveConfig {
/// Check if the provided curve point is in the prime-order subgroup.
///
/// The default implementation multiplies `item` by the order `r` of the
/// prime-order subgroup, and checks if the result is zero.
/// prime-order subgroup, and checks if the result is zero. If the
/// curve's cofactor is one, this check automatically returns true.
/// Implementors can choose to override this default impl
/// if the given curve has faster methods
/// for performing this check (for example, via leveraging curve
/// isomorphisms).
fn is_in_correct_subgroup_assuming_on_curve(item: &Affine<Self>) -> bool {
Self::mul_affine(item, Self::ScalarField::characteristic()).is_zero()
if Self::cofactor_is_one() {
true
} else {
Self::mul_affine(item, Self::ScalarField::characteristic()).is_zero()
}
}

/// Performs cofactor clearing.
Expand Down
Loading