diff --git a/CHANGELOG.md b/CHANGELOG.md index dc24c3f58..bc2472ee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/ec/src/models/short_weierstrass/affine.rs b/ec/src/models/short_weierstrass/affine.rs index 2a47f5cb3..82e127928 100644 --- a/ec/src/models/short_weierstrass/affine.rs +++ b/ec/src/models/short_weierstrass/affine.rs @@ -305,14 +305,14 @@ impl> Sub for Affine

{ impl Sub> for Affine

{ type Output = Projective

; fn sub(self, other: Projective

) -> Projective

{ - other - self + self + (-other) } } impl<'a, P: SWCurveConfig> Sub<&'a Projective

> for Affine

{ type Output = Projective

; fn sub(self, other: &'a Projective

) -> Projective

{ - *other - self + self + (-*other) } } diff --git a/ec/src/models/twisted_edwards/affine.rs b/ec/src/models/twisted_edwards/affine.rs index 72a3e4f7e..1d93882a1 100644 --- a/ec/src/models/twisted_edwards/affine.rs +++ b/ec/src/models/twisted_edwards/affine.rs @@ -255,14 +255,14 @@ impl> Sub for Affine

{ impl Sub> for Affine

{ type Output = Projective

; fn sub(self, other: Projective

) -> Projective

{ - other - self + self + (-other) } } impl<'a, P: TECurveConfig> Sub<&'a Projective

> for Affine

{ type Output = Projective

; fn sub(self, other: &'a Projective

) -> Projective

{ - *other - self + self + (-*other) } } diff --git a/test-templates/src/groups.rs b/test-templates/src/groups.rs index 5ad7e33b2..625a26d7c 100644 --- a/test-templates/src/groups.rs +++ b/test-templates/src/groups.rs @@ -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); } }