@solana/webcrypto-ed25519-polyfill 2.0.0-experimental.d6c3cfe → 2.0.0-experimental.d93f1ad
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.
|
@@ -1,27 +1,13 @@
|
|
|
1
1
|
(function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.3.
|
|
5
|
-
function number(n) {
|
|
6
|
-
if (!Number.isSafeInteger(n) || n < 0)
|
|
7
|
-
throw new Error(`Wrong positive integer: ${n}`);
|
|
8
|
-
}
|
|
9
|
-
function bool(b) {
|
|
10
|
-
if (typeof b !== "boolean")
|
|
11
|
-
throw new Error(`Expected boolean, not ${b}`);
|
|
12
|
-
}
|
|
4
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.3.2/node_modules/@noble/hashes/esm/_assert.js
|
|
13
5
|
function bytes(b, ...lengths) {
|
|
14
6
|
if (!(b instanceof Uint8Array))
|
|
15
7
|
throw new Error("Expected Uint8Array");
|
|
16
8
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
17
9
|
throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
|
|
18
10
|
}
|
|
19
|
-
function hash(hash2) {
|
|
20
|
-
if (typeof hash2 !== "function" || typeof hash2.create !== "function")
|
|
21
|
-
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
22
|
-
number(hash2.outputLen);
|
|
23
|
-
number(hash2.blockLen);
|
|
24
|
-
}
|
|
25
11
|
function exists(instance, checkFinished = true) {
|
|
26
12
|
if (instance.destroyed)
|
|
27
13
|
throw new Error("Hash instance has been destroyed");
|
|
@@ -35,26 +21,16 @@
|
|
|
35
21
|
throw new Error(`digestInto() expects output buffer of length at least ${min}`);
|
|
36
22
|
}
|
|
37
23
|
}
|
|
38
|
-
var assert = {
|
|
39
|
-
number,
|
|
40
|
-
bool,
|
|
41
|
-
bytes,
|
|
42
|
-
hash,
|
|
43
|
-
exists,
|
|
44
|
-
output
|
|
45
|
-
};
|
|
46
|
-
var assert_default = assert;
|
|
47
24
|
|
|
48
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.3.
|
|
25
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.3.2/node_modules/@noble/hashes/esm/crypto.js
|
|
49
26
|
var crypto = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
50
27
|
|
|
51
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.3.
|
|
28
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.3.2/node_modules/@noble/hashes/esm/utils.js
|
|
52
29
|
var u8a = (a) => a instanceof Uint8Array;
|
|
53
30
|
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
54
31
|
var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
55
32
|
if (!isLE)
|
|
56
33
|
throw new Error("Non little-endian hardware is not supported");
|
|
57
|
-
Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, "0"));
|
|
58
34
|
function utf8ToBytes(str) {
|
|
59
35
|
if (typeof str !== "string")
|
|
60
36
|
throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
@@ -67,17 +43,6 @@
|
|
|
67
43
|
throw new Error(`expected Uint8Array, got ${typeof data}`);
|
|
68
44
|
return data;
|
|
69
45
|
}
|
|
70
|
-
function concatBytes(...arrays) {
|
|
71
|
-
const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
|
|
72
|
-
let pad = 0;
|
|
73
|
-
arrays.forEach((a) => {
|
|
74
|
-
if (!u8a(a))
|
|
75
|
-
throw new Error("Uint8Array expected");
|
|
76
|
-
r.set(a, pad);
|
|
77
|
-
pad += a.length;
|
|
78
|
-
});
|
|
79
|
-
return r;
|
|
80
|
-
}
|
|
81
46
|
var Hash = class {
|
|
82
47
|
// Safe version that clones internal state
|
|
83
48
|
clone() {
|
|
@@ -99,7 +64,7 @@
|
|
|
99
64
|
throw new Error("crypto.getRandomValues must be defined");
|
|
100
65
|
}
|
|
101
66
|
|
|
102
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.3.
|
|
67
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.3.2/node_modules/@noble/hashes/esm/_sha2.js
|
|
103
68
|
function setBigUint64(view, byteOffset, value, isLE2) {
|
|
104
69
|
if (typeof view.setBigUint64 === "function")
|
|
105
70
|
return view.setBigUint64(byteOffset, value, isLE2);
|
|
@@ -127,7 +92,7 @@
|
|
|
127
92
|
this.view = createView(this.buffer);
|
|
128
93
|
}
|
|
129
94
|
update(data) {
|
|
130
|
-
|
|
95
|
+
exists(this);
|
|
131
96
|
const { view, buffer, blockLen } = this;
|
|
132
97
|
data = toBytes(data);
|
|
133
98
|
const len = data.length;
|
|
@@ -152,8 +117,8 @@
|
|
|
152
117
|
return this;
|
|
153
118
|
}
|
|
154
119
|
digestInto(out) {
|
|
155
|
-
|
|
156
|
-
|
|
120
|
+
exists(this);
|
|
121
|
+
output(out, this);
|
|
157
122
|
this.finished = true;
|
|
158
123
|
const { buffer, view, blockLen, isLE: isLE2 } = this;
|
|
159
124
|
let { pos } = this;
|
|
@@ -199,9 +164,9 @@
|
|
|
199
164
|
}
|
|
200
165
|
};
|
|
201
166
|
|
|
202
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.3.
|
|
203
|
-
var U32_MASK64 = BigInt(2 ** 32 - 1);
|
|
204
|
-
var _32n = BigInt(32);
|
|
167
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.3.2/node_modules/@noble/hashes/esm/_u64.js
|
|
168
|
+
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
169
|
+
var _32n = /* @__PURE__ */ BigInt(32);
|
|
205
170
|
function fromBig(n, le = false) {
|
|
206
171
|
if (le)
|
|
207
172
|
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
@@ -217,14 +182,14 @@
|
|
|
217
182
|
return [Ah, Al];
|
|
218
183
|
}
|
|
219
184
|
var toBig = (h, l) => BigInt(h >>> 0) << _32n | BigInt(l >>> 0);
|
|
220
|
-
var shrSH = (h,
|
|
185
|
+
var shrSH = (h, _l, s) => h >>> s;
|
|
221
186
|
var shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
222
187
|
var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
223
188
|
var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
224
189
|
var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
225
190
|
var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
226
|
-
var rotr32H = (
|
|
227
|
-
var rotr32L = (h,
|
|
191
|
+
var rotr32H = (_h, l) => l;
|
|
192
|
+
var rotr32L = (h, _l) => h;
|
|
228
193
|
var rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
229
194
|
var rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
230
195
|
var rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
@@ -265,8 +230,8 @@
|
|
|
265
230
|
};
|
|
266
231
|
var u64_default = u64;
|
|
267
232
|
|
|
268
|
-
// ../../node_modules/.pnpm/@noble+hashes@1.3.
|
|
269
|
-
var [SHA512_Kh, SHA512_Kl] = u64_default.split([
|
|
233
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.3.2/node_modules/@noble/hashes/esm/sha512.js
|
|
234
|
+
var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64_default.split([
|
|
270
235
|
"0x428a2f98d728ae22",
|
|
271
236
|
"0x7137449123ef65cd",
|
|
272
237
|
"0xb5c0fbcfec4d3b2f",
|
|
@@ -347,9 +312,9 @@
|
|
|
347
312
|
"0x597f299cfc657e2a",
|
|
348
313
|
"0x5fcb6fab3ad6faec",
|
|
349
314
|
"0x6c44198c4a475817"
|
|
350
|
-
].map((n) => BigInt(n)));
|
|
351
|
-
var SHA512_W_H = new Uint32Array(80);
|
|
352
|
-
var SHA512_W_L = new Uint32Array(80);
|
|
315
|
+
].map((n) => BigInt(n))))();
|
|
316
|
+
var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
317
|
+
var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
353
318
|
var SHA512 = class extends SHA2 {
|
|
354
319
|
constructor() {
|
|
355
320
|
super(128, 64, 16, false);
|
|
@@ -462,89 +427,20 @@
|
|
|
462
427
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
463
428
|
}
|
|
464
429
|
};
|
|
465
|
-
var
|
|
466
|
-
constructor() {
|
|
467
|
-
super();
|
|
468
|
-
this.Ah = 2352822216 | 0;
|
|
469
|
-
this.Al = 424955298 | 0;
|
|
470
|
-
this.Bh = 1944164710 | 0;
|
|
471
|
-
this.Bl = 2312950998 | 0;
|
|
472
|
-
this.Ch = 502970286 | 0;
|
|
473
|
-
this.Cl = 855612546 | 0;
|
|
474
|
-
this.Dh = 1738396948 | 0;
|
|
475
|
-
this.Dl = 1479516111 | 0;
|
|
476
|
-
this.Eh = 258812777 | 0;
|
|
477
|
-
this.El = 2077511080 | 0;
|
|
478
|
-
this.Fh = 2011393907 | 0;
|
|
479
|
-
this.Fl = 79989058 | 0;
|
|
480
|
-
this.Gh = 1067287976 | 0;
|
|
481
|
-
this.Gl = 1780299464 | 0;
|
|
482
|
-
this.Hh = 286451373 | 0;
|
|
483
|
-
this.Hl = 2446758561 | 0;
|
|
484
|
-
this.outputLen = 28;
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
var SHA512_256 = class extends SHA512 {
|
|
488
|
-
constructor() {
|
|
489
|
-
super();
|
|
490
|
-
this.Ah = 573645204 | 0;
|
|
491
|
-
this.Al = 4230739756 | 0;
|
|
492
|
-
this.Bh = 2673172387 | 0;
|
|
493
|
-
this.Bl = 3360449730 | 0;
|
|
494
|
-
this.Ch = 596883563 | 0;
|
|
495
|
-
this.Cl = 1867755857 | 0;
|
|
496
|
-
this.Dh = 2520282905 | 0;
|
|
497
|
-
this.Dl = 1497426621 | 0;
|
|
498
|
-
this.Eh = 2519219938 | 0;
|
|
499
|
-
this.El = 2827943907 | 0;
|
|
500
|
-
this.Fh = 3193839141 | 0;
|
|
501
|
-
this.Fl = 1401305490 | 0;
|
|
502
|
-
this.Gh = 721525244 | 0;
|
|
503
|
-
this.Gl = 746961066 | 0;
|
|
504
|
-
this.Hh = 246885852 | 0;
|
|
505
|
-
this.Hl = 2177182882 | 0;
|
|
506
|
-
this.outputLen = 32;
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
var SHA384 = class extends SHA512 {
|
|
510
|
-
constructor() {
|
|
511
|
-
super();
|
|
512
|
-
this.Ah = 3418070365 | 0;
|
|
513
|
-
this.Al = 3238371032 | 0;
|
|
514
|
-
this.Bh = 1654270250 | 0;
|
|
515
|
-
this.Bl = 914150663 | 0;
|
|
516
|
-
this.Ch = 2438529370 | 0;
|
|
517
|
-
this.Cl = 812702999 | 0;
|
|
518
|
-
this.Dh = 355462360 | 0;
|
|
519
|
-
this.Dl = 4144912697 | 0;
|
|
520
|
-
this.Eh = 1731405415 | 0;
|
|
521
|
-
this.El = 4290775857 | 0;
|
|
522
|
-
this.Fh = 2394180231 | 0;
|
|
523
|
-
this.Fl = 1750603025 | 0;
|
|
524
|
-
this.Gh = 3675008525 | 0;
|
|
525
|
-
this.Gl = 1694076839 | 0;
|
|
526
|
-
this.Hh = 1203062813 | 0;
|
|
527
|
-
this.Hl = 3204075428 | 0;
|
|
528
|
-
this.outputLen = 48;
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
var sha512 = wrapConstructor(() => new SHA512());
|
|
532
|
-
wrapConstructor(() => new SHA512_224());
|
|
533
|
-
wrapConstructor(() => new SHA512_256());
|
|
534
|
-
wrapConstructor(() => new SHA384());
|
|
430
|
+
var sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA512());
|
|
535
431
|
|
|
536
|
-
// ../../node_modules/.pnpm/@noble+curves@1.
|
|
432
|
+
// ../../node_modules/.pnpm/@noble+curves@1.2.0/node_modules/@noble/curves/esm/abstract/utils.js
|
|
537
433
|
BigInt(0);
|
|
538
434
|
var _1n = BigInt(1);
|
|
539
435
|
var _2n = BigInt(2);
|
|
540
436
|
var u8a2 = (a) => a instanceof Uint8Array;
|
|
541
|
-
var
|
|
437
|
+
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
|
542
438
|
function bytesToHex(bytes2) {
|
|
543
439
|
if (!u8a2(bytes2))
|
|
544
440
|
throw new Error("Uint8Array expected");
|
|
545
441
|
let hex = "";
|
|
546
442
|
for (let i = 0; i < bytes2.length; i++) {
|
|
547
|
-
hex +=
|
|
443
|
+
hex += hexes[bytes2[i]];
|
|
548
444
|
}
|
|
549
445
|
return hex;
|
|
550
446
|
}
|
|
@@ -619,6 +515,7 @@
|
|
|
619
515
|
function: (val) => typeof val === "function",
|
|
620
516
|
boolean: (val) => typeof val === "boolean",
|
|
621
517
|
string: (val) => typeof val === "string",
|
|
518
|
+
stringOrUint8Array: (val) => typeof val === "string" || val instanceof Uint8Array,
|
|
622
519
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
623
520
|
array: (val) => Array.isArray(val),
|
|
624
521
|
field: (val, object) => object.Fp.isValid(val),
|
|
@@ -643,7 +540,7 @@
|
|
|
643
540
|
return object;
|
|
644
541
|
}
|
|
645
542
|
|
|
646
|
-
// ../../node_modules/.pnpm/@noble+curves@1.
|
|
543
|
+
// ../../node_modules/.pnpm/@noble+curves@1.2.0/node_modules/@noble/curves/esm/abstract/modular.js
|
|
647
544
|
var _0n2 = BigInt(0);
|
|
648
545
|
var _1n2 = BigInt(1);
|
|
649
546
|
var _2n2 = BigInt(2);
|
|
@@ -679,11 +576,11 @@
|
|
|
679
576
|
}
|
|
680
577
|
return res;
|
|
681
578
|
}
|
|
682
|
-
function invert(
|
|
683
|
-
if (
|
|
684
|
-
throw new Error(`invert: expected positive integers, got n=${
|
|
579
|
+
function invert(number, modulo) {
|
|
580
|
+
if (number === _0n2 || modulo <= _0n2) {
|
|
581
|
+
throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);
|
|
685
582
|
}
|
|
686
|
-
let a = mod(
|
|
583
|
+
let a = mod(number, modulo);
|
|
687
584
|
let b = modulo;
|
|
688
585
|
let x = _0n2, u = _1n2;
|
|
689
586
|
while (a !== _0n2) {
|
|
@@ -838,7 +735,7 @@
|
|
|
838
735
|
}
|
|
839
736
|
function Field(ORDER, bitLen, isLE2 = false, redef = {}) {
|
|
840
737
|
if (ORDER <= _0n2)
|
|
841
|
-
throw new Error(`Expected
|
|
738
|
+
throw new Error(`Expected Field ORDER > 0, got ${ORDER}`);
|
|
842
739
|
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen);
|
|
843
740
|
if (BYTES > 2048)
|
|
844
741
|
throw new Error("Field lengths over 2048 bytes are not supported");
|
|
@@ -893,7 +790,7 @@
|
|
|
893
790
|
return Fp2.isOdd(root) ? Fp2.neg(root) : root;
|
|
894
791
|
}
|
|
895
792
|
|
|
896
|
-
// ../../node_modules/.pnpm/@noble+curves@1.
|
|
793
|
+
// ../../node_modules/.pnpm/@noble+curves@1.2.0/node_modules/@noble/curves/esm/abstract/curve.js
|
|
897
794
|
var _0n3 = BigInt(0);
|
|
898
795
|
var _1n3 = BigInt(1);
|
|
899
796
|
function wNAF(c, bits) {
|
|
@@ -1011,7 +908,7 @@
|
|
|
1011
908
|
});
|
|
1012
909
|
}
|
|
1013
910
|
|
|
1014
|
-
// ../../node_modules/.pnpm/@noble+curves@1.
|
|
911
|
+
// ../../node_modules/.pnpm/@noble+curves@1.2.0/node_modules/@noble/curves/esm/abstract/edwards.js
|
|
1015
912
|
var _0n4 = BigInt(0);
|
|
1016
913
|
var _1n4 = BigInt(1);
|
|
1017
914
|
var _2n3 = BigInt(2);
|
|
@@ -1311,8 +1208,8 @@
|
|
|
1311
1208
|
function modN(a) {
|
|
1312
1209
|
return mod(a, CURVE_ORDER);
|
|
1313
1210
|
}
|
|
1314
|
-
function modN_LE(
|
|
1315
|
-
return modN(bytesToNumberLE(
|
|
1211
|
+
function modN_LE(hash) {
|
|
1212
|
+
return modN(bytesToNumberLE(hash));
|
|
1316
1213
|
}
|
|
1317
1214
|
function getExtendedPublicKey(key) {
|
|
1318
1215
|
const len = nByteLength;
|
|
@@ -1395,15 +1292,11 @@
|
|
|
1395
1292
|
};
|
|
1396
1293
|
}
|
|
1397
1294
|
|
|
1398
|
-
// ../../node_modules/.pnpm/@noble+curves@1.
|
|
1399
|
-
BigInt(0);
|
|
1400
|
-
BigInt(1);
|
|
1401
|
-
|
|
1402
|
-
// ../../node_modules/.pnpm/@noble+curves@1.1.0/node_modules/@noble/curves/esm/ed25519.js
|
|
1295
|
+
// ../../node_modules/.pnpm/@noble+curves@1.2.0/node_modules/@noble/curves/esm/ed25519.js
|
|
1403
1296
|
var ED25519_P = BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");
|
|
1404
1297
|
var ED25519_SQRT_M1 = BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
1405
1298
|
BigInt(0);
|
|
1406
|
-
var
|
|
1299
|
+
var _1n5 = BigInt(1);
|
|
1407
1300
|
var _2n4 = BigInt(2);
|
|
1408
1301
|
var _5n2 = BigInt(5);
|
|
1409
1302
|
var _10n = BigInt(10);
|
|
@@ -1415,7 +1308,7 @@
|
|
|
1415
1308
|
const x2 = x * x % P;
|
|
1416
1309
|
const b2 = x2 * x % P;
|
|
1417
1310
|
const b4 = pow2(b2, _2n4, P) * b2 % P;
|
|
1418
|
-
const b5 = pow2(b4,
|
|
1311
|
+
const b5 = pow2(b4, _1n5, P) * x % P;
|
|
1419
1312
|
const b10 = pow2(b5, _5n2, P) * b5 % P;
|
|
1420
1313
|
const b20 = pow2(b10, _10n, P) * b10 % P;
|
|
1421
1314
|
const b40 = pow2(b20, _20n, P) * b20 % P;
|
|
@@ -1477,18 +1370,7 @@
|
|
|
1477
1370
|
// Constant-time, u/√v
|
|
1478
1371
|
uvRatio
|
|
1479
1372
|
};
|
|
1480
|
-
var ed25519 = twistedEdwards(ed25519Defaults);
|
|
1481
|
-
function ed25519_domain(data, ctx, phflag) {
|
|
1482
|
-
if (ctx.length > 255)
|
|
1483
|
-
throw new Error("Context is too big");
|
|
1484
|
-
return concatBytes(utf8ToBytes("SigEd25519 no Ed25519 collisions"), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
1485
|
-
}
|
|
1486
|
-
twistedEdwards({ ...ed25519Defaults, domain: ed25519_domain });
|
|
1487
|
-
twistedEdwards({
|
|
1488
|
-
...ed25519Defaults,
|
|
1489
|
-
domain: ed25519_domain,
|
|
1490
|
-
prehash: sha512
|
|
1491
|
-
});
|
|
1373
|
+
var ed25519 = /* @__PURE__ */ twistedEdwards(ed25519Defaults);
|
|
1492
1374
|
var ELL2_C1 = (Fp.ORDER + BigInt(3)) / BigInt(8);
|
|
1493
1375
|
Fp.pow(_2n4, ELL2_C1);
|
|
1494
1376
|
Fp.sqrt(Fp.neg(Fp.ONE));
|
|
@@ -1705,9 +1587,6 @@
|
|
|
1705
1587
|
@noble/curves/esm/abstract/edwards.js:
|
|
1706
1588
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1707
1589
|
|
|
1708
|
-
@noble/curves/esm/abstract/montgomery.js:
|
|
1709
|
-
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1710
|
-
|
|
1711
1590
|
@noble/curves/esm/ed25519.js:
|
|
1712
1591
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1713
1592
|
*/
|