@@ -8,11 +8,11 @@ const P = B256 - 0x1000003d1n; // curve's field prime
8
8
const N = B256 - 0x14551231950b75fc4402da1732fc9bebfn ; // curve (group) order
9
9
const Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n ; // base point x
10
10
const Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n ; // base point y
11
+ const _b = 7n ;
11
12
const _0 = 0n ;
12
13
const _1 = 1n ;
13
14
const L = 32 ; // field / group byte length
14
- const L2 = L * 2 ;
15
- const _b = 7n ;
15
+ const L2 = 64 ;
16
16
/**
17
17
* secp256k1 curve parameters. Equation is x³ + ax + b, but a=0 - which makes it x³+b.
18
18
* Gx and Gy are generator coordinates. p is field order, n is group order.
@@ -100,7 +100,7 @@ class Point {
100
100
}
101
101
if ( len === ( L2 + 1 ) && head === 0x04 ) // Uncompressed 65-byte point, 0x04 prefix
102
102
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
104
104
}
105
105
/** Equality check: compare points P&Q. */
106
106
equals ( other : Point ) : boolean {
@@ -167,7 +167,8 @@ class Point {
167
167
/** Checks if the point is valid and on-curve. */
168
168
ok ( ) : Point {
169
169
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
171
172
return M ( y * y ) === curve ( x ) ? // y² = x³ + ax + b, must be equal
172
173
this : err ( 'bad point: not on curve' ) ;
173
174
}
@@ -309,7 +310,7 @@ const cr = () => // We support: 1) browsers 2) node.js 19+ 3) deno, other envs w
309
310
typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis . crypto : undefined ;
310
311
const subtle = ( ) => {
311
312
const c = cr ( ) ;
312
- return c && c . subtle || err ( 'crypto.subtle must be defined' ) ;
313
+ return c ? .subtle || err ( 'crypto.subtle must be defined' ) ;
313
314
} ;
314
315
const callEtcFn = ( name : string ) => {
315
316
// @ts -ignore
0 commit comments