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

Fix the incorrect Affine - Projective implementation #822

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- [\#747](https://github.com/arkworks-rs/algebra/pull/747) (`ark-ff-macros`) Fix fetching attributes in `MontConfig` macro.
- [\#803](https://github.com/arkworks-rs/algebra/pull/803) (`ark-ec`, `ark-test-template`) Fix incorrect decomposition in GLV.
- [\#806](https://github.com/arkworks-rs/algebra/pull/806) (`ark-ff`) Fix the impl for `Display`ing zero element in Fp.
- [\#822](https://github.com/arkworks-rs/algebra/pull/822) (`ark-ec`, `ark-test-template`) Fix the incorrect `Affine - Projective` implementation

## v0.4.2

Expand Down
4 changes: 2 additions & 2 deletions ec/src/models/short_weierstrass/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ impl<P: SWCurveConfig, T: Borrow<Self>> Sub<T> for Affine<P> {
impl<P: SWCurveConfig> Sub<Projective<P>> for Affine<P> {
type Output = Projective<P>;
fn sub(self, other: Projective<P>) -> Projective<P> {
other - self
self + (-other)
}
}

impl<'a, P: SWCurveConfig> Sub<&'a Projective<P>> for Affine<P> {
type Output = Projective<P>;
fn sub(self, other: &'a Projective<P>) -> Projective<P> {
*other - self
self + (-*other)
}
}

Expand Down
4 changes: 2 additions & 2 deletions ec/src/models/twisted_edwards/affine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,14 @@ impl<P: TECurveConfig, T: Borrow<Self>> Sub<T> for Affine<P> {
impl<P: TECurveConfig> Sub<Projective<P>> for Affine<P> {
type Output = Projective<P>;
fn sub(self, other: Projective<P>) -> Projective<P> {
other - self
self + (-other)
}
}

impl<'a, P: TECurveConfig> Sub<&'a Projective<P>> for Affine<P> {
type Output = Projective<P>;
fn sub(self, other: &'a Projective<P>) -> Projective<P> {
*other - self
self + (-*other)
}
}

Expand Down
3 changes: 3 additions & 0 deletions test-templates/src/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ macro_rules! __test_group {

assert_eq!(a - zero, a);
assert_eq!(b - zero, b);

// Affine - Projective
assert_eq!(a.into_affine() - b, a - b);
}
}

Expand Down
Loading