Skip to content

Commit b10737b

Browse files
committed
Renamings
1 parent b7b97ca commit b10737b

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const P = B256 - 0x1000003d1n; // curve's field prime
88
const N = B256 - 0x14551231950b75fc4402da1732fc9bebfn; // curve (group) order
99
const Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n; // base point x
1010
const Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n; // base point y
11+
const _b = 7n;
1112
const _0 = 0n;
1213
const _1 = 1n;
1314
const L = 32; // field / group byte length
14-
const L2 = L * 2;
15-
const _b = 7n;
15+
const L2 = 64;
1616
/**
1717
* secp256k1 curve parameters. Equation is x³ + ax + b, but a=0 - which makes it x³+b.
1818
* Gx and Gy are generator coordinates. p is field order, n is group order.
@@ -88,7 +88,7 @@ class Point {
8888
}
8989
if (len === (L2 + 1) && head === 0x04) // Uncompressed 65-byte point, 0x04 prefix
9090
p = new Point(x, sliceBytesNum(tail, L, L2), _1);
91-
return p ? p.ok() : err('bad point: not on curve'); // Verify the result
91+
return p ? p.ok() : err('bad Point: not on curve'); // Verify the result
9292
}
9393
/** Equality check: compare points P&Q. */
9494
equals(other) {
@@ -335,7 +335,7 @@ const cr = () => // We support: 1) browsers 2) node.js 19+ 3) deno, other envs w
335335
typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
336336
const subtle = () => {
337337
const c = cr();
338-
return c && c.subtle || err('crypto.subtle must be defined');
338+
return c?.subtle || err('crypto.subtle must be defined');
339339
};
340340
const callEtcFn = (name) => {
341341
// @ts-ignore

index.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const P = B256 - 0x1000003d1n; // curve's field prime
88
const N = B256 - 0x14551231950b75fc4402da1732fc9bebfn; // curve (group) order
99
const Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n; // base point x
1010
const Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n; // base point y
11+
const _b = 7n;
1112
const _0 = 0n;
1213
const _1 = 1n;
1314
const L = 32; // field / group byte length
14-
const L2 = L * 2;
15-
const _b = 7n;
15+
const L2 = 64;
1616
/**
1717
* secp256k1 curve parameters. Equation is x³ + ax + b, but a=0 - which makes it x³+b.
1818
* Gx and Gy are generator coordinates. p is field order, n is group order.
@@ -100,7 +100,7 @@ class Point {
100100
}
101101
if (len === (L2+1) && head === 0x04) // Uncompressed 65-byte point, 0x04 prefix
102102
p = new Point(x, sliceBytesNum(tail, L, L2), _1);
103-
return p ? p.ok() : err('bad point: not on curve'); // Verify the result
103+
return p ? p.ok() : err('bad Point: not on curve'); // Verify the result
104104
}
105105
/** Equality check: compare points P&Q. */
106106
equals(other: Point): boolean {
@@ -167,7 +167,8 @@ class Point {
167167
/** Checks if the point is valid and on-curve. */
168168
ok(): Point {
169169
const { x, y } = this.aff(); // convert to 2d xy affine point.
170-
afield(x); afield(y); // must be in range 1 <= x,y < P
170+
afield(x);
171+
afield(y); // must be in range 1 <= x,y < P
171172
return M(y * y) === curve(x) ? // y² = x³ + ax + b, must be equal
172173
this : err('bad point: not on curve');
173174
}
@@ -309,7 +310,7 @@ const cr = () => // We support: 1) browsers 2) node.js 19+ 3) deno, other envs w
309310
typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
310311
const subtle = () => {
311312
const c = cr();
312-
return c && c.subtle || err('crypto.subtle must be defined');
313+
return c?.subtle || err('crypto.subtle must be defined');
313314
};
314315
const callEtcFn = (name: string) => {
315316
// @ts-ignore

0 commit comments

Comments
 (0)