@meshsdk/common 1.7.2 → 1.7.4

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/dist/index.cjs CHANGED
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJS = (cb, mod) => function __require() {
9
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,6 +30,868 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
33
+ // ../../node_modules/blakejs/util.js
34
+ var require_util = __commonJS({
35
+ "../../node_modules/blakejs/util.js"(exports2, module2) {
36
+ "use strict";
37
+ var ERROR_MSG_INPUT = "Input must be an string, Buffer or Uint8Array";
38
+ function normalizeInput(input) {
39
+ let ret;
40
+ if (input instanceof Uint8Array) {
41
+ ret = input;
42
+ } else if (typeof input === "string") {
43
+ const encoder = new TextEncoder();
44
+ ret = encoder.encode(input);
45
+ } else {
46
+ throw new Error(ERROR_MSG_INPUT);
47
+ }
48
+ return ret;
49
+ }
50
+ function toHex(bytes) {
51
+ return Array.prototype.map.call(bytes, function(n) {
52
+ return (n < 16 ? "0" : "") + n.toString(16);
53
+ }).join("");
54
+ }
55
+ function uint32ToHex(val) {
56
+ return (4294967296 + val).toString(16).substring(1);
57
+ }
58
+ function debugPrint(label, arr, size) {
59
+ let msg = "\n" + label + " = ";
60
+ for (let i = 0; i < arr.length; i += 2) {
61
+ if (size === 32) {
62
+ msg += uint32ToHex(arr[i]).toUpperCase();
63
+ msg += " ";
64
+ msg += uint32ToHex(arr[i + 1]).toUpperCase();
65
+ } else if (size === 64) {
66
+ msg += uint32ToHex(arr[i + 1]).toUpperCase();
67
+ msg += uint32ToHex(arr[i]).toUpperCase();
68
+ } else throw new Error("Invalid size " + size);
69
+ if (i % 6 === 4) {
70
+ msg += "\n" + new Array(label.length + 4).join(" ");
71
+ } else if (i < arr.length - 2) {
72
+ msg += " ";
73
+ }
74
+ }
75
+ console.log(msg);
76
+ }
77
+ function testSpeed(hashFn, N, M) {
78
+ let startMs = (/* @__PURE__ */ new Date()).getTime();
79
+ const input = new Uint8Array(N);
80
+ for (let i = 0; i < N; i++) {
81
+ input[i] = i % 256;
82
+ }
83
+ const genMs = (/* @__PURE__ */ new Date()).getTime();
84
+ console.log("Generated random input in " + (genMs - startMs) + "ms");
85
+ startMs = genMs;
86
+ for (let i = 0; i < M; i++) {
87
+ const hashHex = hashFn(input);
88
+ const hashMs = (/* @__PURE__ */ new Date()).getTime();
89
+ const ms = hashMs - startMs;
90
+ startMs = hashMs;
91
+ console.log("Hashed in " + ms + "ms: " + hashHex.substring(0, 20) + "...");
92
+ console.log(
93
+ Math.round(N / (1 << 20) / (ms / 1e3) * 100) / 100 + " MB PER SECOND"
94
+ );
95
+ }
96
+ }
97
+ module2.exports = {
98
+ normalizeInput,
99
+ toHex,
100
+ debugPrint,
101
+ testSpeed
102
+ };
103
+ }
104
+ });
105
+
106
+ // ../../node_modules/blakejs/blake2b.js
107
+ var require_blake2b = __commonJS({
108
+ "../../node_modules/blakejs/blake2b.js"(exports2, module2) {
109
+ "use strict";
110
+ var util = require_util();
111
+ function ADD64AA(v2, a, b) {
112
+ const o0 = v2[a] + v2[b];
113
+ let o1 = v2[a + 1] + v2[b + 1];
114
+ if (o0 >= 4294967296) {
115
+ o1++;
116
+ }
117
+ v2[a] = o0;
118
+ v2[a + 1] = o1;
119
+ }
120
+ function ADD64AC(v2, a, b0, b1) {
121
+ let o0 = v2[a] + b0;
122
+ if (b0 < 0) {
123
+ o0 += 4294967296;
124
+ }
125
+ let o1 = v2[a + 1] + b1;
126
+ if (o0 >= 4294967296) {
127
+ o1++;
128
+ }
129
+ v2[a] = o0;
130
+ v2[a + 1] = o1;
131
+ }
132
+ function B2B_GET32(arr, i) {
133
+ return arr[i] ^ arr[i + 1] << 8 ^ arr[i + 2] << 16 ^ arr[i + 3] << 24;
134
+ }
135
+ function B2B_G(a, b, c, d, ix, iy) {
136
+ const x0 = m[ix];
137
+ const x1 = m[ix + 1];
138
+ const y0 = m[iy];
139
+ const y1 = m[iy + 1];
140
+ ADD64AA(v, a, b);
141
+ ADD64AC(v, a, x0, x1);
142
+ let xor0 = v[d] ^ v[a];
143
+ let xor1 = v[d + 1] ^ v[a + 1];
144
+ v[d] = xor1;
145
+ v[d + 1] = xor0;
146
+ ADD64AA(v, c, d);
147
+ xor0 = v[b] ^ v[c];
148
+ xor1 = v[b + 1] ^ v[c + 1];
149
+ v[b] = xor0 >>> 24 ^ xor1 << 8;
150
+ v[b + 1] = xor1 >>> 24 ^ xor0 << 8;
151
+ ADD64AA(v, a, b);
152
+ ADD64AC(v, a, y0, y1);
153
+ xor0 = v[d] ^ v[a];
154
+ xor1 = v[d + 1] ^ v[a + 1];
155
+ v[d] = xor0 >>> 16 ^ xor1 << 16;
156
+ v[d + 1] = xor1 >>> 16 ^ xor0 << 16;
157
+ ADD64AA(v, c, d);
158
+ xor0 = v[b] ^ v[c];
159
+ xor1 = v[b + 1] ^ v[c + 1];
160
+ v[b] = xor1 >>> 31 ^ xor0 << 1;
161
+ v[b + 1] = xor0 >>> 31 ^ xor1 << 1;
162
+ }
163
+ var BLAKE2B_IV32 = new Uint32Array([
164
+ 4089235720,
165
+ 1779033703,
166
+ 2227873595,
167
+ 3144134277,
168
+ 4271175723,
169
+ 1013904242,
170
+ 1595750129,
171
+ 2773480762,
172
+ 2917565137,
173
+ 1359893119,
174
+ 725511199,
175
+ 2600822924,
176
+ 4215389547,
177
+ 528734635,
178
+ 327033209,
179
+ 1541459225
180
+ ]);
181
+ var SIGMA8 = [
182
+ 0,
183
+ 1,
184
+ 2,
185
+ 3,
186
+ 4,
187
+ 5,
188
+ 6,
189
+ 7,
190
+ 8,
191
+ 9,
192
+ 10,
193
+ 11,
194
+ 12,
195
+ 13,
196
+ 14,
197
+ 15,
198
+ 14,
199
+ 10,
200
+ 4,
201
+ 8,
202
+ 9,
203
+ 15,
204
+ 13,
205
+ 6,
206
+ 1,
207
+ 12,
208
+ 0,
209
+ 2,
210
+ 11,
211
+ 7,
212
+ 5,
213
+ 3,
214
+ 11,
215
+ 8,
216
+ 12,
217
+ 0,
218
+ 5,
219
+ 2,
220
+ 15,
221
+ 13,
222
+ 10,
223
+ 14,
224
+ 3,
225
+ 6,
226
+ 7,
227
+ 1,
228
+ 9,
229
+ 4,
230
+ 7,
231
+ 9,
232
+ 3,
233
+ 1,
234
+ 13,
235
+ 12,
236
+ 11,
237
+ 14,
238
+ 2,
239
+ 6,
240
+ 5,
241
+ 10,
242
+ 4,
243
+ 0,
244
+ 15,
245
+ 8,
246
+ 9,
247
+ 0,
248
+ 5,
249
+ 7,
250
+ 2,
251
+ 4,
252
+ 10,
253
+ 15,
254
+ 14,
255
+ 1,
256
+ 11,
257
+ 12,
258
+ 6,
259
+ 8,
260
+ 3,
261
+ 13,
262
+ 2,
263
+ 12,
264
+ 6,
265
+ 10,
266
+ 0,
267
+ 11,
268
+ 8,
269
+ 3,
270
+ 4,
271
+ 13,
272
+ 7,
273
+ 5,
274
+ 15,
275
+ 14,
276
+ 1,
277
+ 9,
278
+ 12,
279
+ 5,
280
+ 1,
281
+ 15,
282
+ 14,
283
+ 13,
284
+ 4,
285
+ 10,
286
+ 0,
287
+ 7,
288
+ 6,
289
+ 3,
290
+ 9,
291
+ 2,
292
+ 8,
293
+ 11,
294
+ 13,
295
+ 11,
296
+ 7,
297
+ 14,
298
+ 12,
299
+ 1,
300
+ 3,
301
+ 9,
302
+ 5,
303
+ 0,
304
+ 15,
305
+ 4,
306
+ 8,
307
+ 6,
308
+ 2,
309
+ 10,
310
+ 6,
311
+ 15,
312
+ 14,
313
+ 9,
314
+ 11,
315
+ 3,
316
+ 0,
317
+ 8,
318
+ 12,
319
+ 2,
320
+ 13,
321
+ 7,
322
+ 1,
323
+ 4,
324
+ 10,
325
+ 5,
326
+ 10,
327
+ 2,
328
+ 8,
329
+ 4,
330
+ 7,
331
+ 6,
332
+ 1,
333
+ 5,
334
+ 15,
335
+ 11,
336
+ 9,
337
+ 14,
338
+ 3,
339
+ 12,
340
+ 13,
341
+ 0,
342
+ 0,
343
+ 1,
344
+ 2,
345
+ 3,
346
+ 4,
347
+ 5,
348
+ 6,
349
+ 7,
350
+ 8,
351
+ 9,
352
+ 10,
353
+ 11,
354
+ 12,
355
+ 13,
356
+ 14,
357
+ 15,
358
+ 14,
359
+ 10,
360
+ 4,
361
+ 8,
362
+ 9,
363
+ 15,
364
+ 13,
365
+ 6,
366
+ 1,
367
+ 12,
368
+ 0,
369
+ 2,
370
+ 11,
371
+ 7,
372
+ 5,
373
+ 3
374
+ ];
375
+ var SIGMA82 = new Uint8Array(
376
+ SIGMA8.map(function(x) {
377
+ return x * 2;
378
+ })
379
+ );
380
+ var v = new Uint32Array(32);
381
+ var m = new Uint32Array(32);
382
+ function blake2bCompress(ctx, last) {
383
+ let i = 0;
384
+ for (i = 0; i < 16; i++) {
385
+ v[i] = ctx.h[i];
386
+ v[i + 16] = BLAKE2B_IV32[i];
387
+ }
388
+ v[24] = v[24] ^ ctx.t;
389
+ v[25] = v[25] ^ ctx.t / 4294967296;
390
+ if (last) {
391
+ v[28] = ~v[28];
392
+ v[29] = ~v[29];
393
+ }
394
+ for (i = 0; i < 32; i++) {
395
+ m[i] = B2B_GET32(ctx.b, 4 * i);
396
+ }
397
+ for (i = 0; i < 12; i++) {
398
+ B2B_G(0, 8, 16, 24, SIGMA82[i * 16 + 0], SIGMA82[i * 16 + 1]);
399
+ B2B_G(2, 10, 18, 26, SIGMA82[i * 16 + 2], SIGMA82[i * 16 + 3]);
400
+ B2B_G(4, 12, 20, 28, SIGMA82[i * 16 + 4], SIGMA82[i * 16 + 5]);
401
+ B2B_G(6, 14, 22, 30, SIGMA82[i * 16 + 6], SIGMA82[i * 16 + 7]);
402
+ B2B_G(0, 10, 20, 30, SIGMA82[i * 16 + 8], SIGMA82[i * 16 + 9]);
403
+ B2B_G(2, 12, 22, 24, SIGMA82[i * 16 + 10], SIGMA82[i * 16 + 11]);
404
+ B2B_G(4, 14, 16, 26, SIGMA82[i * 16 + 12], SIGMA82[i * 16 + 13]);
405
+ B2B_G(6, 8, 18, 28, SIGMA82[i * 16 + 14], SIGMA82[i * 16 + 15]);
406
+ }
407
+ for (i = 0; i < 16; i++) {
408
+ ctx.h[i] = ctx.h[i] ^ v[i] ^ v[i + 16];
409
+ }
410
+ }
411
+ var parameterBlock = new Uint8Array([
412
+ 0,
413
+ 0,
414
+ 0,
415
+ 0,
416
+ // 0: outlen, keylen, fanout, depth
417
+ 0,
418
+ 0,
419
+ 0,
420
+ 0,
421
+ // 4: leaf length, sequential mode
422
+ 0,
423
+ 0,
424
+ 0,
425
+ 0,
426
+ // 8: node offset
427
+ 0,
428
+ 0,
429
+ 0,
430
+ 0,
431
+ // 12: node offset
432
+ 0,
433
+ 0,
434
+ 0,
435
+ 0,
436
+ // 16: node depth, inner length, rfu
437
+ 0,
438
+ 0,
439
+ 0,
440
+ 0,
441
+ // 20: rfu
442
+ 0,
443
+ 0,
444
+ 0,
445
+ 0,
446
+ // 24: rfu
447
+ 0,
448
+ 0,
449
+ 0,
450
+ 0,
451
+ // 28: rfu
452
+ 0,
453
+ 0,
454
+ 0,
455
+ 0,
456
+ // 32: salt
457
+ 0,
458
+ 0,
459
+ 0,
460
+ 0,
461
+ // 36: salt
462
+ 0,
463
+ 0,
464
+ 0,
465
+ 0,
466
+ // 40: salt
467
+ 0,
468
+ 0,
469
+ 0,
470
+ 0,
471
+ // 44: salt
472
+ 0,
473
+ 0,
474
+ 0,
475
+ 0,
476
+ // 48: personal
477
+ 0,
478
+ 0,
479
+ 0,
480
+ 0,
481
+ // 52: personal
482
+ 0,
483
+ 0,
484
+ 0,
485
+ 0,
486
+ // 56: personal
487
+ 0,
488
+ 0,
489
+ 0,
490
+ 0
491
+ // 60: personal
492
+ ]);
493
+ function blake2bInit(outlen, key, salt, personal) {
494
+ if (outlen === 0 || outlen > 64) {
495
+ throw new Error("Illegal output length, expected 0 < length <= 64");
496
+ }
497
+ if (key && key.length > 64) {
498
+ throw new Error("Illegal key, expected Uint8Array with 0 < length <= 64");
499
+ }
500
+ if (salt && salt.length !== 16) {
501
+ throw new Error("Illegal salt, expected Uint8Array with length is 16");
502
+ }
503
+ if (personal && personal.length !== 16) {
504
+ throw new Error("Illegal personal, expected Uint8Array with length is 16");
505
+ }
506
+ const ctx = {
507
+ b: new Uint8Array(128),
508
+ h: new Uint32Array(16),
509
+ t: 0,
510
+ // input count
511
+ c: 0,
512
+ // pointer within buffer
513
+ outlen
514
+ // output length in bytes
515
+ };
516
+ parameterBlock.fill(0);
517
+ parameterBlock[0] = outlen;
518
+ if (key) parameterBlock[1] = key.length;
519
+ parameterBlock[2] = 1;
520
+ parameterBlock[3] = 1;
521
+ if (salt) parameterBlock.set(salt, 32);
522
+ if (personal) parameterBlock.set(personal, 48);
523
+ for (let i = 0; i < 16; i++) {
524
+ ctx.h[i] = BLAKE2B_IV32[i] ^ B2B_GET32(parameterBlock, i * 4);
525
+ }
526
+ if (key) {
527
+ blake2bUpdate(ctx, key);
528
+ ctx.c = 128;
529
+ }
530
+ return ctx;
531
+ }
532
+ function blake2bUpdate(ctx, input) {
533
+ for (let i = 0; i < input.length; i++) {
534
+ if (ctx.c === 128) {
535
+ ctx.t += ctx.c;
536
+ blake2bCompress(ctx, false);
537
+ ctx.c = 0;
538
+ }
539
+ ctx.b[ctx.c++] = input[i];
540
+ }
541
+ }
542
+ function blake2bFinal(ctx) {
543
+ ctx.t += ctx.c;
544
+ while (ctx.c < 128) {
545
+ ctx.b[ctx.c++] = 0;
546
+ }
547
+ blake2bCompress(ctx, true);
548
+ const out = new Uint8Array(ctx.outlen);
549
+ for (let i = 0; i < ctx.outlen; i++) {
550
+ out[i] = ctx.h[i >> 2] >> 8 * (i & 3);
551
+ }
552
+ return out;
553
+ }
554
+ function blake2b2(input, key, outlen, salt, personal) {
555
+ outlen = outlen || 64;
556
+ input = util.normalizeInput(input);
557
+ if (salt) {
558
+ salt = util.normalizeInput(salt);
559
+ }
560
+ if (personal) {
561
+ personal = util.normalizeInput(personal);
562
+ }
563
+ const ctx = blake2bInit(outlen, key, salt, personal);
564
+ blake2bUpdate(ctx, input);
565
+ return blake2bFinal(ctx);
566
+ }
567
+ function blake2bHex2(input, key, outlen, salt, personal) {
568
+ const output = blake2b2(input, key, outlen, salt, personal);
569
+ return util.toHex(output);
570
+ }
571
+ module2.exports = {
572
+ blake2b: blake2b2,
573
+ blake2bHex: blake2bHex2,
574
+ blake2bInit,
575
+ blake2bUpdate,
576
+ blake2bFinal
577
+ };
578
+ }
579
+ });
580
+
581
+ // ../../node_modules/blakejs/blake2s.js
582
+ var require_blake2s = __commonJS({
583
+ "../../node_modules/blakejs/blake2s.js"(exports2, module2) {
584
+ "use strict";
585
+ var util = require_util();
586
+ function B2S_GET32(v2, i) {
587
+ return v2[i] ^ v2[i + 1] << 8 ^ v2[i + 2] << 16 ^ v2[i + 3] << 24;
588
+ }
589
+ function B2S_G(a, b, c, d, x, y) {
590
+ v[a] = v[a] + v[b] + x;
591
+ v[d] = ROTR32(v[d] ^ v[a], 16);
592
+ v[c] = v[c] + v[d];
593
+ v[b] = ROTR32(v[b] ^ v[c], 12);
594
+ v[a] = v[a] + v[b] + y;
595
+ v[d] = ROTR32(v[d] ^ v[a], 8);
596
+ v[c] = v[c] + v[d];
597
+ v[b] = ROTR32(v[b] ^ v[c], 7);
598
+ }
599
+ function ROTR32(x, y) {
600
+ return x >>> y ^ x << 32 - y;
601
+ }
602
+ var BLAKE2S_IV = new Uint32Array([
603
+ 1779033703,
604
+ 3144134277,
605
+ 1013904242,
606
+ 2773480762,
607
+ 1359893119,
608
+ 2600822924,
609
+ 528734635,
610
+ 1541459225
611
+ ]);
612
+ var SIGMA = new Uint8Array([
613
+ 0,
614
+ 1,
615
+ 2,
616
+ 3,
617
+ 4,
618
+ 5,
619
+ 6,
620
+ 7,
621
+ 8,
622
+ 9,
623
+ 10,
624
+ 11,
625
+ 12,
626
+ 13,
627
+ 14,
628
+ 15,
629
+ 14,
630
+ 10,
631
+ 4,
632
+ 8,
633
+ 9,
634
+ 15,
635
+ 13,
636
+ 6,
637
+ 1,
638
+ 12,
639
+ 0,
640
+ 2,
641
+ 11,
642
+ 7,
643
+ 5,
644
+ 3,
645
+ 11,
646
+ 8,
647
+ 12,
648
+ 0,
649
+ 5,
650
+ 2,
651
+ 15,
652
+ 13,
653
+ 10,
654
+ 14,
655
+ 3,
656
+ 6,
657
+ 7,
658
+ 1,
659
+ 9,
660
+ 4,
661
+ 7,
662
+ 9,
663
+ 3,
664
+ 1,
665
+ 13,
666
+ 12,
667
+ 11,
668
+ 14,
669
+ 2,
670
+ 6,
671
+ 5,
672
+ 10,
673
+ 4,
674
+ 0,
675
+ 15,
676
+ 8,
677
+ 9,
678
+ 0,
679
+ 5,
680
+ 7,
681
+ 2,
682
+ 4,
683
+ 10,
684
+ 15,
685
+ 14,
686
+ 1,
687
+ 11,
688
+ 12,
689
+ 6,
690
+ 8,
691
+ 3,
692
+ 13,
693
+ 2,
694
+ 12,
695
+ 6,
696
+ 10,
697
+ 0,
698
+ 11,
699
+ 8,
700
+ 3,
701
+ 4,
702
+ 13,
703
+ 7,
704
+ 5,
705
+ 15,
706
+ 14,
707
+ 1,
708
+ 9,
709
+ 12,
710
+ 5,
711
+ 1,
712
+ 15,
713
+ 14,
714
+ 13,
715
+ 4,
716
+ 10,
717
+ 0,
718
+ 7,
719
+ 6,
720
+ 3,
721
+ 9,
722
+ 2,
723
+ 8,
724
+ 11,
725
+ 13,
726
+ 11,
727
+ 7,
728
+ 14,
729
+ 12,
730
+ 1,
731
+ 3,
732
+ 9,
733
+ 5,
734
+ 0,
735
+ 15,
736
+ 4,
737
+ 8,
738
+ 6,
739
+ 2,
740
+ 10,
741
+ 6,
742
+ 15,
743
+ 14,
744
+ 9,
745
+ 11,
746
+ 3,
747
+ 0,
748
+ 8,
749
+ 12,
750
+ 2,
751
+ 13,
752
+ 7,
753
+ 1,
754
+ 4,
755
+ 10,
756
+ 5,
757
+ 10,
758
+ 2,
759
+ 8,
760
+ 4,
761
+ 7,
762
+ 6,
763
+ 1,
764
+ 5,
765
+ 15,
766
+ 11,
767
+ 9,
768
+ 14,
769
+ 3,
770
+ 12,
771
+ 13,
772
+ 0
773
+ ]);
774
+ var v = new Uint32Array(16);
775
+ var m = new Uint32Array(16);
776
+ function blake2sCompress(ctx, last) {
777
+ let i = 0;
778
+ for (i = 0; i < 8; i++) {
779
+ v[i] = ctx.h[i];
780
+ v[i + 8] = BLAKE2S_IV[i];
781
+ }
782
+ v[12] ^= ctx.t;
783
+ v[13] ^= ctx.t / 4294967296;
784
+ if (last) {
785
+ v[14] = ~v[14];
786
+ }
787
+ for (i = 0; i < 16; i++) {
788
+ m[i] = B2S_GET32(ctx.b, 4 * i);
789
+ }
790
+ for (i = 0; i < 10; i++) {
791
+ B2S_G(0, 4, 8, 12, m[SIGMA[i * 16 + 0]], m[SIGMA[i * 16 + 1]]);
792
+ B2S_G(1, 5, 9, 13, m[SIGMA[i * 16 + 2]], m[SIGMA[i * 16 + 3]]);
793
+ B2S_G(2, 6, 10, 14, m[SIGMA[i * 16 + 4]], m[SIGMA[i * 16 + 5]]);
794
+ B2S_G(3, 7, 11, 15, m[SIGMA[i * 16 + 6]], m[SIGMA[i * 16 + 7]]);
795
+ B2S_G(0, 5, 10, 15, m[SIGMA[i * 16 + 8]], m[SIGMA[i * 16 + 9]]);
796
+ B2S_G(1, 6, 11, 12, m[SIGMA[i * 16 + 10]], m[SIGMA[i * 16 + 11]]);
797
+ B2S_G(2, 7, 8, 13, m[SIGMA[i * 16 + 12]], m[SIGMA[i * 16 + 13]]);
798
+ B2S_G(3, 4, 9, 14, m[SIGMA[i * 16 + 14]], m[SIGMA[i * 16 + 15]]);
799
+ }
800
+ for (i = 0; i < 8; i++) {
801
+ ctx.h[i] ^= v[i] ^ v[i + 8];
802
+ }
803
+ }
804
+ function blake2sInit(outlen, key) {
805
+ if (!(outlen > 0 && outlen <= 32)) {
806
+ throw new Error("Incorrect output length, should be in [1, 32]");
807
+ }
808
+ const keylen = key ? key.length : 0;
809
+ if (key && !(keylen > 0 && keylen <= 32)) {
810
+ throw new Error("Incorrect key length, should be in [1, 32]");
811
+ }
812
+ const ctx = {
813
+ h: new Uint32Array(BLAKE2S_IV),
814
+ // hash state
815
+ b: new Uint8Array(64),
816
+ // input block
817
+ c: 0,
818
+ // pointer within block
819
+ t: 0,
820
+ // input count
821
+ outlen
822
+ // output length in bytes
823
+ };
824
+ ctx.h[0] ^= 16842752 ^ keylen << 8 ^ outlen;
825
+ if (keylen > 0) {
826
+ blake2sUpdate(ctx, key);
827
+ ctx.c = 64;
828
+ }
829
+ return ctx;
830
+ }
831
+ function blake2sUpdate(ctx, input) {
832
+ for (let i = 0; i < input.length; i++) {
833
+ if (ctx.c === 64) {
834
+ ctx.t += ctx.c;
835
+ blake2sCompress(ctx, false);
836
+ ctx.c = 0;
837
+ }
838
+ ctx.b[ctx.c++] = input[i];
839
+ }
840
+ }
841
+ function blake2sFinal(ctx) {
842
+ ctx.t += ctx.c;
843
+ while (ctx.c < 64) {
844
+ ctx.b[ctx.c++] = 0;
845
+ }
846
+ blake2sCompress(ctx, true);
847
+ const out = new Uint8Array(ctx.outlen);
848
+ for (let i = 0; i < ctx.outlen; i++) {
849
+ out[i] = ctx.h[i >> 2] >> 8 * (i & 3) & 255;
850
+ }
851
+ return out;
852
+ }
853
+ function blake2s(input, key, outlen) {
854
+ outlen = outlen || 32;
855
+ input = util.normalizeInput(input);
856
+ const ctx = blake2sInit(outlen, key);
857
+ blake2sUpdate(ctx, input);
858
+ return blake2sFinal(ctx);
859
+ }
860
+ function blake2sHex(input, key, outlen) {
861
+ const output = blake2s(input, key, outlen);
862
+ return util.toHex(output);
863
+ }
864
+ module2.exports = {
865
+ blake2s,
866
+ blake2sHex,
867
+ blake2sInit,
868
+ blake2sUpdate,
869
+ blake2sFinal
870
+ };
871
+ }
872
+ });
873
+
874
+ // ../../node_modules/blakejs/index.js
875
+ var require_blakejs = __commonJS({
876
+ "../../node_modules/blakejs/index.js"(exports2, module2) {
877
+ "use strict";
878
+ var b2b = require_blake2b();
879
+ var b2s = require_blake2s();
880
+ module2.exports = {
881
+ blake2b: b2b.blake2b,
882
+ blake2bHex: b2b.blake2bHex,
883
+ blake2bInit: b2b.blake2bInit,
884
+ blake2bUpdate: b2b.blake2bUpdate,
885
+ blake2bFinal: b2b.blake2bFinal,
886
+ blake2s: b2s.blake2s,
887
+ blake2sHex: b2s.blake2sHex,
888
+ blake2sInit: b2s.blake2sInit,
889
+ blake2sUpdate: b2s.blake2sUpdate,
890
+ blake2sFinal: b2s.blake2sFinal
891
+ };
892
+ }
893
+ });
894
+
30
895
  // src/index.ts
31
896
  var src_exports = {};
32
897
  __export(src_exports, {
@@ -38,6 +903,7 @@ __export(src_exports, {
38
903
  DEFAULT_REDEEMER_BUDGET: () => DEFAULT_REDEEMER_BUDGET,
39
904
  DEFAULT_V1_COST_MODEL_LIST: () => DEFAULT_V1_COST_MODEL_LIST,
40
905
  DEFAULT_V2_COST_MODEL_LIST: () => DEFAULT_V2_COST_MODEL_LIST,
906
+ DREP_DEPOSIT: () => DREP_DEPOSIT,
41
907
  HARDENED_KEY_START: () => HARDENED_KEY_START,
42
908
  LANGUAGE_VERSIONS: () => LANGUAGE_VERSIONS,
43
909
  MeshValue: () => MeshValue,
@@ -69,7 +935,9 @@ __export(src_exports, {
69
935
  fromUTF8: () => fromUTF8,
70
936
  fungibleAssetKeys: () => fungibleAssetKeys,
71
937
  generateMnemonic: () => import_bip39.generateMnemonic,
938
+ getFile: () => getFile,
72
939
  hashByteString: () => hashByteString,
940
+ hashDrepAnchor: () => hashDrepAnchor,
73
941
  hexToBytes: () => hexToBytes,
74
942
  hexToString: () => hexToString,
75
943
  integer: () => integer,
@@ -151,6 +1019,7 @@ var DEFAULT_PROTOCOL_PARAMETERS = {
151
1019
  maxBlockExSteps: "40000000000",
152
1020
  minFeeRefScriptCostPerByte: 15
153
1021
  };
1022
+ var DREP_DEPOSIT = "500000000";
154
1023
  var resolveTxFees = (txSize, minFeeA = DEFAULT_PROTOCOL_PARAMETERS.minFeeA, minFeeB = DEFAULT_PROTOCOL_PARAMETERS.minFeeB) => {
155
1024
  const fees = BigInt(minFeeA) * BigInt(txSize) + BigInt(minFeeB);
156
1025
  return fees.toString();
@@ -727,12 +1596,17 @@ var mAssetClass = (currencySymbolHex, tokenNameHex) => {
727
1596
  return mConStr0([currencySymbolHex, tokenNameHex]);
728
1597
  };
729
1598
  var mOutputReference = (txHash, index) => {
1599
+ if (txHash.length !== 64) {
1600
+ throw new Error("Invalid transaction hash - should be 32 bytes long");
1601
+ }
1602
+ return mConStr0([txHash, index]);
1603
+ };
1604
+ var mTxOutRef = (txHash, index) => {
730
1605
  if (txHash.length !== 64) {
731
1606
  throw new Error("Invalid transaction hash - should be 32 bytes long");
732
1607
  }
733
1608
  return mConStr0([mConStr0([txHash]), index]);
734
1609
  };
735
- var mTxOutRef = (txHash, index) => mOutputReference(txHash, index);
736
1610
  var mTuple = (key, value2) => [key, value2];
737
1611
 
738
1612
  // src/data/mesh/credentials.ts
@@ -869,12 +1743,17 @@ var assetName = (bytes) => {
869
1743
  var tokenName = (bytes) => assetName(bytes);
870
1744
  var assetClass = (currencySymbolHex, tokenNameHex) => conStr0([currencySymbol(currencySymbolHex), tokenName(tokenNameHex)]);
871
1745
  var outputReference = (txHash, index) => {
1746
+ if (txHash.length !== 64) {
1747
+ throw new Error("Invalid transaction hash - should be 32 bytes long");
1748
+ }
1749
+ return conStr0([byteString(txHash), integer(index)]);
1750
+ };
1751
+ var txOutRef = (txHash, index) => {
872
1752
  if (txHash.length !== 64) {
873
1753
  throw new Error("Invalid transaction hash - should be 32 bytes long");
874
1754
  }
875
1755
  return conStr0([conStr0([byteString(txHash)]), integer(index)]);
876
1756
  };
877
- var txOutRef = (txHash, index) => outputReference(txHash, index);
878
1757
  var posixTime = (int) => ({ int });
879
1758
  var dict = (itemsMap) => ({
880
1759
  map: itemsMap.map(([k, v]) => ({ k, v }))
@@ -1028,7 +1907,7 @@ var AssetFingerprint = class _AssetFingerprint {
1028
1907
  }
1029
1908
  };
1030
1909
 
1031
- // src/utils/bigNum.ts
1910
+ // src/utils/big-num.ts
1032
1911
  var BigNum = class _BigNum {
1033
1912
  value;
1034
1913
  constructor(value2) {
@@ -1085,6 +1964,21 @@ var BigNum = class _BigNum {
1085
1964
  }
1086
1965
  };
1087
1966
 
1967
+ // src/utils/data-hash.ts
1968
+ var import_blakejs = __toESM(require_blakejs(), 1);
1969
+ var hashDrepAnchor = (jsonLD) => {
1970
+ const jsonHash = (0, import_blakejs.blake2bHex)(JSON.stringify(jsonLD, null, 2), void 0, 32);
1971
+ return jsonHash;
1972
+ };
1973
+
1974
+ // src/utils/file.ts
1975
+ function getFile(url) {
1976
+ var Httpreq = new XMLHttpRequest();
1977
+ Httpreq.open("GET", url, false);
1978
+ Httpreq.send(null);
1979
+ return Httpreq.responseText;
1980
+ }
1981
+
1088
1982
  // src/data/value.ts
1089
1983
  var value = (assets) => {
1090
1984
  return MeshValue.fromAssets(assets).toJSON();
@@ -1598,6 +2492,7 @@ var import_bip39 = require("bip39");
1598
2492
  DEFAULT_REDEEMER_BUDGET,
1599
2493
  DEFAULT_V1_COST_MODEL_LIST,
1600
2494
  DEFAULT_V2_COST_MODEL_LIST,
2495
+ DREP_DEPOSIT,
1601
2496
  HARDENED_KEY_START,
1602
2497
  LANGUAGE_VERSIONS,
1603
2498
  MeshValue,
@@ -1629,7 +2524,9 @@ var import_bip39 = require("bip39");
1629
2524
  fromUTF8,
1630
2525
  fungibleAssetKeys,
1631
2526
  generateMnemonic,
2527
+ getFile,
1632
2528
  hashByteString,
2529
+ hashDrepAnchor,
1633
2530
  hexToBytes,
1634
2531
  hexToString,
1635
2532
  integer,