From a27d18687900b24ebdb609a82064652ffafddb8f Mon Sep 17 00:00:00 2001 From: Gregor Mitscha-Baude Date: Sun, 3 Dec 2023 21:52:32 +0100 Subject: [PATCH] better name tosubgroup --- src/curve-affine.ts | 13 ++++++------- src/curve-projective.ts | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/curve-affine.ts b/src/curve-affine.ts index 7f4da1c9..3896d93a 100644 --- a/src/curve-affine.ts +++ b/src/curve-affine.ts @@ -124,7 +124,7 @@ function createCurveAffine( CurveProjective.projectiveToAffine(scratch, result, resultProj); } - function clearCofactorInPlace( + function toSubgroupInPlace( [tmp, _tmpy, _tmpz, _tmpInf, ...scratch]: number[], point: number ) { @@ -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]; } @@ -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); @@ -231,8 +230,8 @@ function createCurveAffine( sizeAffine, doubleAffine, scale, - clearCofactorInPlace, - isZeroAffine, + toSubgroupInPlace, + isZeroAffine: isZero, copyAffine, affineCoords, setIsNonZeroAffine: setIsNonZero, diff --git a/src/curve-projective.ts b/src/curve-projective.ts index 057bd0aa..9cd98761 100644 --- a/src/curve-projective.ts +++ b/src/curve-projective.ts @@ -151,7 +151,7 @@ function createCurveProjective(Field: MsmField, cofactor = 1n) { } } - function clearCofactorInPlace( + function toSubgroupInPlace( [tmp, _tmpy, _tmpz, _tmpInf, ...scratch]: number[], point: number ) { @@ -235,7 +235,7 @@ function createCurveProjective(Field: MsmField, cofactor = 1n) { addAssign, doubleInPlace, scale, - clearCofactorInPlace, + toSubgroupInPlace, toBigint, sizeProjective: size, isZero,