Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
querolita committed Jan 15, 2025
1 parent 868e8c6 commit b741643
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/lib/provable/gadgets/twisted-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ function add(

let x1x2y1y2 = ForeignField.mul(x1x2, y1y2, f);
let dx1x2y1y2 = ForeignField.mul(Field3.from(d), x1x2y1y2, f);
// check denominators are correctly computed:
// den = 1 / (1 +- d * x1^2 * y1^2)
Provable.equal(
Field3,
x3Den,
ForeignField.add(one, dx1x2y1y2, f)
one,
ForeignField.mul(x3Den, ForeignField.add(one, dx1x2y1y2, f), f)
).assertTrue();
Provable.equal(
Field3,
y3Den,
ForeignField.sub(one, dx1x2y1y2, f)
one,
ForeignField.mul(y3Den, ForeignField.sub(one, dx1x2y1y2, f), f)
).assertTrue();

ForeignField.assertMul(x3Num, x3Den, x3, f);
Expand Down
3 changes: 0 additions & 3 deletions src/lib/provable/test/twisted-curve.unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ for (let Curve of curves) {
`${Curve.name} double`
);

/*
equivalentProvable({ from: [point], to: point, verbose: true })(
Curve.negate,
(p) => CurveTwisted.negate(p, Curve),
Expand All @@ -83,5 +81,4 @@ for (let Curve of curves) {
(p, s) => CurveTwisted.scale(s, p, Curve),
`${Curve.name} scale`
);
*/
}

0 comments on commit b741643

Please sign in to comment.