@notabene/verify-proof 1.11.0 → 1.11.1-next.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.
Files changed (75) hide show
  1. package/README.md +21 -15
  2. package/dist/bitcoin-3CW4MNAW.cjs +314 -0
  3. package/dist/bitcoin-3CW4MNAW.cjs.map +1 -0
  4. package/dist/bitcoin-QK53ILBF.js +312 -0
  5. package/dist/bitcoin-QK53ILBF.js.map +1 -0
  6. package/dist/cardano-DYBYEAAF.cjs +53 -0
  7. package/dist/cardano-DYBYEAAF.cjs.map +1 -0
  8. package/dist/cardano-WE6YXYLW.js +31 -0
  9. package/dist/cardano-WE6YXYLW.js.map +1 -0
  10. package/dist/chunk-E3V5ATTC.js +38 -0
  11. package/dist/chunk-E3V5ATTC.js.map +1 -0
  12. package/dist/chunk-OAXNH5XR.cjs +42 -0
  13. package/dist/chunk-OAXNH5XR.cjs.map +1 -0
  14. package/dist/concordium-HQC37GCK.cjs +188 -0
  15. package/dist/concordium-HQC37GCK.cjs.map +1 -0
  16. package/dist/concordium-XX4XYLLU.js +186 -0
  17. package/dist/concordium-XX4XYLLU.js.map +1 -0
  18. package/dist/cosmos-64MKE5FJ.cjs +683 -0
  19. package/dist/cosmos-64MKE5FJ.cjs.map +1 -0
  20. package/dist/cosmos-QMH7BK7S.js +681 -0
  21. package/dist/cosmos-QMH7BK7S.js.map +1 -0
  22. package/dist/eth-3DX3PXDU.cjs +37 -0
  23. package/dist/eth-3DX3PXDU.cjs.map +1 -0
  24. package/dist/eth-ICLGRJE5.js +34 -0
  25. package/dist/eth-ICLGRJE5.js.map +1 -0
  26. package/dist/index.cjs +69 -1
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +5 -0
  29. package/dist/index.d.ts +5 -2
  30. package/dist/index.js +67 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/solana-4KQFLZUC.js +342 -0
  33. package/dist/solana-4KQFLZUC.js.map +1 -0
  34. package/dist/solana-PQ5K4NGO.cjs +365 -0
  35. package/dist/solana-PQ5K4NGO.cjs.map +1 -0
  36. package/dist/tron-F5AARBY4.cjs +58 -0
  37. package/dist/tron-F5AARBY4.cjs.map +1 -0
  38. package/dist/tron-OBLPB2LN.js +53 -0
  39. package/dist/tron-OBLPB2LN.js.map +1 -0
  40. package/dist/xlm-5GODWWL2.cjs +28 -0
  41. package/dist/xlm-5GODWWL2.cjs.map +1 -0
  42. package/dist/xlm-GX2QGFLI.js +26 -0
  43. package/dist/xlm-GX2QGFLI.js.map +1 -0
  44. package/dist/xrpl-7HQLIDAK.cjs +1174 -0
  45. package/dist/xrpl-7HQLIDAK.cjs.map +1 -0
  46. package/dist/xrpl-YCDFXBGQ.js +1169 -0
  47. package/dist/xrpl-YCDFXBGQ.js.map +1 -0
  48. package/package.json +11 -2
  49. package/src/cardano.ts +2 -2
  50. package/src/index.ts +31 -19
  51. package/src/solana.ts +1 -1
  52. package/src/tests/solana.test.ts +1 -1
  53. package/dist/bitcoin.d.ts +0 -2
  54. package/dist/cardano.d.ts +0 -2
  55. package/dist/concordium.d.ts +0 -15
  56. package/dist/cosmos.d.ts +0 -2
  57. package/dist/eth.d.ts +0 -4
  58. package/dist/index.modern.js +0 -2
  59. package/dist/index.modern.js.map +0 -1
  60. package/dist/index.umd.js +0 -2
  61. package/dist/index.umd.js.map +0 -1
  62. package/dist/solana.d.ts +0 -17
  63. package/dist/tests/bitcoin.test.d.ts +0 -1
  64. package/dist/tests/cardano.test.d.ts +0 -1
  65. package/dist/tests/concordium.test.d.ts +0 -1
  66. package/dist/tests/cosmos.test.d.ts +0 -1
  67. package/dist/tests/eth.test.d.ts +0 -1
  68. package/dist/tests/index.test.d.ts +0 -1
  69. package/dist/tests/solana.test.d.ts +0 -1
  70. package/dist/tests/tron.test.d.ts +0 -1
  71. package/dist/tests/xlm.test.d.ts +0 -1
  72. package/dist/tests/xrpl.test.d.ts +0 -1
  73. package/dist/tron.d.ts +0 -6
  74. package/dist/xlm.d.ts +0 -2
  75. package/dist/xrpl.d.ts +0 -5
@@ -0,0 +1,681 @@
1
+ import { Buffer } from 'buffer';
2
+ import { __commonJS, __toESM } from './chunk-E3V5ATTC.js';
3
+ import { ProofStatus } from '@notabene/javascript-sdk';
4
+ import { serializeSignDoc } from '@cosmjs/amino';
5
+ import { secp256k1 } from '@noble/curves/secp256k1';
6
+
7
+ if (typeof globalThis !== 'undefined' && !globalThis.Buffer) { globalThis.Buffer = Buffer; }
8
+
9
+ // node_modules/bech32/dist/index.js
10
+ var require_dist = __commonJS({
11
+ "node_modules/bech32/dist/index.js"(exports) {
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.bech32m = exports.bech32 = void 0;
14
+ var ALPHABET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
15
+ var ALPHABET_MAP = {};
16
+ for (let z = 0; z < ALPHABET.length; z++) {
17
+ const x = ALPHABET.charAt(z);
18
+ ALPHABET_MAP[x] = z;
19
+ }
20
+ function polymodStep(pre) {
21
+ const b = pre >> 25;
22
+ return (pre & 33554431) << 5 ^ -(b >> 0 & 1) & 996825010 ^ -(b >> 1 & 1) & 642813549 ^ -(b >> 2 & 1) & 513874426 ^ -(b >> 3 & 1) & 1027748829 ^ -(b >> 4 & 1) & 705979059;
23
+ }
24
+ function prefixChk(prefix) {
25
+ let chk = 1;
26
+ for (let i = 0; i < prefix.length; ++i) {
27
+ const c = prefix.charCodeAt(i);
28
+ if (c < 33 || c > 126)
29
+ return "Invalid prefix (" + prefix + ")";
30
+ chk = polymodStep(chk) ^ c >> 5;
31
+ }
32
+ chk = polymodStep(chk);
33
+ for (let i = 0; i < prefix.length; ++i) {
34
+ const v = prefix.charCodeAt(i);
35
+ chk = polymodStep(chk) ^ v & 31;
36
+ }
37
+ return chk;
38
+ }
39
+ function convert(data, inBits, outBits, pad) {
40
+ let value = 0;
41
+ let bits = 0;
42
+ const maxV = (1 << outBits) - 1;
43
+ const result = [];
44
+ for (let i = 0; i < data.length; ++i) {
45
+ value = value << inBits | data[i];
46
+ bits += inBits;
47
+ while (bits >= outBits) {
48
+ bits -= outBits;
49
+ result.push(value >> bits & maxV);
50
+ }
51
+ }
52
+ if (pad) {
53
+ if (bits > 0) {
54
+ result.push(value << outBits - bits & maxV);
55
+ }
56
+ } else {
57
+ if (bits >= inBits)
58
+ return "Excess padding";
59
+ if (value << outBits - bits & maxV)
60
+ return "Non-zero padding";
61
+ }
62
+ return result;
63
+ }
64
+ function toWords(bytes) {
65
+ return convert(bytes, 8, 5, true);
66
+ }
67
+ function fromWordsUnsafe(words) {
68
+ const res = convert(words, 5, 8, false);
69
+ if (Array.isArray(res))
70
+ return res;
71
+ }
72
+ function fromWords(words) {
73
+ const res = convert(words, 5, 8, false);
74
+ if (Array.isArray(res))
75
+ return res;
76
+ throw new Error(res);
77
+ }
78
+ function getLibraryFromEncoding(encoding) {
79
+ let ENCODING_CONST;
80
+ if (encoding === "bech32") {
81
+ ENCODING_CONST = 1;
82
+ } else {
83
+ ENCODING_CONST = 734539939;
84
+ }
85
+ function encode(prefix, words, LIMIT) {
86
+ LIMIT = LIMIT || 90;
87
+ if (prefix.length + 7 + words.length > LIMIT)
88
+ throw new TypeError("Exceeds length limit");
89
+ prefix = prefix.toLowerCase();
90
+ let chk = prefixChk(prefix);
91
+ if (typeof chk === "string")
92
+ throw new Error(chk);
93
+ let result = prefix + "1";
94
+ for (let i = 0; i < words.length; ++i) {
95
+ const x = words[i];
96
+ if (x >> 5 !== 0)
97
+ throw new Error("Non 5-bit word");
98
+ chk = polymodStep(chk) ^ x;
99
+ result += ALPHABET.charAt(x);
100
+ }
101
+ for (let i = 0; i < 6; ++i) {
102
+ chk = polymodStep(chk);
103
+ }
104
+ chk ^= ENCODING_CONST;
105
+ for (let i = 0; i < 6; ++i) {
106
+ const v = chk >> (5 - i) * 5 & 31;
107
+ result += ALPHABET.charAt(v);
108
+ }
109
+ return result;
110
+ }
111
+ function __decode(str, LIMIT) {
112
+ LIMIT = LIMIT || 90;
113
+ if (str.length < 8)
114
+ return str + " too short";
115
+ if (str.length > LIMIT)
116
+ return "Exceeds length limit";
117
+ const lowered = str.toLowerCase();
118
+ const uppered = str.toUpperCase();
119
+ if (str !== lowered && str !== uppered)
120
+ return "Mixed-case string " + str;
121
+ str = lowered;
122
+ const split = str.lastIndexOf("1");
123
+ if (split === -1)
124
+ return "No separator character for " + str;
125
+ if (split === 0)
126
+ return "Missing prefix for " + str;
127
+ const prefix = str.slice(0, split);
128
+ const wordChars = str.slice(split + 1);
129
+ if (wordChars.length < 6)
130
+ return "Data too short";
131
+ let chk = prefixChk(prefix);
132
+ if (typeof chk === "string")
133
+ return chk;
134
+ const words = [];
135
+ for (let i = 0; i < wordChars.length; ++i) {
136
+ const c = wordChars.charAt(i);
137
+ const v = ALPHABET_MAP[c];
138
+ if (v === void 0)
139
+ return "Unknown character " + c;
140
+ chk = polymodStep(chk) ^ v;
141
+ if (i + 6 >= wordChars.length)
142
+ continue;
143
+ words.push(v);
144
+ }
145
+ if (chk !== ENCODING_CONST)
146
+ return "Invalid checksum for " + str;
147
+ return { prefix, words };
148
+ }
149
+ function decodeUnsafe(str, LIMIT) {
150
+ const res = __decode(str, LIMIT);
151
+ if (typeof res === "object")
152
+ return res;
153
+ }
154
+ function decode(str, LIMIT) {
155
+ const res = __decode(str, LIMIT);
156
+ if (typeof res === "object")
157
+ return res;
158
+ throw new Error(res);
159
+ }
160
+ return {
161
+ decodeUnsafe,
162
+ decode,
163
+ encode,
164
+ toWords,
165
+ fromWordsUnsafe,
166
+ fromWords
167
+ };
168
+ }
169
+ exports.bech32 = getLibraryFromEncoding("bech32");
170
+ exports.bech32m = getLibraryFromEncoding("bech32m");
171
+ }
172
+ });
173
+
174
+ // src/cosmos.ts
175
+ var import_bech32 = __toESM(require_dist(), 1);
176
+
177
+ // node_modules/@noble/hashes/esm/utils.js
178
+ function isBytes(a) {
179
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
180
+ }
181
+ function abytes(b, ...lengths) {
182
+ if (!isBytes(b))
183
+ throw new Error("Uint8Array expected");
184
+ if (lengths.length > 0 && !lengths.includes(b.length))
185
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
186
+ }
187
+ function aexists(instance, checkFinished = true) {
188
+ if (instance.destroyed)
189
+ throw new Error("Hash instance has been destroyed");
190
+ if (checkFinished && instance.finished)
191
+ throw new Error("Hash#digest() has already been called");
192
+ }
193
+ function aoutput(out, instance) {
194
+ abytes(out);
195
+ const min = instance.outputLen;
196
+ if (out.length < min) {
197
+ throw new Error("digestInto() expects output buffer of length at least " + min);
198
+ }
199
+ }
200
+ function clean(...arrays) {
201
+ for (let i = 0; i < arrays.length; i++) {
202
+ arrays[i].fill(0);
203
+ }
204
+ }
205
+ function createView(arr) {
206
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
207
+ }
208
+ function rotr(word, shift) {
209
+ return word << 32 - shift | word >>> shift;
210
+ }
211
+ function rotl(word, shift) {
212
+ return word << shift | word >>> 32 - shift >>> 0;
213
+ }
214
+ function utf8ToBytes(str) {
215
+ if (typeof str !== "string")
216
+ throw new Error("string expected");
217
+ return new Uint8Array(new TextEncoder().encode(str));
218
+ }
219
+ function toBytes(data) {
220
+ if (typeof data === "string")
221
+ data = utf8ToBytes(data);
222
+ abytes(data);
223
+ return data;
224
+ }
225
+ var Hash = class {
226
+ };
227
+ function createHasher(hashCons) {
228
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
229
+ const tmp = hashCons();
230
+ hashC.outputLen = tmp.outputLen;
231
+ hashC.blockLen = tmp.blockLen;
232
+ hashC.create = () => hashCons();
233
+ return hashC;
234
+ }
235
+
236
+ // node_modules/@noble/hashes/esm/_md.js
237
+ function setBigUint64(view, byteOffset, value, isLE) {
238
+ if (typeof view.setBigUint64 === "function")
239
+ return view.setBigUint64(byteOffset, value, isLE);
240
+ const _32n = BigInt(32);
241
+ const _u32_max = BigInt(4294967295);
242
+ const wh = Number(value >> _32n & _u32_max);
243
+ const wl = Number(value & _u32_max);
244
+ const h = isLE ? 4 : 0;
245
+ const l = isLE ? 0 : 4;
246
+ view.setUint32(byteOffset + h, wh, isLE);
247
+ view.setUint32(byteOffset + l, wl, isLE);
248
+ }
249
+ function Chi(a, b, c) {
250
+ return a & b ^ ~a & c;
251
+ }
252
+ function Maj(a, b, c) {
253
+ return a & b ^ a & c ^ b & c;
254
+ }
255
+ var HashMD = class extends Hash {
256
+ constructor(blockLen, outputLen, padOffset, isLE) {
257
+ super();
258
+ this.finished = false;
259
+ this.length = 0;
260
+ this.pos = 0;
261
+ this.destroyed = false;
262
+ this.blockLen = blockLen;
263
+ this.outputLen = outputLen;
264
+ this.padOffset = padOffset;
265
+ this.isLE = isLE;
266
+ this.buffer = new Uint8Array(blockLen);
267
+ this.view = createView(this.buffer);
268
+ }
269
+ update(data) {
270
+ aexists(this);
271
+ data = toBytes(data);
272
+ abytes(data);
273
+ const { view, buffer, blockLen } = this;
274
+ const len = data.length;
275
+ for (let pos = 0; pos < len; ) {
276
+ const take = Math.min(blockLen - this.pos, len - pos);
277
+ if (take === blockLen) {
278
+ const dataView = createView(data);
279
+ for (; blockLen <= len - pos; pos += blockLen)
280
+ this.process(dataView, pos);
281
+ continue;
282
+ }
283
+ buffer.set(data.subarray(pos, pos + take), this.pos);
284
+ this.pos += take;
285
+ pos += take;
286
+ if (this.pos === blockLen) {
287
+ this.process(view, 0);
288
+ this.pos = 0;
289
+ }
290
+ }
291
+ this.length += data.length;
292
+ this.roundClean();
293
+ return this;
294
+ }
295
+ digestInto(out) {
296
+ aexists(this);
297
+ aoutput(out, this);
298
+ this.finished = true;
299
+ const { buffer, view, blockLen, isLE } = this;
300
+ let { pos } = this;
301
+ buffer[pos++] = 128;
302
+ clean(this.buffer.subarray(pos));
303
+ if (this.padOffset > blockLen - pos) {
304
+ this.process(view, 0);
305
+ pos = 0;
306
+ }
307
+ for (let i = pos; i < blockLen; i++)
308
+ buffer[i] = 0;
309
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
310
+ this.process(view, 0);
311
+ const oview = createView(out);
312
+ const len = this.outputLen;
313
+ if (len % 4)
314
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
315
+ const outLen = len / 4;
316
+ const state = this.get();
317
+ if (outLen > state.length)
318
+ throw new Error("_sha2: outputLen bigger than state");
319
+ for (let i = 0; i < outLen; i++)
320
+ oview.setUint32(4 * i, state[i], isLE);
321
+ }
322
+ digest() {
323
+ const { buffer, outputLen } = this;
324
+ this.digestInto(buffer);
325
+ const res = buffer.slice(0, outputLen);
326
+ this.destroy();
327
+ return res;
328
+ }
329
+ _cloneInto(to) {
330
+ to || (to = new this.constructor());
331
+ to.set(...this.get());
332
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
333
+ to.destroyed = destroyed;
334
+ to.finished = finished;
335
+ to.length = length;
336
+ to.pos = pos;
337
+ if (length % blockLen)
338
+ to.buffer.set(buffer);
339
+ return to;
340
+ }
341
+ clone() {
342
+ return this._cloneInto();
343
+ }
344
+ };
345
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
346
+ 1779033703,
347
+ 3144134277,
348
+ 1013904242,
349
+ 2773480762,
350
+ 1359893119,
351
+ 2600822924,
352
+ 528734635,
353
+ 1541459225
354
+ ]);
355
+
356
+ // node_modules/@noble/hashes/esm/legacy.js
357
+ var Rho160 = /* @__PURE__ */ Uint8Array.from([
358
+ 7,
359
+ 4,
360
+ 13,
361
+ 1,
362
+ 10,
363
+ 6,
364
+ 15,
365
+ 3,
366
+ 12,
367
+ 0,
368
+ 9,
369
+ 5,
370
+ 2,
371
+ 14,
372
+ 11,
373
+ 8
374
+ ]);
375
+ var Id160 = /* @__PURE__ */ (() => Uint8Array.from(new Array(16).fill(0).map((_, i) => i)))();
376
+ var Pi160 = /* @__PURE__ */ (() => Id160.map((i) => (9 * i + 5) % 16))();
377
+ var idxLR = /* @__PURE__ */ (() => {
378
+ const L = [Id160];
379
+ const R = [Pi160];
380
+ const res = [L, R];
381
+ for (let i = 0; i < 4; i++)
382
+ for (let j of res)
383
+ j.push(j[i].map((k) => Rho160[k]));
384
+ return res;
385
+ })();
386
+ var idxL = /* @__PURE__ */ (() => idxLR[0])();
387
+ var idxR = /* @__PURE__ */ (() => idxLR[1])();
388
+ var shifts160 = /* @__PURE__ */ [
389
+ [11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8],
390
+ [12, 13, 11, 15, 6, 9, 9, 7, 12, 15, 11, 13, 7, 8, 7, 7],
391
+ [13, 15, 14, 11, 7, 7, 6, 8, 13, 14, 13, 12, 5, 5, 6, 9],
392
+ [14, 11, 12, 14, 8, 6, 5, 5, 15, 12, 15, 14, 9, 9, 8, 6],
393
+ [15, 12, 13, 13, 9, 5, 8, 6, 14, 11, 12, 11, 8, 6, 5, 5]
394
+ ].map((i) => Uint8Array.from(i));
395
+ var shiftsL160 = /* @__PURE__ */ idxL.map((idx, i) => idx.map((j) => shifts160[i][j]));
396
+ var shiftsR160 = /* @__PURE__ */ idxR.map((idx, i) => idx.map((j) => shifts160[i][j]));
397
+ var Kl160 = /* @__PURE__ */ Uint32Array.from([
398
+ 0,
399
+ 1518500249,
400
+ 1859775393,
401
+ 2400959708,
402
+ 2840853838
403
+ ]);
404
+ var Kr160 = /* @__PURE__ */ Uint32Array.from([
405
+ 1352829926,
406
+ 1548603684,
407
+ 1836072691,
408
+ 2053994217,
409
+ 0
410
+ ]);
411
+ function ripemd_f(group, x, y, z) {
412
+ if (group === 0)
413
+ return x ^ y ^ z;
414
+ if (group === 1)
415
+ return x & y | ~x & z;
416
+ if (group === 2)
417
+ return (x | ~y) ^ z;
418
+ if (group === 3)
419
+ return x & z | y & ~z;
420
+ return x ^ (y | ~z);
421
+ }
422
+ var BUF_160 = /* @__PURE__ */ new Uint32Array(16);
423
+ var RIPEMD160 = class extends HashMD {
424
+ constructor() {
425
+ super(64, 20, 8, true);
426
+ this.h0 = 1732584193 | 0;
427
+ this.h1 = 4023233417 | 0;
428
+ this.h2 = 2562383102 | 0;
429
+ this.h3 = 271733878 | 0;
430
+ this.h4 = 3285377520 | 0;
431
+ }
432
+ get() {
433
+ const { h0, h1, h2, h3, h4 } = this;
434
+ return [h0, h1, h2, h3, h4];
435
+ }
436
+ set(h0, h1, h2, h3, h4) {
437
+ this.h0 = h0 | 0;
438
+ this.h1 = h1 | 0;
439
+ this.h2 = h2 | 0;
440
+ this.h3 = h3 | 0;
441
+ this.h4 = h4 | 0;
442
+ }
443
+ process(view, offset) {
444
+ for (let i = 0; i < 16; i++, offset += 4)
445
+ BUF_160[i] = view.getUint32(offset, true);
446
+ let al = this.h0 | 0, ar = al, bl = this.h1 | 0, br = bl, cl = this.h2 | 0, cr = cl, dl = this.h3 | 0, dr = dl, el = this.h4 | 0, er = el;
447
+ for (let group = 0; group < 5; group++) {
448
+ const rGroup = 4 - group;
449
+ const hbl = Kl160[group], hbr = Kr160[group];
450
+ const rl = idxL[group], rr = idxR[group];
451
+ const sl = shiftsL160[group], sr = shiftsR160[group];
452
+ for (let i = 0; i < 16; i++) {
453
+ const tl = rotl(al + ripemd_f(group, bl, cl, dl) + BUF_160[rl[i]] + hbl, sl[i]) + el | 0;
454
+ al = el, el = dl, dl = rotl(cl, 10) | 0, cl = bl, bl = tl;
455
+ }
456
+ for (let i = 0; i < 16; i++) {
457
+ const tr = rotl(ar + ripemd_f(rGroup, br, cr, dr) + BUF_160[rr[i]] + hbr, sr[i]) + er | 0;
458
+ ar = er, er = dr, dr = rotl(cr, 10) | 0, cr = br, br = tr;
459
+ }
460
+ }
461
+ this.set(this.h1 + cl + dr | 0, this.h2 + dl + er | 0, this.h3 + el + ar | 0, this.h4 + al + br | 0, this.h0 + bl + cr | 0);
462
+ }
463
+ roundClean() {
464
+ clean(BUF_160);
465
+ }
466
+ destroy() {
467
+ this.destroyed = true;
468
+ clean(this.buffer);
469
+ this.set(0, 0, 0, 0, 0);
470
+ }
471
+ };
472
+ var ripemd160 = /* @__PURE__ */ createHasher(() => new RIPEMD160());
473
+
474
+ // node_modules/@noble/hashes/esm/sha2.js
475
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
476
+ 1116352408,
477
+ 1899447441,
478
+ 3049323471,
479
+ 3921009573,
480
+ 961987163,
481
+ 1508970993,
482
+ 2453635748,
483
+ 2870763221,
484
+ 3624381080,
485
+ 310598401,
486
+ 607225278,
487
+ 1426881987,
488
+ 1925078388,
489
+ 2162078206,
490
+ 2614888103,
491
+ 3248222580,
492
+ 3835390401,
493
+ 4022224774,
494
+ 264347078,
495
+ 604807628,
496
+ 770255983,
497
+ 1249150122,
498
+ 1555081692,
499
+ 1996064986,
500
+ 2554220882,
501
+ 2821834349,
502
+ 2952996808,
503
+ 3210313671,
504
+ 3336571891,
505
+ 3584528711,
506
+ 113926993,
507
+ 338241895,
508
+ 666307205,
509
+ 773529912,
510
+ 1294757372,
511
+ 1396182291,
512
+ 1695183700,
513
+ 1986661051,
514
+ 2177026350,
515
+ 2456956037,
516
+ 2730485921,
517
+ 2820302411,
518
+ 3259730800,
519
+ 3345764771,
520
+ 3516065817,
521
+ 3600352804,
522
+ 4094571909,
523
+ 275423344,
524
+ 430227734,
525
+ 506948616,
526
+ 659060556,
527
+ 883997877,
528
+ 958139571,
529
+ 1322822218,
530
+ 1537002063,
531
+ 1747873779,
532
+ 1955562222,
533
+ 2024104815,
534
+ 2227730452,
535
+ 2361852424,
536
+ 2428436474,
537
+ 2756734187,
538
+ 3204031479,
539
+ 3329325298
540
+ ]);
541
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
542
+ var SHA256 = class extends HashMD {
543
+ constructor(outputLen = 32) {
544
+ super(64, outputLen, 8, false);
545
+ this.A = SHA256_IV[0] | 0;
546
+ this.B = SHA256_IV[1] | 0;
547
+ this.C = SHA256_IV[2] | 0;
548
+ this.D = SHA256_IV[3] | 0;
549
+ this.E = SHA256_IV[4] | 0;
550
+ this.F = SHA256_IV[5] | 0;
551
+ this.G = SHA256_IV[6] | 0;
552
+ this.H = SHA256_IV[7] | 0;
553
+ }
554
+ get() {
555
+ const { A, B, C, D, E, F, G, H } = this;
556
+ return [A, B, C, D, E, F, G, H];
557
+ }
558
+ // prettier-ignore
559
+ set(A, B, C, D, E, F, G, H) {
560
+ this.A = A | 0;
561
+ this.B = B | 0;
562
+ this.C = C | 0;
563
+ this.D = D | 0;
564
+ this.E = E | 0;
565
+ this.F = F | 0;
566
+ this.G = G | 0;
567
+ this.H = H | 0;
568
+ }
569
+ process(view, offset) {
570
+ for (let i = 0; i < 16; i++, offset += 4)
571
+ SHA256_W[i] = view.getUint32(offset, false);
572
+ for (let i = 16; i < 64; i++) {
573
+ const W15 = SHA256_W[i - 15];
574
+ const W2 = SHA256_W[i - 2];
575
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
576
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
577
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
578
+ }
579
+ let { A, B, C, D, E, F, G, H } = this;
580
+ for (let i = 0; i < 64; i++) {
581
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
582
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
583
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
584
+ const T2 = sigma0 + Maj(A, B, C) | 0;
585
+ H = G;
586
+ G = F;
587
+ F = E;
588
+ E = D + T1 | 0;
589
+ D = C;
590
+ C = B;
591
+ B = A;
592
+ A = T1 + T2 | 0;
593
+ }
594
+ A = A + this.A | 0;
595
+ B = B + this.B | 0;
596
+ C = C + this.C | 0;
597
+ D = D + this.D | 0;
598
+ E = E + this.E | 0;
599
+ F = F + this.F | 0;
600
+ G = G + this.G | 0;
601
+ H = H + this.H | 0;
602
+ this.set(A, B, C, D, E, F, G, H);
603
+ }
604
+ roundClean() {
605
+ clean(SHA256_W);
606
+ }
607
+ destroy() {
608
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
609
+ clean(this.buffer);
610
+ }
611
+ };
612
+ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
613
+
614
+ // src/cosmos.ts
615
+ function base64ToUint8Array(base64) {
616
+ return Uint8Array.from(atob(base64), (c) => c.charCodeAt(0));
617
+ }
618
+ function toBase64Bytes(str) {
619
+ const utf8 = new TextEncoder().encode(str);
620
+ let binary = "";
621
+ for (let i = 0; i < utf8.length; i++) {
622
+ binary += String.fromCharCode(utf8[i]);
623
+ }
624
+ return btoa(binary);
625
+ }
626
+ function deriveCosmosAddress(pubkey, prefix = "cosmos") {
627
+ const sha = sha256(pubkey);
628
+ const rip = ripemd160(sha);
629
+ return import_bech32.bech32.encode(prefix, import_bech32.bech32.toWords(rip));
630
+ }
631
+ async function verifyCosmosSignature(proof) {
632
+ try {
633
+ const [ns, , address] = proof.address.split(/:/);
634
+ if (ns !== "cosmos") {
635
+ return { ...proof, status: ProofStatus.FAILED };
636
+ }
637
+ const pubKeyBytes = base64ToUint8Array(
638
+ proof.chainSpecificData.pub_key.value
639
+ );
640
+ const signatureBytes = base64ToUint8Array(proof.proof);
641
+ const derivedAddress = deriveCosmosAddress(pubKeyBytes);
642
+ if (derivedAddress !== address) {
643
+ return { ...proof, status: ProofStatus.FAILED };
644
+ }
645
+ const signDoc = {
646
+ chain_id: "",
647
+ // must match the signing process
648
+ account_number: "0",
649
+ sequence: "0",
650
+ fee: { amount: [], gas: "0" },
651
+ msgs: [
652
+ {
653
+ type: "sign/MsgSignData",
654
+ value: {
655
+ signer: address,
656
+ data: toBase64Bytes(proof.attestation)
657
+ }
658
+ }
659
+ ],
660
+ memo: ""
661
+ };
662
+ const signBytes = await serializeSignDoc(signDoc);
663
+ const digest = sha256(signBytes);
664
+ const verified = secp256k1.verify(signatureBytes, digest, pubKeyBytes);
665
+ return {
666
+ ...proof,
667
+ status: verified ? ProofStatus.VERIFIED : ProofStatus.FAILED
668
+ };
669
+ } catch {
670
+ return { ...proof, status: ProofStatus.FAILED };
671
+ }
672
+ }
673
+ /*! Bundled license information:
674
+
675
+ @noble/hashes/esm/utils.js:
676
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
677
+ */
678
+
679
+ export { verifyCosmosSignature };
680
+ //# sourceMappingURL=cosmos-QMH7BK7S.js.map
681
+ //# sourceMappingURL=cosmos-QMH7BK7S.js.map