Clarify comment

This commit is contained in:
Paul Miller 2023-01-30 07:17:08 +00:00
parent e57aec63d8
commit 823149ecd9
No known key found for this signature in database
GPG Key ID: 697079DA6878B89B
2 changed files with 4 additions and 1 deletions

@ -171,7 +171,8 @@ export function twistedEdwards(curveDef: CurveType): CurveFn {
this._WINDOW_SIZE = windowSize;
pointPrecomputes.delete(this);
}
// fromHex and other functions returns valid point, but if point is created by user (fromAffine), it can be off curve
// Not required for fromHex(), which always creates valid points.
// Could be useful for fromAffine().
assertValidity(): void {
const { a, d } = CURVE;
if (this.is0()) throw new Error('bad point: ZERO'); // TODO: optimize, with vars below?

@ -241,6 +241,8 @@ export function weierstrassPoints<T>(opts: CurvePointsType<T>) {
if (pz == null || !Fp.isValid(pz)) throw new Error('z required');
}
// Does not validate if the point is on-curve.
// Use fromHex instead, or call assertValidity() later.
static fromAffine(p: AffinePoint<T>): Point {
const { x, y } = p || {};
if (!p || !Fp.isValid(x) || !Fp.isValid(y)) throw new Error('invalid affine point');