Skip to content

Commit

Permalink
feat(elliptic-curve.ts): update affineOnCurve function to use GroupAf…
Browse files Browse the repository at this point in the history
…fine union type.
  • Loading branch information
ymekuria committed Jul 15, 2024
1 parent f0ab6bf commit b12ca8c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crypto/elliptic-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,10 @@ const Vesta = createCurveProjective({
const affineZero: PointAtInfinity = { infinity: true };

function affineOnCurve(g: GroupAffine, p: bigint, a: bigint, b: bigint) {
if (infinity) return true;
if (g.infinity) return true;
// y^2 = x^3 + ax + b
let x2 = mod(x * x, p);
return mod(y * y - x * x2 - a * x - b, p) === 0n;
let x2 = mod(g.x * g.x, p);
return mod(g.y * g.y - g.x * x2 - a * g.x - b, p) === 0n;
}

function affineAdd(g: GroupAffine, h: GroupAffine, p: bigint): GroupAffine {
Expand Down

0 comments on commit b12ca8c

Please sign in to comment.