x402-proxy 0.10.7 → 0.10.9
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/CHANGELOG.md +23 -1
- package/README.md +7 -1
- package/dist/Credential-COZQnr1-.js +2055 -0
- package/dist/Mcp-CrCEqLqO.js +10 -0
- package/dist/Sse-ChldYgU7.js +9742 -0
- package/dist/Sse-kCB38G56.js +16482 -0
- package/dist/accounts-DsuvWwph.js +232 -0
- package/dist/accounts-DzvAlQRn.js +5 -0
- package/dist/accounts-IG-Cmrwy.js +229 -0
- package/dist/api-CUzmQvTQ.js +2802 -0
- package/dist/auth-DTzQmnZ_.js +1196 -0
- package/dist/bin/cli.js +585 -242
- package/dist/ccip-Bx-zoUCJ.js +240 -0
- package/dist/ccip-C2k1DD1T.js +153 -0
- package/dist/ccip-C6CQOJYv.js +152 -0
- package/dist/ccip-RZzsZ5Mv.js +156 -0
- package/dist/chain-CafcHffR.js +1997 -0
- package/dist/chain-DwfP5RGZ.js +1968 -0
- package/dist/chunk-DBEY4PJZ.js +16 -0
- package/dist/chunk-DjEMn6fM.js +36 -0
- package/dist/client-Blw2V7LF.js +657 -0
- package/dist/client-C37gWJOZ.js +102 -0
- package/dist/client-CEc4NYAA.js +6388 -0
- package/dist/client-CVDTUY0l.js +5152 -0
- package/dist/config-BUQsit4s.js +3 -0
- package/dist/config-DR1Fs_wL.js +6600 -0
- package/dist/{config-D9wIR3xc.js → config-rvKA3SYT.js} +10 -5
- package/dist/decodeFunctionData-DuFcwhC_.js +4510 -0
- package/dist/decodeFunctionData-JPOUdvil.js +4394 -0
- package/dist/derive-DNUl8LU9.js +9109 -0
- package/dist/dist-C2YO6HSQ.js +6581 -0
- package/dist/dist-DM5_F3r5.js +4 -0
- package/dist/dist-DxJCYyL5.js +1388 -0
- package/dist/hashTypedData-BHmP9dBd.js +859 -0
- package/dist/hashTypedData-CtEdfx4y.js +846 -0
- package/dist/helpers-CuUSw-tH.js +7125 -0
- package/dist/hmac-59IlS_by.js +648 -0
- package/dist/http-BAtucMbS.js +2060 -0
- package/dist/index.d.ts +1903 -9
- package/dist/index.js +18006 -50
- package/dist/index.node-CxkL0OFh.js +3592 -0
- package/dist/index.node-DvmeuZBj.js +3 -0
- package/dist/isAddressEqual-BLrd1Hg1.js +9 -0
- package/dist/isAddressEqual-DsAqfQOD.js +10 -0
- package/dist/localBatchGatewayRequest-C-RPJyDO.js +6260 -0
- package/dist/localBatchGatewayRequest-DOdQ9bR7.js +93 -0
- package/dist/localBatchGatewayRequest-DQkbZaSy.js +6261 -0
- package/dist/parseUnits-CApwcKSD.js +49 -0
- package/dist/parseUnits-cMO2udMe.js +48 -0
- package/dist/schemas-BxMFYNbH.js +1270 -0
- package/dist/secp256k1-BZpiyffY.js +2525 -0
- package/dist/secp256k1-BjenrLl5.js +1877 -0
- package/dist/secp256k1-CLPUX17u.js +3 -0
- package/dist/sendRawTransactionSync-DvSkhZtW.js +3612 -0
- package/dist/server-CSq0IuUq.js +565 -0
- package/dist/setup-BY4J49Lv.js +1110 -0
- package/dist/setup-wMOAgrsN.js +3 -0
- package/dist/sha256-FAs0qeni.js +17 -0
- package/dist/sha3-CYkWM8Xa.js +195 -0
- package/dist/sha3-DbMJRJ3C.js +194 -0
- package/dist/sse-B4LLqBQm.js +408 -0
- package/dist/status-Bu23RjW6.js +3 -0
- package/dist/{status-DihAcUSC.js → status-X21VnGUO.js} +16 -15
- package/dist/stdio-BADqxZdZ.js +85 -0
- package/dist/streamableHttp-BHkJypcI.js +358 -0
- package/dist/tempo-3nttrxgQ.js +17 -0
- package/dist/tempo-DER0P-ul.js +18 -0
- package/dist/types-BEKUz-Mf.js +1240 -0
- package/dist/types-DatK5vR5.js +3 -0
- package/dist/utils-BYjkXZDF.js +444 -0
- package/dist/utils-SeGHMW9O.js +445 -0
- package/dist/wallet-DKVlrR1S.js +3 -0
- package/dist/wallet-DSyht15_.js +17759 -0
- package/package.json +18 -71
- package/dist/config-B_upkJeK.js +0 -66
- package/dist/config-Be35NM5s.js +0 -3
- package/dist/config-J1m-CWXT.js +0 -27
- package/dist/derive-CL6e8K0Z.js +0 -81
- package/dist/openclaw/plugin.d.ts +0 -15
- package/dist/openclaw/plugin.js +0 -2067
- package/dist/openclaw.plugin.json +0 -93
- package/dist/setup-CNyMLnM-.js +0 -197
- package/dist/setup-DTIxPe58.js +0 -3
- package/dist/status-DZlJ4pS7.js +0 -3
- package/dist/wallet-B0S-rma9.js +0 -544
- package/dist/wallet-DBrVZJqe.js +0 -3
- package/openclaw.plugin.json +0 -93
- package/skills/SKILL.md +0 -183
- package/skills/references/library.md +0 -85
- package/skills/references/openclaw-plugin.md +0 -145
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { $ as shrSH, A as createHasher, B as add3L, C as abytes, D as aoutput, H as add4L, I as toBytes, O as clean, P as rotr, Q as rotrSL, R as add, S as Hash, T as ahash, U as add5H, V as add4H, W as add5L, X as rotrBL, Y as rotrBH, Z as rotrSH, et as shrSL, j as createView, tt as split, w as aexists, z as add3H } from "./utils-SeGHMW9O.js";
|
|
3
|
+
//#region node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
|
|
4
|
+
/**
|
|
5
|
+
* Internal Merkle-Damgard hash utils.
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
/** Polyfill for Safari 14. https://caniuse.com/mdn-javascript_builtins_dataview_setbiguint64 */
|
|
9
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
10
|
+
if (typeof view.setBigUint64 === "function") return view.setBigUint64(byteOffset, value, isLE);
|
|
11
|
+
const _32n = BigInt(32);
|
|
12
|
+
const _u32_max = BigInt(4294967295);
|
|
13
|
+
const wh = Number(value >> _32n & _u32_max);
|
|
14
|
+
const wl = Number(value & _u32_max);
|
|
15
|
+
const h = isLE ? 4 : 0;
|
|
16
|
+
const l = isLE ? 0 : 4;
|
|
17
|
+
view.setUint32(byteOffset + h, wh, isLE);
|
|
18
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
|
19
|
+
}
|
|
20
|
+
/** Choice: a ? b : c */
|
|
21
|
+
function Chi(a, b, c) {
|
|
22
|
+
return a & b ^ ~a & c;
|
|
23
|
+
}
|
|
24
|
+
/** Majority function, true if any two inputs is true. */
|
|
25
|
+
function Maj(a, b, c) {
|
|
26
|
+
return a & b ^ a & c ^ b & c;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Merkle-Damgard hash construction base class.
|
|
30
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
31
|
+
*/
|
|
32
|
+
var HashMD = class extends Hash {
|
|
33
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
34
|
+
super();
|
|
35
|
+
this.finished = false;
|
|
36
|
+
this.length = 0;
|
|
37
|
+
this.pos = 0;
|
|
38
|
+
this.destroyed = false;
|
|
39
|
+
this.blockLen = blockLen;
|
|
40
|
+
this.outputLen = outputLen;
|
|
41
|
+
this.padOffset = padOffset;
|
|
42
|
+
this.isLE = isLE;
|
|
43
|
+
this.buffer = new Uint8Array(blockLen);
|
|
44
|
+
this.view = createView(this.buffer);
|
|
45
|
+
}
|
|
46
|
+
update(data) {
|
|
47
|
+
aexists(this);
|
|
48
|
+
data = toBytes(data);
|
|
49
|
+
abytes(data);
|
|
50
|
+
const { view, buffer, blockLen } = this;
|
|
51
|
+
const len = data.length;
|
|
52
|
+
for (let pos = 0; pos < len;) {
|
|
53
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
54
|
+
if (take === blockLen) {
|
|
55
|
+
const dataView = createView(data);
|
|
56
|
+
for (; blockLen <= len - pos; pos += blockLen) this.process(dataView, pos);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
60
|
+
this.pos += take;
|
|
61
|
+
pos += take;
|
|
62
|
+
if (this.pos === blockLen) {
|
|
63
|
+
this.process(view, 0);
|
|
64
|
+
this.pos = 0;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this.length += data.length;
|
|
68
|
+
this.roundClean();
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
digestInto(out) {
|
|
72
|
+
aexists(this);
|
|
73
|
+
aoutput(out, this);
|
|
74
|
+
this.finished = true;
|
|
75
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
76
|
+
let { pos } = this;
|
|
77
|
+
buffer[pos++] = 128;
|
|
78
|
+
clean(this.buffer.subarray(pos));
|
|
79
|
+
if (this.padOffset > blockLen - pos) {
|
|
80
|
+
this.process(view, 0);
|
|
81
|
+
pos = 0;
|
|
82
|
+
}
|
|
83
|
+
for (let i = pos; i < blockLen; i++) buffer[i] = 0;
|
|
84
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
85
|
+
this.process(view, 0);
|
|
86
|
+
const oview = createView(out);
|
|
87
|
+
const len = this.outputLen;
|
|
88
|
+
if (len % 4) throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
89
|
+
const outLen = len / 4;
|
|
90
|
+
const state = this.get();
|
|
91
|
+
if (outLen > state.length) throw new Error("_sha2: outputLen bigger than state");
|
|
92
|
+
for (let i = 0; i < outLen; i++) oview.setUint32(4 * i, state[i], isLE);
|
|
93
|
+
}
|
|
94
|
+
digest() {
|
|
95
|
+
const { buffer, outputLen } = this;
|
|
96
|
+
this.digestInto(buffer);
|
|
97
|
+
const res = buffer.slice(0, outputLen);
|
|
98
|
+
this.destroy();
|
|
99
|
+
return res;
|
|
100
|
+
}
|
|
101
|
+
_cloneInto(to) {
|
|
102
|
+
to || (to = new this.constructor());
|
|
103
|
+
to.set(...this.get());
|
|
104
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
105
|
+
to.destroyed = destroyed;
|
|
106
|
+
to.finished = finished;
|
|
107
|
+
to.length = length;
|
|
108
|
+
to.pos = pos;
|
|
109
|
+
if (length % blockLen) to.buffer.set(buffer);
|
|
110
|
+
return to;
|
|
111
|
+
}
|
|
112
|
+
clone() {
|
|
113
|
+
return this._cloneInto();
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
118
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
119
|
+
*/
|
|
120
|
+
/** Initial SHA256 state. Bits 0..32 of frac part of sqrt of primes 2..19 */
|
|
121
|
+
const SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
122
|
+
1779033703,
|
|
123
|
+
3144134277,
|
|
124
|
+
1013904242,
|
|
125
|
+
2773480762,
|
|
126
|
+
1359893119,
|
|
127
|
+
2600822924,
|
|
128
|
+
528734635,
|
|
129
|
+
1541459225
|
|
130
|
+
]);
|
|
131
|
+
/** Initial SHA384 state. Bits 0..64 of frac part of sqrt of primes 23..53 */
|
|
132
|
+
const SHA384_IV = /* @__PURE__ */ Uint32Array.from([
|
|
133
|
+
3418070365,
|
|
134
|
+
3238371032,
|
|
135
|
+
1654270250,
|
|
136
|
+
914150663,
|
|
137
|
+
2438529370,
|
|
138
|
+
812702999,
|
|
139
|
+
355462360,
|
|
140
|
+
4144912697,
|
|
141
|
+
1731405415,
|
|
142
|
+
4290775857,
|
|
143
|
+
2394180231,
|
|
144
|
+
1750603025,
|
|
145
|
+
3675008525,
|
|
146
|
+
1694076839,
|
|
147
|
+
1203062813,
|
|
148
|
+
3204075428
|
|
149
|
+
]);
|
|
150
|
+
/** Initial SHA512 state. Bits 0..64 of frac part of sqrt of primes 2..19 */
|
|
151
|
+
const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
152
|
+
1779033703,
|
|
153
|
+
4089235720,
|
|
154
|
+
3144134277,
|
|
155
|
+
2227873595,
|
|
156
|
+
1013904242,
|
|
157
|
+
4271175723,
|
|
158
|
+
2773480762,
|
|
159
|
+
1595750129,
|
|
160
|
+
1359893119,
|
|
161
|
+
2917565137,
|
|
162
|
+
2600822924,
|
|
163
|
+
725511199,
|
|
164
|
+
528734635,
|
|
165
|
+
4215389547,
|
|
166
|
+
1541459225,
|
|
167
|
+
327033209
|
|
168
|
+
]);
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
|
|
171
|
+
/**
|
|
172
|
+
* SHA2 hash function. A.k.a. sha256, sha384, sha512, sha512_224, sha512_256.
|
|
173
|
+
* SHA256 is the fastest hash implementable in JS, even faster than Blake3.
|
|
174
|
+
* Check out [RFC 4634](https://datatracker.ietf.org/doc/html/rfc4634) and
|
|
175
|
+
* [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf).
|
|
176
|
+
* @module
|
|
177
|
+
*/
|
|
178
|
+
/**
|
|
179
|
+
* Round constants:
|
|
180
|
+
* First 32 bits of fractional parts of the cube roots of the first 64 primes 2..311)
|
|
181
|
+
*/
|
|
182
|
+
const SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
183
|
+
1116352408,
|
|
184
|
+
1899447441,
|
|
185
|
+
3049323471,
|
|
186
|
+
3921009573,
|
|
187
|
+
961987163,
|
|
188
|
+
1508970993,
|
|
189
|
+
2453635748,
|
|
190
|
+
2870763221,
|
|
191
|
+
3624381080,
|
|
192
|
+
310598401,
|
|
193
|
+
607225278,
|
|
194
|
+
1426881987,
|
|
195
|
+
1925078388,
|
|
196
|
+
2162078206,
|
|
197
|
+
2614888103,
|
|
198
|
+
3248222580,
|
|
199
|
+
3835390401,
|
|
200
|
+
4022224774,
|
|
201
|
+
264347078,
|
|
202
|
+
604807628,
|
|
203
|
+
770255983,
|
|
204
|
+
1249150122,
|
|
205
|
+
1555081692,
|
|
206
|
+
1996064986,
|
|
207
|
+
2554220882,
|
|
208
|
+
2821834349,
|
|
209
|
+
2952996808,
|
|
210
|
+
3210313671,
|
|
211
|
+
3336571891,
|
|
212
|
+
3584528711,
|
|
213
|
+
113926993,
|
|
214
|
+
338241895,
|
|
215
|
+
666307205,
|
|
216
|
+
773529912,
|
|
217
|
+
1294757372,
|
|
218
|
+
1396182291,
|
|
219
|
+
1695183700,
|
|
220
|
+
1986661051,
|
|
221
|
+
2177026350,
|
|
222
|
+
2456956037,
|
|
223
|
+
2730485921,
|
|
224
|
+
2820302411,
|
|
225
|
+
3259730800,
|
|
226
|
+
3345764771,
|
|
227
|
+
3516065817,
|
|
228
|
+
3600352804,
|
|
229
|
+
4094571909,
|
|
230
|
+
275423344,
|
|
231
|
+
430227734,
|
|
232
|
+
506948616,
|
|
233
|
+
659060556,
|
|
234
|
+
883997877,
|
|
235
|
+
958139571,
|
|
236
|
+
1322822218,
|
|
237
|
+
1537002063,
|
|
238
|
+
1747873779,
|
|
239
|
+
1955562222,
|
|
240
|
+
2024104815,
|
|
241
|
+
2227730452,
|
|
242
|
+
2361852424,
|
|
243
|
+
2428436474,
|
|
244
|
+
2756734187,
|
|
245
|
+
3204031479,
|
|
246
|
+
3329325298
|
|
247
|
+
]);
|
|
248
|
+
/** Reusable temporary buffer. "W" comes straight from spec. */
|
|
249
|
+
const SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
250
|
+
var SHA256 = class extends HashMD {
|
|
251
|
+
constructor(outputLen = 32) {
|
|
252
|
+
super(64, outputLen, 8, false);
|
|
253
|
+
this.A = SHA256_IV[0] | 0;
|
|
254
|
+
this.B = SHA256_IV[1] | 0;
|
|
255
|
+
this.C = SHA256_IV[2] | 0;
|
|
256
|
+
this.D = SHA256_IV[3] | 0;
|
|
257
|
+
this.E = SHA256_IV[4] | 0;
|
|
258
|
+
this.F = SHA256_IV[5] | 0;
|
|
259
|
+
this.G = SHA256_IV[6] | 0;
|
|
260
|
+
this.H = SHA256_IV[7] | 0;
|
|
261
|
+
}
|
|
262
|
+
get() {
|
|
263
|
+
const { A, B, C, D, E, F, G, H } = this;
|
|
264
|
+
return [
|
|
265
|
+
A,
|
|
266
|
+
B,
|
|
267
|
+
C,
|
|
268
|
+
D,
|
|
269
|
+
E,
|
|
270
|
+
F,
|
|
271
|
+
G,
|
|
272
|
+
H
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
set(A, B, C, D, E, F, G, H) {
|
|
276
|
+
this.A = A | 0;
|
|
277
|
+
this.B = B | 0;
|
|
278
|
+
this.C = C | 0;
|
|
279
|
+
this.D = D | 0;
|
|
280
|
+
this.E = E | 0;
|
|
281
|
+
this.F = F | 0;
|
|
282
|
+
this.G = G | 0;
|
|
283
|
+
this.H = H | 0;
|
|
284
|
+
}
|
|
285
|
+
process(view, offset) {
|
|
286
|
+
for (let i = 0; i < 16; i++, offset += 4) SHA256_W[i] = view.getUint32(offset, false);
|
|
287
|
+
for (let i = 16; i < 64; i++) {
|
|
288
|
+
const W15 = SHA256_W[i - 15];
|
|
289
|
+
const W2 = SHA256_W[i - 2];
|
|
290
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
291
|
+
SHA256_W[i] = (rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10) + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
292
|
+
}
|
|
293
|
+
let { A, B, C, D, E, F, G, H } = this;
|
|
294
|
+
for (let i = 0; i < 64; i++) {
|
|
295
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
296
|
+
const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
297
|
+
const T2 = (rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22)) + Maj(A, B, C) | 0;
|
|
298
|
+
H = G;
|
|
299
|
+
G = F;
|
|
300
|
+
F = E;
|
|
301
|
+
E = D + T1 | 0;
|
|
302
|
+
D = C;
|
|
303
|
+
C = B;
|
|
304
|
+
B = A;
|
|
305
|
+
A = T1 + T2 | 0;
|
|
306
|
+
}
|
|
307
|
+
A = A + this.A | 0;
|
|
308
|
+
B = B + this.B | 0;
|
|
309
|
+
C = C + this.C | 0;
|
|
310
|
+
D = D + this.D | 0;
|
|
311
|
+
E = E + this.E | 0;
|
|
312
|
+
F = F + this.F | 0;
|
|
313
|
+
G = G + this.G | 0;
|
|
314
|
+
H = H + this.H | 0;
|
|
315
|
+
this.set(A, B, C, D, E, F, G, H);
|
|
316
|
+
}
|
|
317
|
+
roundClean() {
|
|
318
|
+
clean(SHA256_W);
|
|
319
|
+
}
|
|
320
|
+
destroy() {
|
|
321
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
322
|
+
clean(this.buffer);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
const K512 = split([
|
|
326
|
+
"0x428a2f98d728ae22",
|
|
327
|
+
"0x7137449123ef65cd",
|
|
328
|
+
"0xb5c0fbcfec4d3b2f",
|
|
329
|
+
"0xe9b5dba58189dbbc",
|
|
330
|
+
"0x3956c25bf348b538",
|
|
331
|
+
"0x59f111f1b605d019",
|
|
332
|
+
"0x923f82a4af194f9b",
|
|
333
|
+
"0xab1c5ed5da6d8118",
|
|
334
|
+
"0xd807aa98a3030242",
|
|
335
|
+
"0x12835b0145706fbe",
|
|
336
|
+
"0x243185be4ee4b28c",
|
|
337
|
+
"0x550c7dc3d5ffb4e2",
|
|
338
|
+
"0x72be5d74f27b896f",
|
|
339
|
+
"0x80deb1fe3b1696b1",
|
|
340
|
+
"0x9bdc06a725c71235",
|
|
341
|
+
"0xc19bf174cf692694",
|
|
342
|
+
"0xe49b69c19ef14ad2",
|
|
343
|
+
"0xefbe4786384f25e3",
|
|
344
|
+
"0x0fc19dc68b8cd5b5",
|
|
345
|
+
"0x240ca1cc77ac9c65",
|
|
346
|
+
"0x2de92c6f592b0275",
|
|
347
|
+
"0x4a7484aa6ea6e483",
|
|
348
|
+
"0x5cb0a9dcbd41fbd4",
|
|
349
|
+
"0x76f988da831153b5",
|
|
350
|
+
"0x983e5152ee66dfab",
|
|
351
|
+
"0xa831c66d2db43210",
|
|
352
|
+
"0xb00327c898fb213f",
|
|
353
|
+
"0xbf597fc7beef0ee4",
|
|
354
|
+
"0xc6e00bf33da88fc2",
|
|
355
|
+
"0xd5a79147930aa725",
|
|
356
|
+
"0x06ca6351e003826f",
|
|
357
|
+
"0x142929670a0e6e70",
|
|
358
|
+
"0x27b70a8546d22ffc",
|
|
359
|
+
"0x2e1b21385c26c926",
|
|
360
|
+
"0x4d2c6dfc5ac42aed",
|
|
361
|
+
"0x53380d139d95b3df",
|
|
362
|
+
"0x650a73548baf63de",
|
|
363
|
+
"0x766a0abb3c77b2a8",
|
|
364
|
+
"0x81c2c92e47edaee6",
|
|
365
|
+
"0x92722c851482353b",
|
|
366
|
+
"0xa2bfe8a14cf10364",
|
|
367
|
+
"0xa81a664bbc423001",
|
|
368
|
+
"0xc24b8b70d0f89791",
|
|
369
|
+
"0xc76c51a30654be30",
|
|
370
|
+
"0xd192e819d6ef5218",
|
|
371
|
+
"0xd69906245565a910",
|
|
372
|
+
"0xf40e35855771202a",
|
|
373
|
+
"0x106aa07032bbd1b8",
|
|
374
|
+
"0x19a4c116b8d2d0c8",
|
|
375
|
+
"0x1e376c085141ab53",
|
|
376
|
+
"0x2748774cdf8eeb99",
|
|
377
|
+
"0x34b0bcb5e19b48a8",
|
|
378
|
+
"0x391c0cb3c5c95a63",
|
|
379
|
+
"0x4ed8aa4ae3418acb",
|
|
380
|
+
"0x5b9cca4f7763e373",
|
|
381
|
+
"0x682e6ff3d6b2b8a3",
|
|
382
|
+
"0x748f82ee5defb2fc",
|
|
383
|
+
"0x78a5636f43172f60",
|
|
384
|
+
"0x84c87814a1f0ab72",
|
|
385
|
+
"0x8cc702081a6439ec",
|
|
386
|
+
"0x90befffa23631e28",
|
|
387
|
+
"0xa4506cebde82bde9",
|
|
388
|
+
"0xbef9a3f7b2c67915",
|
|
389
|
+
"0xc67178f2e372532b",
|
|
390
|
+
"0xca273eceea26619c",
|
|
391
|
+
"0xd186b8c721c0c207",
|
|
392
|
+
"0xeada7dd6cde0eb1e",
|
|
393
|
+
"0xf57d4f7fee6ed178",
|
|
394
|
+
"0x06f067aa72176fba",
|
|
395
|
+
"0x0a637dc5a2c898a6",
|
|
396
|
+
"0x113f9804bef90dae",
|
|
397
|
+
"0x1b710b35131c471b",
|
|
398
|
+
"0x28db77f523047d84",
|
|
399
|
+
"0x32caab7b40c72493",
|
|
400
|
+
"0x3c9ebe0a15c9bebc",
|
|
401
|
+
"0x431d67c49c100d4c",
|
|
402
|
+
"0x4cc5d4becb3e42b6",
|
|
403
|
+
"0x597f299cfc657e2a",
|
|
404
|
+
"0x5fcb6fab3ad6faec",
|
|
405
|
+
"0x6c44198c4a475817"
|
|
406
|
+
].map((n) => BigInt(n)));
|
|
407
|
+
const SHA512_Kh = K512[0];
|
|
408
|
+
const SHA512_Kl = K512[1];
|
|
409
|
+
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
410
|
+
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
411
|
+
var SHA512 = class extends HashMD {
|
|
412
|
+
constructor(outputLen = 64) {
|
|
413
|
+
super(128, outputLen, 16, false);
|
|
414
|
+
this.Ah = SHA512_IV[0] | 0;
|
|
415
|
+
this.Al = SHA512_IV[1] | 0;
|
|
416
|
+
this.Bh = SHA512_IV[2] | 0;
|
|
417
|
+
this.Bl = SHA512_IV[3] | 0;
|
|
418
|
+
this.Ch = SHA512_IV[4] | 0;
|
|
419
|
+
this.Cl = SHA512_IV[5] | 0;
|
|
420
|
+
this.Dh = SHA512_IV[6] | 0;
|
|
421
|
+
this.Dl = SHA512_IV[7] | 0;
|
|
422
|
+
this.Eh = SHA512_IV[8] | 0;
|
|
423
|
+
this.El = SHA512_IV[9] | 0;
|
|
424
|
+
this.Fh = SHA512_IV[10] | 0;
|
|
425
|
+
this.Fl = SHA512_IV[11] | 0;
|
|
426
|
+
this.Gh = SHA512_IV[12] | 0;
|
|
427
|
+
this.Gl = SHA512_IV[13] | 0;
|
|
428
|
+
this.Hh = SHA512_IV[14] | 0;
|
|
429
|
+
this.Hl = SHA512_IV[15] | 0;
|
|
430
|
+
}
|
|
431
|
+
get() {
|
|
432
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
433
|
+
return [
|
|
434
|
+
Ah,
|
|
435
|
+
Al,
|
|
436
|
+
Bh,
|
|
437
|
+
Bl,
|
|
438
|
+
Ch,
|
|
439
|
+
Cl,
|
|
440
|
+
Dh,
|
|
441
|
+
Dl,
|
|
442
|
+
Eh,
|
|
443
|
+
El,
|
|
444
|
+
Fh,
|
|
445
|
+
Fl,
|
|
446
|
+
Gh,
|
|
447
|
+
Gl,
|
|
448
|
+
Hh,
|
|
449
|
+
Hl
|
|
450
|
+
];
|
|
451
|
+
}
|
|
452
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
453
|
+
this.Ah = Ah | 0;
|
|
454
|
+
this.Al = Al | 0;
|
|
455
|
+
this.Bh = Bh | 0;
|
|
456
|
+
this.Bl = Bl | 0;
|
|
457
|
+
this.Ch = Ch | 0;
|
|
458
|
+
this.Cl = Cl | 0;
|
|
459
|
+
this.Dh = Dh | 0;
|
|
460
|
+
this.Dl = Dl | 0;
|
|
461
|
+
this.Eh = Eh | 0;
|
|
462
|
+
this.El = El | 0;
|
|
463
|
+
this.Fh = Fh | 0;
|
|
464
|
+
this.Fl = Fl | 0;
|
|
465
|
+
this.Gh = Gh | 0;
|
|
466
|
+
this.Gl = Gl | 0;
|
|
467
|
+
this.Hh = Hh | 0;
|
|
468
|
+
this.Hl = Hl | 0;
|
|
469
|
+
}
|
|
470
|
+
process(view, offset) {
|
|
471
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
472
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
473
|
+
SHA512_W_L[i] = view.getUint32(offset += 4);
|
|
474
|
+
}
|
|
475
|
+
for (let i = 16; i < 80; i++) {
|
|
476
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
477
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
478
|
+
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
479
|
+
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
480
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
481
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
482
|
+
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
483
|
+
const SUMl = add4L(s0l, rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6), SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
484
|
+
SHA512_W_H[i] = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]) | 0;
|
|
485
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
486
|
+
}
|
|
487
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
488
|
+
for (let i = 0; i < 80; i++) {
|
|
489
|
+
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
490
|
+
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
491
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
492
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
493
|
+
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
494
|
+
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
495
|
+
const T1l = T1ll | 0;
|
|
496
|
+
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
497
|
+
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
498
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
499
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
500
|
+
Hh = Gh | 0;
|
|
501
|
+
Hl = Gl | 0;
|
|
502
|
+
Gh = Fh | 0;
|
|
503
|
+
Gl = Fl | 0;
|
|
504
|
+
Fh = Eh | 0;
|
|
505
|
+
Fl = El | 0;
|
|
506
|
+
({h: Eh, l: El} = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
507
|
+
Dh = Ch | 0;
|
|
508
|
+
Dl = Cl | 0;
|
|
509
|
+
Ch = Bh | 0;
|
|
510
|
+
Cl = Bl | 0;
|
|
511
|
+
Bh = Ah | 0;
|
|
512
|
+
Bl = Al | 0;
|
|
513
|
+
const All = add3L(T1l, sigma0l, MAJl);
|
|
514
|
+
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
515
|
+
Al = All | 0;
|
|
516
|
+
}
|
|
517
|
+
({h: Ah, l: Al} = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
518
|
+
({h: Bh, l: Bl} = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
519
|
+
({h: Ch, l: Cl} = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
520
|
+
({h: Dh, l: Dl} = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
521
|
+
({h: Eh, l: El} = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
522
|
+
({h: Fh, l: Fl} = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
523
|
+
({h: Gh, l: Gl} = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
524
|
+
({h: Hh, l: Hl} = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
525
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
526
|
+
}
|
|
527
|
+
roundClean() {
|
|
528
|
+
clean(SHA512_W_H, SHA512_W_L);
|
|
529
|
+
}
|
|
530
|
+
destroy() {
|
|
531
|
+
clean(this.buffer);
|
|
532
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
var SHA384 = class extends SHA512 {
|
|
536
|
+
constructor() {
|
|
537
|
+
super(48);
|
|
538
|
+
this.Ah = SHA384_IV[0] | 0;
|
|
539
|
+
this.Al = SHA384_IV[1] | 0;
|
|
540
|
+
this.Bh = SHA384_IV[2] | 0;
|
|
541
|
+
this.Bl = SHA384_IV[3] | 0;
|
|
542
|
+
this.Ch = SHA384_IV[4] | 0;
|
|
543
|
+
this.Cl = SHA384_IV[5] | 0;
|
|
544
|
+
this.Dh = SHA384_IV[6] | 0;
|
|
545
|
+
this.Dl = SHA384_IV[7] | 0;
|
|
546
|
+
this.Eh = SHA384_IV[8] | 0;
|
|
547
|
+
this.El = SHA384_IV[9] | 0;
|
|
548
|
+
this.Fh = SHA384_IV[10] | 0;
|
|
549
|
+
this.Fl = SHA384_IV[11] | 0;
|
|
550
|
+
this.Gh = SHA384_IV[12] | 0;
|
|
551
|
+
this.Gl = SHA384_IV[13] | 0;
|
|
552
|
+
this.Hh = SHA384_IV[14] | 0;
|
|
553
|
+
this.Hl = SHA384_IV[15] | 0;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* SHA2-256 hash function from RFC 4634.
|
|
558
|
+
*
|
|
559
|
+
* It is the fastest JS hash, even faster than Blake3.
|
|
560
|
+
* To break sha256 using birthday attack, attackers need to try 2^128 hashes.
|
|
561
|
+
* BTC network is doing 2^70 hashes/sec (2^95 hashes/year) as per 2025.
|
|
562
|
+
*/
|
|
563
|
+
const sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
564
|
+
/** SHA2-512 hash function from RFC 4634. */
|
|
565
|
+
const sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
|
|
566
|
+
/** SHA2-384 hash function from RFC 4634. */
|
|
567
|
+
const sha384 = /* @__PURE__ */ createHasher(() => new SHA384());
|
|
568
|
+
//#endregion
|
|
569
|
+
//#region node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/hmac.js
|
|
570
|
+
/**
|
|
571
|
+
* HMAC: RFC2104 message authentication code.
|
|
572
|
+
* @module
|
|
573
|
+
*/
|
|
574
|
+
var HMAC = class extends Hash {
|
|
575
|
+
constructor(hash, _key) {
|
|
576
|
+
super();
|
|
577
|
+
this.finished = false;
|
|
578
|
+
this.destroyed = false;
|
|
579
|
+
ahash(hash);
|
|
580
|
+
const key = toBytes(_key);
|
|
581
|
+
this.iHash = hash.create();
|
|
582
|
+
if (typeof this.iHash.update !== "function") throw new Error("Expected instance of class which extends utils.Hash");
|
|
583
|
+
this.blockLen = this.iHash.blockLen;
|
|
584
|
+
this.outputLen = this.iHash.outputLen;
|
|
585
|
+
const blockLen = this.blockLen;
|
|
586
|
+
const pad = new Uint8Array(blockLen);
|
|
587
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
588
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 54;
|
|
589
|
+
this.iHash.update(pad);
|
|
590
|
+
this.oHash = hash.create();
|
|
591
|
+
for (let i = 0; i < pad.length; i++) pad[i] ^= 106;
|
|
592
|
+
this.oHash.update(pad);
|
|
593
|
+
clean(pad);
|
|
594
|
+
}
|
|
595
|
+
update(buf) {
|
|
596
|
+
aexists(this);
|
|
597
|
+
this.iHash.update(buf);
|
|
598
|
+
return this;
|
|
599
|
+
}
|
|
600
|
+
digestInto(out) {
|
|
601
|
+
aexists(this);
|
|
602
|
+
abytes(out, this.outputLen);
|
|
603
|
+
this.finished = true;
|
|
604
|
+
this.iHash.digestInto(out);
|
|
605
|
+
this.oHash.update(out);
|
|
606
|
+
this.oHash.digestInto(out);
|
|
607
|
+
this.destroy();
|
|
608
|
+
}
|
|
609
|
+
digest() {
|
|
610
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
611
|
+
this.digestInto(out);
|
|
612
|
+
return out;
|
|
613
|
+
}
|
|
614
|
+
_cloneInto(to) {
|
|
615
|
+
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
616
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
617
|
+
to = to;
|
|
618
|
+
to.finished = finished;
|
|
619
|
+
to.destroyed = destroyed;
|
|
620
|
+
to.blockLen = blockLen;
|
|
621
|
+
to.outputLen = outputLen;
|
|
622
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
623
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
624
|
+
return to;
|
|
625
|
+
}
|
|
626
|
+
clone() {
|
|
627
|
+
return this._cloneInto();
|
|
628
|
+
}
|
|
629
|
+
destroy() {
|
|
630
|
+
this.destroyed = true;
|
|
631
|
+
this.oHash.destroy();
|
|
632
|
+
this.iHash.destroy();
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* HMAC: RFC2104 message authentication code.
|
|
637
|
+
* @param hash - function that would be used e.g. sha256
|
|
638
|
+
* @param key - message key
|
|
639
|
+
* @param message - message data
|
|
640
|
+
* @example
|
|
641
|
+
* import { hmac } from '@noble/hashes/hmac';
|
|
642
|
+
* import { sha256 } from '@noble/hashes/sha2';
|
|
643
|
+
* const mac1 = hmac(sha256, 'key', 'message');
|
|
644
|
+
*/
|
|
645
|
+
const hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
646
|
+
hmac.create = (hash, key) => new HMAC(hash, key);
|
|
647
|
+
//#endregion
|
|
648
|
+
export { sha512 as i, sha256 as n, sha384 as r, hmac as t };
|