Skip to content

Commit

Permalink
Merge pull request #730 from dusk-network/mocello/ecc_tests
Browse files Browse the repository at this point in the history
Fix negation of coordinates in `assert_equal_public_point`
  • Loading branch information
moCello authored Jan 27, 2023
2 parents c162d2b + fedebc8 commit 44dbecb
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 39 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fix negation of public input values when using `composer.append_public` [#717]
- Fix `assert_equal_point` method [#721]
- Fix negation of constant in `append_equal_constant` [#728]
- Fix negation of public point coordinates in `assert_equal_public_point` [#728]

## [0.13.1] - 2022-10-26

Expand Down Expand Up @@ -457,6 +459,7 @@ is necessary since `rkyv/validation` was required as a bound.
- Proof system module.

<!-- ISSUES -->
[#728]: https://github.com/dusk-network/plonk/issues/728
[#725]: https://github.com/dusk-network/plonk/issues/725
[#721]: https://github.com/dusk-network/plonk/issues/721
[#717]: https://github.com/dusk-network/plonk/issues/717
Expand Down
13 changes: 8 additions & 5 deletions src/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,13 +544,13 @@ pub trait Composer: Sized + Index<Witness, Output = BlsScalar> {
self.assert_equal_constant(
*point.x(),
BlsScalar::zero(),
Some(-affine.get_x()),
Some(affine.get_x()),
);

self.assert_equal_constant(
*point.y(),
BlsScalar::zero(),
Some(-affine.get_y()),
Some(affine.get_y()),
);

point
Expand Down Expand Up @@ -622,7 +622,10 @@ pub trait Composer: Sized + Index<Witness, Output = BlsScalar> {
public: Option<BlsScalar>,
) {
let constant = constant.into();
let constraint = Constraint::new().left(1).constant(-constant).a(a);
let constraint = Constraint::new()
.left(-BlsScalar::one())
.a(a)
.constant(constant);
let constraint =
public.map(|p| constraint.public(p)).unwrap_or(constraint);

Expand All @@ -649,13 +652,13 @@ pub trait Composer: Sized + Index<Witness, Output = BlsScalar> {
self.assert_equal_constant(
*point.x(),
BlsScalar::zero(),
Some(-public.get_x()),
Some(public.get_x()),
);

self.assert_equal_constant(
*point.y(),
BlsScalar::zero(),
Some(-public.get_y()),
Some(public.get_y()),
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn circuit_with_all_gates() {
composer.append_public(self.y);

composer.assert_equal(w_x, r_w);
composer.assert_equal_constant(w_x, 0, Some(-self.x));
composer.assert_equal_constant(w_x, 0, Some(self.x));
composer.assert_equal_point(w_z, w_z);
composer.assert_equal_public_point(w_z, self.z);

Expand Down
Loading

0 comments on commit 44dbecb

Please sign in to comment.