@noble/curves 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -2,15 +2,21 @@
2
2
 
3
3
  Minimal, zero-dependency JS implementation of elliptic curve cryptography.
4
4
 
5
- Implements Short Weierstrass curves with ECDSA signature scheme.
5
+ - Short Weierstrass curve with ECDSA signatures
6
+ - Twisted Edwards curve with EdDSA signatures
7
+ - Montgomery curve for ECDH key agreement
6
8
 
7
- To keep the package minimal, no curve definitions are provided out-of-box.
8
- Main reason for that is the fact hashing library is usually required for full functionality. Use separate package that defines popular curves: `micro-curve-definitions` for P192, P224, P256, P384, P521, secp256k1, stark curve, bn254, pasta (pallas/vesta) - it depends on `@noble/hashes`.
9
+ To keep the package minimal, no curve definitions are provided out-of-box. Use `micro-curve-definitions` module:
10
+
11
+ - It provides P192, P224, P256, P384, P521, secp256k1, stark curve, bn254, pasta (pallas/vesta) short weierstrass curves
12
+ - It also provides ed25519 and ed448 twisted edwards curves
13
+ - Main reason for separate package is the fact hashing library (like `@noble/hashes`) is required for full functionality
14
+ - We may reconsider merging packages in future, when a stable version would be ready
9
15
 
10
16
  Future plans:
11
17
 
12
- - Edwards, Twisted Edwards & Montgomery curves
13
- - hash-to-curve standard
18
+ - hash to curve standard
19
+ - point indistinguishability
14
20
  - pairings
15
21
 
16
22
  ### This library belongs to _noble_ crypto
@@ -33,39 +39,352 @@ Future plans:
33
39
  Use NPM in node.js / browser, or include single file from
34
40
  [GitHub's releases page](https://github.com/paulmillr/noble-curves/releases):
35
41
 
36
- ## Usage
42
+ > npm install @noble/curves
43
+
44
+ The library does not have an entry point. It allows you to select specific primitives and drop everything else. If you only want to use secp256k1, just use the library with rollup or other bundlers. This is done to make your bundles tiny.
45
+
46
+ ```ts
47
+ import { weierstrass } from '@noble/curves/weierstrass'; // Short Weierstrass curve
48
+ import { sha256 } from '@noble/hashes/sha256';
49
+ import { hmac } from '@noble/hashes/hmac';
50
+ import { concatBytes, randomBytes } from '@noble/hashes/utils';
51
+
52
+ const secp256k1 = weierstrass({
53
+ a: 0n,
54
+ b: 7n,
55
+ P: 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,
56
+ n: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
57
+ Gx: 55066263022277343669578718895168534326250603453777594175500187360389116729240n,
58
+ Gy: 32670510020758816978083085130507043184471273380659243275938904335757337482424n,
59
+ hash: sha256,
60
+ hmac: (k: Uint8Array, ...msgs: Uint8Array[]) => hmac(sha256, key, concatBytes(...msgs)),
61
+ });
37
62
 
38
- ```sh
39
- npm install @noble/curves
63
+ const key = secp256k1.utils.randomPrivateKey();
64
+ const pub = secp256k1.getPublicKey(key);
65
+ const msg = randomBytes(32);
66
+ const sig = secp256k1.sign(msg, key);
67
+ secp256k1.verify(sig, msg, pub); // true
68
+ sig.recoverPublicKey(msg); // == pub
69
+ const someonesPubkey = secp256k1.getPublicKey(secp256k1.utils.randomPrivateKey());
70
+ const shared = secp256k1.getSharedSecret(key, someonesPubkey);
40
71
  ```
41
72
 
73
+ ## API
74
+
75
+ - [Overview](#overview)
76
+ - [edwards: Twisted Edwards curve](#edwards-twisted-edwards-curve)
77
+ - [montgomery: Montgomery curve](#montgomery-montgomery-curve)
78
+ - [weierstrass: Short Weierstrass curve](#weierstrass-short-weierstrass-curve)
79
+ - [modular](#modular)
80
+ - [utils](#utils)
81
+
82
+ ### Overview
83
+
84
+ * All arithmetics is done with JS bigints in finite fields
85
+ * Curve variables, order (number of points on curve), field prime (over which the modular division would be done)
86
+ are required
87
+ * Many features require hashing, which is not provided. `@noble/hashes` can be used for this purpose.
88
+ Any other library must conform to the CHash interface:
89
+ ```ts
90
+ export type CHash = {
91
+ (message: Uint8Array): Uint8Array;
92
+ blockLen: number; outputLen: number; create(): any;
93
+ };
94
+ ```
95
+ * w-ary non-adjacent form (wNAF) method with constant-time adjustments is used for point multiplication.
96
+ It is possible to enable precomputes for edwards & weierstrass curves.
97
+ Precomputes are calculated once (takes ~20-40ms), after that most `G` multiplications
98
+ - for example, `getPublicKey()`, `sign()` and similar methods - would be much faster.
99
+ Use `curve.utils.precompute()`
100
+ * Special params that tune performance can be optionally provided.
101
+ For example, square root calculation, which is commonly used in point decompression routines
102
+ * Curves export `Point`, which conforms to `Group` interface, which has following methods:
103
+ - `double()`, `negate()`
104
+ - `add()`, `subtract()`, `equals()`
105
+ - `multiply()`
106
+ Every group also has `BASE` (generator) and `ZERO` (infinity) static properties.
107
+ * Curves export `CURVE` object
108
+ * Curves export `utils`:
109
+ * `randomPrivateKey()` specific for the curve, avoiding modulo bias
110
+ * `mod()` & `invert()` methods: function from `modular` with default `P` set to CURVE
111
+
112
+ ### edwards: Twisted Edwards curve
113
+
114
+ Twisted Edwards curve's formula is: ax² + y² = 1 + dx²y².
115
+
116
+ * You must specify curve params `a`, `d`, field `P`, order `n`, cofactor `h`, and coordinates `Gx`, `Gy` of generator point.
117
+ * For EdDSA signatures, params `hash` is also required. `adjustScalarBytes` which instructs how to change private scalars could be specified.
118
+
119
+ ```typescript
120
+ import { twistedEdwards } from '@noble/curves/edwards'; // Twisted Edwards curve
121
+ import { sha512 } from '@noble/hashes/sha512';
122
+ import { div } from '@noble/curves/modular';
123
+
124
+ const ed25519 = twistedEdwards({
125
+ a: -1n,
126
+ d: div(-121665n, 121666n, 2n ** 255n - 19n), // -121665n/121666n
127
+ P: 2n ** 255n - 19n,
128
+ n: 2n ** 252n + 27742317777372353535851937790883648493n,
129
+ h: 8n,
130
+ Gx: 15112221349535400772501151409588531511454012693041857206046113283949847762202n,
131
+ Gy: 46316835694926478169428394003475163141307993866256225615783033603165251855960n,
132
+ hash: sha512,
133
+ randomBytes,
134
+ adjustScalarBytes(bytes) { // could be no-op
135
+ bytes[0] &= 248;
136
+ bytes[31] &= 127;
137
+ bytes[31] |= 64;
138
+ return bytes;
139
+ },
140
+ } as const);
141
+ ed25519.getPublicKey(ed25519.utils.randomPrivateKey());
142
+ ```
143
+
144
+ `twistedEdwards()` returns `CurveFn` of following type:
145
+
42
146
  ```ts
43
- // Short Weierstrass curve
44
- import shortw from '@noble/curves/shortw';
147
+ export type CurveFn = {
148
+ CURVE: ReturnType<typeof validateOpts>;
149
+ getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array;
150
+ sign: (message: Hex, privateKey: Hex) => Uint8Array;
151
+ verify: (sig: SigType, message: Hex, publicKey: PubKey) => boolean;
152
+ Point: PointConstructor;
153
+ ExtendedPoint: ExtendedPointConstructor;
154
+ Signature: SignatureConstructor;
155
+ utils: {
156
+ mod: (a: bigint, b?: bigint) => bigint;
157
+ invert: (number: bigint, modulo?: bigint) => bigint;
158
+ randomPrivateKey: () => Uint8Array;
159
+ getExtendedPublicKey: (key: PrivKey) => {
160
+ head: Uint8Array;
161
+ prefix: Uint8Array;
162
+ scalar: bigint;
163
+ point: PointType;
164
+ pointBytes: Uint8Array;
165
+ };
166
+ };
167
+ };
168
+ ```
169
+
170
+ ### montgomery: Montgomery curve
171
+
172
+ For now the module only contains methods for x-only ECDH on Curve25519 / Curve448 from RFC7748.
173
+
174
+ Proper Elliptic Curve Points are not implemented yet.
175
+
176
+ You must specify curve field, `a24` special variable, `montgomeryBits`, `nByteLength`, and coordinate `u` of generator point.
177
+
178
+ ```typescript
179
+ const x25519 = montgomery({
180
+ P: 2n ** 255n - 19n,
181
+ a24: 121665n, // TODO: change to a
182
+ montgomeryBits: 255,
183
+ nByteLength: 32,
184
+ Gu: '0900000000000000000000000000000000000000000000000000000000000000',
185
+
186
+ // Optional params
187
+ powPminus2: (x: bigint): bigint => { return mod.pow(x, P-2, P); },
188
+ adjustScalarBytes(bytes) {
189
+ bytes[0] &= 248;
190
+ bytes[31] &= 127;
191
+ bytes[31] |= 64;
192
+ return bytes;
193
+ },
194
+ });
195
+ ```
196
+
197
+ ### weierstrass: Short Weierstrass curve
198
+
199
+ Short Weierstrass curve's formula is: y² = x³ + ax + b. Uses deterministic ECDSA from RFC6979. You can also specify `extraEntropy` in `sign()`.
200
+
201
+ * You must specify curve params: `a`, `b`; field `P`; curve order `n`; coordinates `Gx`, `Gy` of generator point
202
+ * For ECDSA, you must specify `hash`, `hmac`. It is also possible to recover keys from signatures
203
+ * For ECDH, use `getSharedSecret(privKeyA, pubKeyB)`
204
+ * Optional params are `lowS` (default value), `sqrtMod` (square root chain) and `endo` (endomorphism)
205
+
206
+ ```typescript
207
+ import { weierstrass } from '@noble/curves/weierstrass'; // Short Weierstrass curve
45
208
  import { sha256 } from '@noble/hashes/sha256';
46
209
  import { hmac } from '@noble/hashes/hmac';
47
210
  import { concatBytes, randomBytes } from '@noble/hashes/utils';
48
211
 
49
- export const secp256k1 = shortw({
212
+ const secp256k1 = weierstrass({
213
+ // Required params
50
214
  a: 0n,
51
215
  b: 7n,
52
- // Field over which we'll do calculations
53
- P: 2n ** 256n - 2n ** 32n - 2n ** 9n - 2n ** 8n - 2n ** 7n - 2n ** 6n - 2n ** 4n - 1n,
54
- // Curve order, total count of valid points in the field
216
+ P: 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,
55
217
  n: 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,
56
- // Base point (x, y) aka generator point
57
218
  Gx: 55066263022277343669578718895168534326250603453777594175500187360389116729240n,
58
219
  Gy: 32670510020758816978083085130507043184471273380659243275938904335757337482424n,
59
220
  hash: sha256,
60
221
  hmac: (k: Uint8Array, ...msgs: Uint8Array[]) => hmac(sha256, key, concatBytes(...msgs)),
61
- randomBytes: randomBytes
222
+ randomBytes,
223
+
224
+ // Optional params
225
+ // Cofactor
226
+ h: BigInt(1),
227
+ // Allow only low-S signatures by default in sign() and verify()
228
+ lowS: true,
229
+ // More efficient curve-specific implementation of square root
230
+ sqrtMod(y: bigint) { return sqrt(y); },
231
+ // Endomorphism options
232
+ endo: {
233
+ // Beta param
234
+ beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),
235
+ // Split scalar k into k1, k2
236
+ splitScalar: (k: bigint) => {
237
+ return { k1neg: true, k1: 512n, k2neg: false, k2: 448n };
238
+ },
239
+ },
62
240
  });
63
241
 
64
- // secp256k1.getPublicKey(priv)
65
- // secp256k1.sign(msg, priv)
66
- // secp256k1.verify(sig, msg, pub)
242
+ // Usage
243
+ const key = secp256k1.utils.randomPrivateKey();
244
+ const pub = secp256k1.getPublicKey(key);
245
+ const msg = randomBytes(32);
246
+ const sig = secp256k1.sign(msg, key);
247
+ secp256k1.verify(sig, msg, pub); // true
248
+ sig.recoverPublicKey(msg); // == pub
249
+ const someonesPubkey = secp256k1.getPublicKey(secp256k1.utils.randomPrivateKey());
250
+ const shared = secp256k1.getSharedSecret(key, someonesPubkey);
67
251
  ```
68
252
 
253
+ `weierstrass()` returns `CurveFn`:
254
+
255
+ ```ts
256
+ export type CurveFn = {
257
+ CURVE: ReturnType<typeof validateOpts>;
258
+ getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array;
259
+ getSharedSecret: (privateA: PrivKey, publicB: PubKey, isCompressed?: boolean) => Uint8Array;
260
+ sign: (msgHash: Hex, privKey: PrivKey, opts?: SignOpts) => SignatureType;
261
+ verify: (
262
+ signature: Hex | SignatureType, msgHash: Hex, publicKey: PubKey, opts?: {lowS?: boolean;}
263
+ ) => boolean;
264
+ Point: PointConstructor;
265
+ JacobianPoint: JacobianPointConstructor;
266
+ Signature: SignatureConstructor;
267
+ utils: {
268
+ mod: (a: bigint, b?: bigint) => bigint;
269
+ invert: (number: bigint, modulo?: bigint) => bigint;
270
+ isValidPrivateKey(privateKey: PrivKey): boolean;
271
+ hashToPrivateKey: (hash: Hex) => Uint8Array;
272
+ randomPrivateKey: () => Uint8Array;
273
+ };
274
+ };
275
+ ```
276
+
277
+ ### modular
278
+
279
+ Modular arithmetics utilities.
280
+
281
+ ```typescript
282
+ import * as mod from '@noble/curves/modular';
283
+ mod.mod(21n, 10n); // 21 mod 10 == 1n; fixed version of 21 % 10
284
+ mod.invert(17n, 10n); // invert(17) mod 10; modular multiplicative inverse
285
+ mod.div(5n, 17n, 10n); // 5/17 mod 10 == 5 * invert(17) mod 10; division
286
+ mod.invertBatch([1n, 2n, 4n], 21n); // => [1n, 11n, 16n] in one inversion
287
+ mod.sqrt(21n, 73n); // sqrt(21) mod 73; square root
288
+ ```
289
+
290
+ ### utils
291
+
292
+ ```typescript
293
+ import * as utils from '@noble/curves/utils';
294
+
295
+ utils.bytesToHex(Uint8Array.from([0xde, 0xad, 0xbe, 0xef]));
296
+ utils.hexToBytes('deadbeef');
297
+ utils.hexToNumber();
298
+ utils.bytesToNumberBE(Uint8Array.from([0xde, 0xad, 0xbe, 0xef]));
299
+ utils.bytesToNumberLE(Uint8Array.from([0xde, 0xad, 0xbe, 0xef]));
300
+ utils.numberToBytesBE(123n);
301
+ utils.numberToBytesLE(123n);
302
+ utils.numberToHexUnpadded(123n);
303
+ utils.concatBytes(Uint8Array.from([0xde, 0xad]), Uint8Array.from([0xbe, 0xef]));
304
+ utils.nLength(255n);
305
+ utils.hashToPrivateScalar(sha512_of_something, secp256r1.n);
306
+ utils.equalBytes(Uint8Array.from([0xde]), Uint8Array.from([0xde]));
307
+ ```
308
+
309
+ ## Security
310
+
311
+ The library had no prior security audit.
312
+
313
+ [Timing attack](https://en.wikipedia.org/wiki/Timing_attack) considerations: _JIT-compiler_ and _Garbage Collector_ make "constant time" extremely hard to achieve in a scripting language. Which means _any other JS library can't have constant-timeness_. Even statically typed Rust, a language without GC, [makes it harder to achieve constant-time](https://www.chosenplaintext.ca/open-source/rust-timing-shield/security) for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones. Use low-level libraries & languages. Nonetheless we're targetting algorithmic constant time.
314
+
315
+ We consider infrastructure attacks like rogue NPM modules very important; that's why it's crucial to minimize the amount of 3rd-party dependencies & native bindings. If your app uses 500 dependencies, any dep could get hacked and you'll be downloading malware with every `npm install`. Our goal is to minimize this attack vector.
316
+
317
+ ## Speed
318
+
319
+ Benchmark results on Apple M2 with node v18.10:
320
+
321
+ ```
322
+ ==== secp256k1 ====
323
+ - getPublicKey1 (samples: 10000)
324
+ noble_old x 8,131 ops/sec @ 122μs/op
325
+ secp256k1 x 7,374 ops/sec @ 135μs/op
326
+ - getPublicKey255 (samples: 10000)
327
+ noble_old x 7,894 ops/sec @ 126μs/op
328
+ secp256k1 x 7,327 ops/sec @ 136μs/op
329
+ - sign (samples: 5000)
330
+ noble_old x 5,243 ops/sec @ 190μs/op
331
+ secp256k1 x 4,834 ops/sec @ 206μs/op
332
+ - getSharedSecret (samples: 1000)
333
+ noble_old x 653 ops/sec @ 1ms/op
334
+ secp256k1 x 634 ops/sec @ 1ms/op
335
+ - verify (samples: 1000)
336
+ secp256k1_old x 1,038 ops/sec @ 962μs/op
337
+ secp256k1 x 1,009 ops/sec @ 990μs/op
338
+ ==== ed25519 ====
339
+ - getPublicKey (samples: 10000)
340
+ old x 8,632 ops/sec @ 115μs/op
341
+ noble x 8,390 ops/sec @ 119μs/op
342
+ - sign (samples: 5000)
343
+ old x 4,376 ops/sec @ 228μs/op
344
+ noble x 4,233 ops/sec @ 236μs/op
345
+ - verify (samples: 1000)
346
+ old x 865 ops/sec @ 1ms/op
347
+ noble x 860 ops/sec @ 1ms/op
348
+ ==== ed448 ====
349
+ - getPublicKey (samples: 5000)
350
+ noble x 3,224 ops/sec @ 310μs/op
351
+ - sign (samples: 2500)
352
+ noble x 1,561 ops/sec @ 640μs/op
353
+ - verify (samples: 500)
354
+ noble x 313 ops/sec @ 3ms/op
355
+ ==== nist ====
356
+ - getPublicKey (samples: 2500)
357
+ P256 x 7,993 ops/sec @ 125μs/op
358
+ P384 x 3,819 ops/sec @ 261μs/op
359
+ P521 x 2,074 ops/sec @ 481μs/op
360
+ - sign (samples: 1000)
361
+ P256 x 5,327 ops/sec @ 187μs/op
362
+ P384 x 2,728 ops/sec @ 366μs/op
363
+ P521 x 1,594 ops/sec @ 626μs/op
364
+ - verify (samples: 250)
365
+ P256 x 806 ops/sec @ 1ms/op
366
+ P384 x 353 ops/sec @ 2ms/op
367
+ P521 x 171 ops/sec @ 5ms/op
368
+ ==== stark ====
369
+ - pedersen (samples: 500)
370
+ old x 85 ops/sec @ 11ms/op
371
+ noble x 1,216 ops/sec @ 822μs/op
372
+ - verify (samples: 500)
373
+ old x 302 ops/sec @ 3ms/op
374
+ noble x 698 ops/sec @ 1ms/op
375
+ ```
376
+
377
+ ## Contributing & testing
378
+
379
+ 1. Clone the repository
380
+ 2. `npm install` to install build dependencies like TypeScript
381
+ 3. `npm run build` to compile TypeScript code
382
+ 4. `npm run test` will execute all main tests
383
+
69
384
  ## License
70
385
 
71
- MIT (c) Paul Miller [(https://paulmillr.com)](https://paulmillr.com), see LICENSE file.
386
+ The MIT License (MIT)
387
+
388
+ Copyright (c) 2022 Paul Miller [(https://paulmillr.com)](https://paulmillr.com)
389
+
390
+ See LICENSE file.
@@ -0,0 +1,108 @@
1
+ /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
2
+ import { BasicCurve, Hex, PrivKey } from './utils.js';
3
+ import { Group, GroupConstructor } from './group.js';
4
+ export declare type CHash = {
5
+ (message: Uint8Array | string): Uint8Array;
6
+ blockLen: number;
7
+ outputLen: number;
8
+ create(): any;
9
+ };
10
+ export declare type CurveType = BasicCurve & {
11
+ a: bigint;
12
+ d: bigint;
13
+ hash: CHash;
14
+ randomBytes: (bytesLength?: number) => Uint8Array;
15
+ adjustScalarBytes?: (bytes: Uint8Array) => Uint8Array;
16
+ domain?: (data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array;
17
+ uvRatio?: (u: bigint, v: bigint) => {
18
+ isValid: boolean;
19
+ value: bigint;
20
+ };
21
+ preHash?: CHash;
22
+ };
23
+ declare function validateOpts(curve: CurveType): Readonly<{
24
+ readonly nBitLength: number;
25
+ readonly nByteLength: number;
26
+ readonly P: bigint;
27
+ readonly n: bigint;
28
+ readonly h: bigint;
29
+ readonly Gx: bigint;
30
+ readonly Gy: bigint;
31
+ readonly a: bigint;
32
+ readonly d: bigint;
33
+ readonly hash: CHash;
34
+ readonly randomBytes: (bytesLength?: number | undefined) => Uint8Array;
35
+ readonly adjustScalarBytes?: ((bytes: Uint8Array) => Uint8Array) | undefined;
36
+ readonly domain?: ((data: Uint8Array, ctx: Uint8Array, phflag: boolean) => Uint8Array) | undefined;
37
+ readonly uvRatio?: ((u: bigint, v: bigint) => {
38
+ isValid: boolean;
39
+ value: bigint;
40
+ }) | undefined;
41
+ readonly preHash?: CHash | undefined;
42
+ }>;
43
+ export interface SignatureType {
44
+ readonly r: PointType;
45
+ readonly s: bigint;
46
+ assertValidity(): SignatureType;
47
+ toRawBytes(): Uint8Array;
48
+ toHex(): string;
49
+ }
50
+ export declare type SignatureConstructor = {
51
+ new (r: PointType, s: bigint): SignatureType;
52
+ fromHex(hex: Hex): SignatureType;
53
+ };
54
+ export interface ExtendedPointType extends Group<ExtendedPointType> {
55
+ readonly x: bigint;
56
+ readonly y: bigint;
57
+ readonly z: bigint;
58
+ readonly t: bigint;
59
+ multiply(scalar: number | bigint, affinePoint?: PointType): ExtendedPointType;
60
+ multiplyUnsafe(scalar: number | bigint): ExtendedPointType;
61
+ isSmallOrder(): boolean;
62
+ isTorsionFree(): boolean;
63
+ toAffine(invZ?: bigint): PointType;
64
+ }
65
+ export interface ExtendedPointConstructor extends GroupConstructor<ExtendedPointType> {
66
+ new (x: bigint, y: bigint, z: bigint, t: bigint): ExtendedPointType;
67
+ fromAffine(p: PointType): ExtendedPointType;
68
+ toAffineBatch(points: ExtendedPointType[]): PointType[];
69
+ normalizeZ(points: ExtendedPointType[]): ExtendedPointType[];
70
+ }
71
+ export interface PointType extends Group<PointType> {
72
+ readonly x: bigint;
73
+ readonly y: bigint;
74
+ _setWindowSize(windowSize: number): void;
75
+ toRawBytes(isCompressed?: boolean): Uint8Array;
76
+ toHex(isCompressed?: boolean): string;
77
+ isTorsionFree(): boolean;
78
+ }
79
+ export interface PointConstructor extends GroupConstructor<PointType> {
80
+ new (x: bigint, y: bigint): PointType;
81
+ fromHex(hex: Hex): PointType;
82
+ fromPrivateKey(privateKey: PrivKey): PointType;
83
+ }
84
+ export declare type PubKey = Hex | PointType;
85
+ export declare type SigType = Hex | SignatureType;
86
+ export declare type CurveFn = {
87
+ CURVE: ReturnType<typeof validateOpts>;
88
+ getPublicKey: (privateKey: PrivKey, isCompressed?: boolean) => Uint8Array;
89
+ sign: (message: Hex, privateKey: Hex) => Uint8Array;
90
+ verify: (sig: SigType, message: Hex, publicKey: PubKey) => boolean;
91
+ Point: PointConstructor;
92
+ ExtendedPoint: ExtendedPointConstructor;
93
+ Signature: SignatureConstructor;
94
+ utils: {
95
+ mod: (a: bigint, b?: bigint) => bigint;
96
+ invert: (number: bigint, modulo?: bigint) => bigint;
97
+ randomPrivateKey: () => Uint8Array;
98
+ getExtendedPublicKey: (key: PrivKey) => {
99
+ head: Uint8Array;
100
+ prefix: Uint8Array;
101
+ scalar: bigint;
102
+ point: PointType;
103
+ pointBytes: Uint8Array;
104
+ };
105
+ };
106
+ };
107
+ export declare function twistedEdwards(curveDef: CurveType): CurveFn;
108
+ export {};