Skip to content

Commit

Permalink
better name tosubgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Dec 3, 2023
1 parent 17638a2 commit a27d186
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/curve-affine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function createCurveAffine(
CurveProjective.projectiveToAffine(scratch, result, resultProj);
}

function clearCofactorInPlace(
function toSubgroupInPlace(
[tmp, _tmpy, _tmpz, _tmpInf, ...scratch]: number[],
point: number
) {
Expand Down Expand Up @@ -175,13 +175,13 @@ function createCurveAffine(

if (CurveProjective.cofactor !== 1n) {
for (let i = 0; i < n; i++) {
clearCofactorInPlace(scratch, points[i]);
toSubgroupInPlace(scratch, points[i]);
}
}
return points;
}

function isZeroAffine(pointer: number) {
function isZero(pointer: number) {
return !memoryBytes[pointer + 2 * sizeField];
}

Expand All @@ -198,8 +198,7 @@ function createCurveAffine(
}

function toBigint(point: number): BigintPoint {
let isZero = isZeroAffine(point);
if (isZero) return BigintPoint.zero;
if (isZero(point)) return BigintPoint.zero;
let [x, y] = affineCoords(point);
Field.fromMontgomery(x);
Field.fromMontgomery(y);
Expand Down Expand Up @@ -231,8 +230,8 @@ function createCurveAffine(
sizeAffine,
doubleAffine,
scale,
clearCofactorInPlace,
isZeroAffine,
toSubgroupInPlace,
isZeroAffine: isZero,
copyAffine,
affineCoords,
setIsNonZeroAffine: setIsNonZero,
Expand Down
4 changes: 2 additions & 2 deletions src/curve-projective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function createCurveProjective(Field: MsmField, cofactor = 1n) {
}
}

function clearCofactorInPlace(
function toSubgroupInPlace(
[tmp, _tmpy, _tmpz, _tmpInf, ...scratch]: number[],
point: number
) {
Expand Down Expand Up @@ -235,7 +235,7 @@ function createCurveProjective(Field: MsmField, cofactor = 1n) {
addAssign,
doubleInPlace,
scale,
clearCofactorInPlace,
toSubgroupInPlace,
toBigint,
sizeProjective: size,
isZero,
Expand Down

0 comments on commit a27d186

Please sign in to comment.