@vleap/warps-adapter-fastset 0.1.0-alpha.26 → 0.1.0-alpha.27
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.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +573 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +579 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ 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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
9
|
var __export = (target, all) => {
|
|
9
10
|
for (var name2 in all)
|
|
10
11
|
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
@@ -26,6 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
27
|
mod
|
|
27
28
|
));
|
|
28
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
29
31
|
|
|
30
32
|
// src/index.ts
|
|
31
33
|
var index_exports = {};
|
|
@@ -256,8 +258,8 @@ var WarpFastsetExplorer = class {
|
|
|
256
258
|
getAccountUrl(address) {
|
|
257
259
|
return `${this.explorerUrl}/account/${address}`;
|
|
258
260
|
}
|
|
259
|
-
getTransactionUrl(
|
|
260
|
-
return `${this.explorerUrl}/transaction/${
|
|
261
|
+
getTransactionUrl(hash2) {
|
|
262
|
+
return `${this.explorerUrl}/transaction/${hash2}`;
|
|
261
263
|
}
|
|
262
264
|
getAssetUrl(identifier) {
|
|
263
265
|
return `${this.explorerUrl}/asset/${identifier}`;
|
|
@@ -469,15 +471,549 @@ var WarpFastsetResults = class {
|
|
|
469
471
|
var bip39 = __toESM(require("@scure/bip39"), 1);
|
|
470
472
|
var import_warps5 = require("@vleap/warps");
|
|
471
473
|
|
|
472
|
-
//
|
|
473
|
-
var
|
|
474
|
+
// ../../node_modules/@noble/ed25519/index.js
|
|
475
|
+
var ed25519_exports = {};
|
|
476
|
+
__export(ed25519_exports, {
|
|
477
|
+
Point: () => Point,
|
|
478
|
+
etc: () => etc,
|
|
479
|
+
getPublicKey: () => getPublicKey,
|
|
480
|
+
getPublicKeyAsync: () => getPublicKeyAsync,
|
|
481
|
+
hash: () => hash,
|
|
482
|
+
hashes: () => hashes,
|
|
483
|
+
keygen: () => keygen,
|
|
484
|
+
keygenAsync: () => keygenAsync,
|
|
485
|
+
sign: () => sign,
|
|
486
|
+
signAsync: () => signAsync,
|
|
487
|
+
utils: () => utils,
|
|
488
|
+
verify: () => verify,
|
|
489
|
+
verifyAsync: () => verifyAsync
|
|
490
|
+
});
|
|
491
|
+
var ed25519_CURVE = {
|
|
492
|
+
p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
|
|
493
|
+
n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
|
|
494
|
+
h: 8n,
|
|
495
|
+
a: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,
|
|
496
|
+
d: 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,
|
|
497
|
+
Gx: 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,
|
|
498
|
+
Gy: 0x6666666666666666666666666666666666666666666666666666666666666658n
|
|
499
|
+
};
|
|
500
|
+
var { p: P, n: N, Gx, Gy, a: _a, d: _d, h } = ed25519_CURVE;
|
|
501
|
+
var L = 32;
|
|
502
|
+
var L2 = 64;
|
|
503
|
+
var captureTrace = (...args) => {
|
|
504
|
+
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
|
|
505
|
+
Error.captureStackTrace(...args);
|
|
506
|
+
}
|
|
507
|
+
};
|
|
508
|
+
var err = (message = "") => {
|
|
509
|
+
const e = new Error(message);
|
|
510
|
+
captureTrace(e, err);
|
|
511
|
+
throw e;
|
|
512
|
+
};
|
|
513
|
+
var isBig = (n) => typeof n === "bigint";
|
|
514
|
+
var isStr = (s) => typeof s === "string";
|
|
515
|
+
var isBytes = (a) => a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
516
|
+
var abytes = (value, length, title = "") => {
|
|
517
|
+
const bytes = isBytes(value);
|
|
518
|
+
const len = value?.length;
|
|
519
|
+
const needsLen = length !== void 0;
|
|
520
|
+
if (!bytes || needsLen && len !== length) {
|
|
521
|
+
const prefix = title && `"${title}" `;
|
|
522
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
523
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
524
|
+
err(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
525
|
+
}
|
|
526
|
+
return value;
|
|
527
|
+
};
|
|
528
|
+
var u8n = (len) => new Uint8Array(len);
|
|
529
|
+
var u8fr = (buf) => Uint8Array.from(buf);
|
|
530
|
+
var padh = (n, pad) => n.toString(16).padStart(pad, "0");
|
|
531
|
+
var bytesToHex = (b) => Array.from(abytes(b)).map((e) => padh(e, 2)).join("");
|
|
532
|
+
var C = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
533
|
+
var _ch = (ch) => {
|
|
534
|
+
if (ch >= C._0 && ch <= C._9)
|
|
535
|
+
return ch - C._0;
|
|
536
|
+
if (ch >= C.A && ch <= C.F)
|
|
537
|
+
return ch - (C.A - 10);
|
|
538
|
+
if (ch >= C.a && ch <= C.f)
|
|
539
|
+
return ch - (C.a - 10);
|
|
540
|
+
return;
|
|
541
|
+
};
|
|
542
|
+
var hexToBytes = (hex) => {
|
|
543
|
+
const e = "hex invalid";
|
|
544
|
+
if (!isStr(hex))
|
|
545
|
+
return err(e);
|
|
546
|
+
const hl = hex.length;
|
|
547
|
+
const al = hl / 2;
|
|
548
|
+
if (hl % 2)
|
|
549
|
+
return err(e);
|
|
550
|
+
const array = u8n(al);
|
|
551
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
552
|
+
const n1 = _ch(hex.charCodeAt(hi));
|
|
553
|
+
const n2 = _ch(hex.charCodeAt(hi + 1));
|
|
554
|
+
if (n1 === void 0 || n2 === void 0)
|
|
555
|
+
return err(e);
|
|
556
|
+
array[ai] = n1 * 16 + n2;
|
|
557
|
+
}
|
|
558
|
+
return array;
|
|
559
|
+
};
|
|
560
|
+
var cr = () => globalThis?.crypto;
|
|
561
|
+
var subtle = () => cr()?.subtle ?? err("crypto.subtle must be defined, consider polyfill");
|
|
562
|
+
var concatBytes = (...arrs) => {
|
|
563
|
+
const r = u8n(arrs.reduce((sum, a) => sum + abytes(a).length, 0));
|
|
564
|
+
let pad = 0;
|
|
565
|
+
arrs.forEach((a) => {
|
|
566
|
+
r.set(a, pad);
|
|
567
|
+
pad += a.length;
|
|
568
|
+
});
|
|
569
|
+
return r;
|
|
570
|
+
};
|
|
571
|
+
var randomBytes = (len = L) => {
|
|
572
|
+
const c = cr();
|
|
573
|
+
return c.getRandomValues(u8n(len));
|
|
574
|
+
};
|
|
575
|
+
var big = BigInt;
|
|
576
|
+
var assertRange = (n, min, max, msg = "bad number: out of range") => isBig(n) && min <= n && n < max ? n : err(msg);
|
|
577
|
+
var M = (a, b = P) => {
|
|
578
|
+
const r = a % b;
|
|
579
|
+
return r >= 0n ? r : b + r;
|
|
580
|
+
};
|
|
581
|
+
var modN = (a) => M(a, N);
|
|
582
|
+
var invert = (num, md) => {
|
|
583
|
+
if (num === 0n || md <= 0n)
|
|
584
|
+
err("no inverse n=" + num + " mod=" + md);
|
|
585
|
+
let a = M(num, md), b = md, x = 0n, y = 1n, u = 1n, v = 0n;
|
|
586
|
+
while (a !== 0n) {
|
|
587
|
+
const q = b / a, r = b % a;
|
|
588
|
+
const m = x - u * q, n = y - v * q;
|
|
589
|
+
b = a, a = r, x = u, y = v, u = m, v = n;
|
|
590
|
+
}
|
|
591
|
+
return b === 1n ? M(x, md) : err("no inverse");
|
|
592
|
+
};
|
|
593
|
+
var callHash = (name2) => {
|
|
594
|
+
const fn = hashes[name2];
|
|
595
|
+
if (typeof fn !== "function")
|
|
596
|
+
err("hashes." + name2 + " not set");
|
|
597
|
+
return fn;
|
|
598
|
+
};
|
|
599
|
+
var hash = (msg) => callHash("sha512")(msg);
|
|
600
|
+
var apoint = (p) => p instanceof Point ? p : err("Point expected");
|
|
601
|
+
var B256 = 2n ** 256n;
|
|
602
|
+
var _Point = class _Point {
|
|
603
|
+
constructor(X, Y, Z, T) {
|
|
604
|
+
__publicField(this, "X");
|
|
605
|
+
__publicField(this, "Y");
|
|
606
|
+
__publicField(this, "Z");
|
|
607
|
+
__publicField(this, "T");
|
|
608
|
+
const max = B256;
|
|
609
|
+
this.X = assertRange(X, 0n, max);
|
|
610
|
+
this.Y = assertRange(Y, 0n, max);
|
|
611
|
+
this.Z = assertRange(Z, 1n, max);
|
|
612
|
+
this.T = assertRange(T, 0n, max);
|
|
613
|
+
Object.freeze(this);
|
|
614
|
+
}
|
|
615
|
+
static CURVE() {
|
|
616
|
+
return ed25519_CURVE;
|
|
617
|
+
}
|
|
618
|
+
static fromAffine(p) {
|
|
619
|
+
return new _Point(p.x, p.y, 1n, M(p.x * p.y));
|
|
620
|
+
}
|
|
621
|
+
/** RFC8032 5.1.3: Uint8Array to Point. */
|
|
622
|
+
static fromBytes(hex, zip215 = false) {
|
|
623
|
+
const d = _d;
|
|
624
|
+
const normed = u8fr(abytes(hex, L));
|
|
625
|
+
const lastByte = hex[31];
|
|
626
|
+
normed[31] = lastByte & ~128;
|
|
627
|
+
const y = bytesToNumLE(normed);
|
|
628
|
+
const max = zip215 ? B256 : P;
|
|
629
|
+
assertRange(y, 0n, max);
|
|
630
|
+
const y2 = M(y * y);
|
|
631
|
+
const u = M(y2 - 1n);
|
|
632
|
+
const v = M(d * y2 + 1n);
|
|
633
|
+
let { isValid, value: x } = uvRatio(u, v);
|
|
634
|
+
if (!isValid)
|
|
635
|
+
err("bad point: y not sqrt");
|
|
636
|
+
const isXOdd = (x & 1n) === 1n;
|
|
637
|
+
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
638
|
+
if (!zip215 && x === 0n && isLastByteOdd)
|
|
639
|
+
err("bad point: x==0, isLastByteOdd");
|
|
640
|
+
if (isLastByteOdd !== isXOdd)
|
|
641
|
+
x = M(-x);
|
|
642
|
+
return new _Point(x, y, 1n, M(x * y));
|
|
643
|
+
}
|
|
644
|
+
static fromHex(hex, zip215) {
|
|
645
|
+
return _Point.fromBytes(hexToBytes(hex), zip215);
|
|
646
|
+
}
|
|
647
|
+
get x() {
|
|
648
|
+
return this.toAffine().x;
|
|
649
|
+
}
|
|
650
|
+
get y() {
|
|
651
|
+
return this.toAffine().y;
|
|
652
|
+
}
|
|
653
|
+
/** Checks if the point is valid and on-curve. */
|
|
654
|
+
assertValidity() {
|
|
655
|
+
const a = _a;
|
|
656
|
+
const d = _d;
|
|
657
|
+
const p = this;
|
|
658
|
+
if (p.is0())
|
|
659
|
+
return err("bad point: ZERO");
|
|
660
|
+
const { X, Y, Z, T } = p;
|
|
661
|
+
const X2 = M(X * X);
|
|
662
|
+
const Y2 = M(Y * Y);
|
|
663
|
+
const Z2 = M(Z * Z);
|
|
664
|
+
const Z4 = M(Z2 * Z2);
|
|
665
|
+
const aX2 = M(X2 * a);
|
|
666
|
+
const left = M(Z2 * M(aX2 + Y2));
|
|
667
|
+
const right = M(Z4 + M(d * M(X2 * Y2)));
|
|
668
|
+
if (left !== right)
|
|
669
|
+
return err("bad point: equation left != right (1)");
|
|
670
|
+
const XY = M(X * Y);
|
|
671
|
+
const ZT = M(Z * T);
|
|
672
|
+
if (XY !== ZT)
|
|
673
|
+
return err("bad point: equation left != right (2)");
|
|
674
|
+
return this;
|
|
675
|
+
}
|
|
676
|
+
/** Equality check: compare points P&Q. */
|
|
677
|
+
equals(other) {
|
|
678
|
+
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
679
|
+
const { X: X2, Y: Y2, Z: Z2 } = apoint(other);
|
|
680
|
+
const X1Z2 = M(X1 * Z2);
|
|
681
|
+
const X2Z1 = M(X2 * Z1);
|
|
682
|
+
const Y1Z2 = M(Y1 * Z2);
|
|
683
|
+
const Y2Z1 = M(Y2 * Z1);
|
|
684
|
+
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
685
|
+
}
|
|
686
|
+
is0() {
|
|
687
|
+
return this.equals(I);
|
|
688
|
+
}
|
|
689
|
+
/** Flip point over y coordinate. */
|
|
690
|
+
negate() {
|
|
691
|
+
return new _Point(M(-this.X), this.Y, this.Z, M(-this.T));
|
|
692
|
+
}
|
|
693
|
+
/** Point doubling. Complete formula. Cost: `4M + 4S + 1*a + 6add + 1*2`. */
|
|
694
|
+
double() {
|
|
695
|
+
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
696
|
+
const a = _a;
|
|
697
|
+
const A = M(X1 * X1);
|
|
698
|
+
const B = M(Y1 * Y1);
|
|
699
|
+
const C2 = M(2n * M(Z1 * Z1));
|
|
700
|
+
const D = M(a * A);
|
|
701
|
+
const x1y1 = X1 + Y1;
|
|
702
|
+
const E = M(M(x1y1 * x1y1) - A - B);
|
|
703
|
+
const G2 = D + B;
|
|
704
|
+
const F = G2 - C2;
|
|
705
|
+
const H = D - B;
|
|
706
|
+
const X3 = M(E * F);
|
|
707
|
+
const Y3 = M(G2 * H);
|
|
708
|
+
const T3 = M(E * H);
|
|
709
|
+
const Z3 = M(F * G2);
|
|
710
|
+
return new _Point(X3, Y3, Z3, T3);
|
|
711
|
+
}
|
|
712
|
+
/** Point addition. Complete formula. Cost: `8M + 1*k + 8add + 1*2`. */
|
|
713
|
+
add(other) {
|
|
714
|
+
const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
|
|
715
|
+
const { X: X2, Y: Y2, Z: Z2, T: T2 } = apoint(other);
|
|
716
|
+
const a = _a;
|
|
717
|
+
const d = _d;
|
|
718
|
+
const A = M(X1 * X2);
|
|
719
|
+
const B = M(Y1 * Y2);
|
|
720
|
+
const C2 = M(T1 * d * T2);
|
|
721
|
+
const D = M(Z1 * Z2);
|
|
722
|
+
const E = M((X1 + Y1) * (X2 + Y2) - A - B);
|
|
723
|
+
const F = M(D - C2);
|
|
724
|
+
const G2 = M(D + C2);
|
|
725
|
+
const H = M(B - a * A);
|
|
726
|
+
const X3 = M(E * F);
|
|
727
|
+
const Y3 = M(G2 * H);
|
|
728
|
+
const T3 = M(E * H);
|
|
729
|
+
const Z3 = M(F * G2);
|
|
730
|
+
return new _Point(X3, Y3, Z3, T3);
|
|
731
|
+
}
|
|
732
|
+
subtract(other) {
|
|
733
|
+
return this.add(apoint(other).negate());
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Point-by-scalar multiplication. Scalar must be in range 1 <= n < CURVE.n.
|
|
737
|
+
* Uses {@link wNAF} for base point.
|
|
738
|
+
* Uses fake point to mitigate side-channel leakage.
|
|
739
|
+
* @param n scalar by which point is multiplied
|
|
740
|
+
* @param safe safe mode guards against timing attacks; unsafe mode is faster
|
|
741
|
+
*/
|
|
742
|
+
multiply(n, safe = true) {
|
|
743
|
+
if (!safe && (n === 0n || this.is0()))
|
|
744
|
+
return I;
|
|
745
|
+
assertRange(n, 1n, N);
|
|
746
|
+
if (n === 1n)
|
|
747
|
+
return this;
|
|
748
|
+
if (this.equals(G))
|
|
749
|
+
return wNAF(n).p;
|
|
750
|
+
let p = I;
|
|
751
|
+
let f = G;
|
|
752
|
+
for (let d = this; n > 0n; d = d.double(), n >>= 1n) {
|
|
753
|
+
if (n & 1n)
|
|
754
|
+
p = p.add(d);
|
|
755
|
+
else if (safe)
|
|
756
|
+
f = f.add(d);
|
|
757
|
+
}
|
|
758
|
+
return p;
|
|
759
|
+
}
|
|
760
|
+
multiplyUnsafe(scalar) {
|
|
761
|
+
return this.multiply(scalar, false);
|
|
762
|
+
}
|
|
763
|
+
/** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
|
|
764
|
+
toAffine() {
|
|
765
|
+
const { X, Y, Z } = this;
|
|
766
|
+
if (this.equals(I))
|
|
767
|
+
return { x: 0n, y: 1n };
|
|
768
|
+
const iz = invert(Z, P);
|
|
769
|
+
if (M(Z * iz) !== 1n)
|
|
770
|
+
err("invalid inverse");
|
|
771
|
+
const x = M(X * iz);
|
|
772
|
+
const y = M(Y * iz);
|
|
773
|
+
return { x, y };
|
|
774
|
+
}
|
|
775
|
+
toBytes() {
|
|
776
|
+
const { x, y } = this.assertValidity().toAffine();
|
|
777
|
+
const b = numTo32bLE(y);
|
|
778
|
+
b[31] |= x & 1n ? 128 : 0;
|
|
779
|
+
return b;
|
|
780
|
+
}
|
|
781
|
+
toHex() {
|
|
782
|
+
return bytesToHex(this.toBytes());
|
|
783
|
+
}
|
|
784
|
+
clearCofactor() {
|
|
785
|
+
return this.multiply(big(h), false);
|
|
786
|
+
}
|
|
787
|
+
isSmallOrder() {
|
|
788
|
+
return this.clearCofactor().is0();
|
|
789
|
+
}
|
|
790
|
+
isTorsionFree() {
|
|
791
|
+
let p = this.multiply(N / 2n, false).double();
|
|
792
|
+
if (N % 2n)
|
|
793
|
+
p = p.add(this);
|
|
794
|
+
return p.is0();
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
__publicField(_Point, "BASE");
|
|
798
|
+
__publicField(_Point, "ZERO");
|
|
799
|
+
var Point = _Point;
|
|
800
|
+
var G = new Point(Gx, Gy, 1n, M(Gx * Gy));
|
|
801
|
+
var I = new Point(0n, 1n, 1n, 0n);
|
|
802
|
+
Point.BASE = G;
|
|
803
|
+
Point.ZERO = I;
|
|
804
|
+
var numTo32bLE = (num) => hexToBytes(padh(assertRange(num, 0n, B256), L2)).reverse();
|
|
805
|
+
var bytesToNumLE = (b) => big("0x" + bytesToHex(u8fr(abytes(b)).reverse()));
|
|
806
|
+
var pow2 = (x, power) => {
|
|
807
|
+
let r = x;
|
|
808
|
+
while (power-- > 0n) {
|
|
809
|
+
r *= r;
|
|
810
|
+
r %= P;
|
|
811
|
+
}
|
|
812
|
+
return r;
|
|
813
|
+
};
|
|
814
|
+
var pow_2_252_3 = (x) => {
|
|
815
|
+
const x2 = x * x % P;
|
|
816
|
+
const b2 = x2 * x % P;
|
|
817
|
+
const b4 = pow2(b2, 2n) * b2 % P;
|
|
818
|
+
const b5 = pow2(b4, 1n) * x % P;
|
|
819
|
+
const b10 = pow2(b5, 5n) * b5 % P;
|
|
820
|
+
const b20 = pow2(b10, 10n) * b10 % P;
|
|
821
|
+
const b40 = pow2(b20, 20n) * b20 % P;
|
|
822
|
+
const b80 = pow2(b40, 40n) * b40 % P;
|
|
823
|
+
const b160 = pow2(b80, 80n) * b80 % P;
|
|
824
|
+
const b240 = pow2(b160, 80n) * b80 % P;
|
|
825
|
+
const b250 = pow2(b240, 10n) * b10 % P;
|
|
826
|
+
const pow_p_5_8 = pow2(b250, 2n) * x % P;
|
|
827
|
+
return { pow_p_5_8, b2 };
|
|
828
|
+
};
|
|
829
|
+
var RM1 = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n;
|
|
830
|
+
var uvRatio = (u, v) => {
|
|
831
|
+
const v3 = M(v * v * v);
|
|
832
|
+
const v7 = M(v3 * v3 * v);
|
|
833
|
+
const pow = pow_2_252_3(u * v7).pow_p_5_8;
|
|
834
|
+
let x = M(u * v3 * pow);
|
|
835
|
+
const vx2 = M(v * x * x);
|
|
836
|
+
const root1 = x;
|
|
837
|
+
const root2 = M(x * RM1);
|
|
838
|
+
const useRoot1 = vx2 === u;
|
|
839
|
+
const useRoot2 = vx2 === M(-u);
|
|
840
|
+
const noRoot = vx2 === M(-u * RM1);
|
|
841
|
+
if (useRoot1)
|
|
842
|
+
x = root1;
|
|
843
|
+
if (useRoot2 || noRoot)
|
|
844
|
+
x = root2;
|
|
845
|
+
if ((M(x) & 1n) === 1n)
|
|
846
|
+
x = M(-x);
|
|
847
|
+
return { isValid: useRoot1 || useRoot2, value: x };
|
|
848
|
+
};
|
|
849
|
+
var modL_LE = (hash2) => modN(bytesToNumLE(hash2));
|
|
850
|
+
var sha512a = (...m) => hashes.sha512Async(concatBytes(...m));
|
|
851
|
+
var sha512s = (...m) => callHash("sha512")(concatBytes(...m));
|
|
852
|
+
var hash2extK = (hashed) => {
|
|
853
|
+
const head = hashed.slice(0, L);
|
|
854
|
+
head[0] &= 248;
|
|
855
|
+
head[31] &= 127;
|
|
856
|
+
head[31] |= 64;
|
|
857
|
+
const prefix = hashed.slice(L, L2);
|
|
858
|
+
const scalar = modL_LE(head);
|
|
859
|
+
const point = G.multiply(scalar);
|
|
860
|
+
const pointBytes = point.toBytes();
|
|
861
|
+
return { head, prefix, scalar, point, pointBytes };
|
|
862
|
+
};
|
|
863
|
+
var getExtendedPublicKeyAsync = (secretKey) => sha512a(abytes(secretKey, L)).then(hash2extK);
|
|
864
|
+
var getExtendedPublicKey = (secretKey) => hash2extK(sha512s(abytes(secretKey, L)));
|
|
865
|
+
var getPublicKeyAsync = (secretKey) => getExtendedPublicKeyAsync(secretKey).then((p) => p.pointBytes);
|
|
866
|
+
var getPublicKey = (priv) => getExtendedPublicKey(priv).pointBytes;
|
|
867
|
+
var hashFinishA = (res) => sha512a(res.hashable).then(res.finish);
|
|
868
|
+
var hashFinishS = (res) => res.finish(sha512s(res.hashable));
|
|
869
|
+
var _sign = (e, rBytes, msg) => {
|
|
870
|
+
const { pointBytes: P2, scalar: s } = e;
|
|
871
|
+
const r = modL_LE(rBytes);
|
|
872
|
+
const R = G.multiply(r).toBytes();
|
|
873
|
+
const hashable = concatBytes(R, P2, msg);
|
|
874
|
+
const finish = (hashed) => {
|
|
875
|
+
const S = modN(r + modL_LE(hashed) * s);
|
|
876
|
+
return abytes(concatBytes(R, numTo32bLE(S)), L2);
|
|
877
|
+
};
|
|
878
|
+
return { hashable, finish };
|
|
879
|
+
};
|
|
880
|
+
var signAsync = async (message, secretKey) => {
|
|
881
|
+
const m = abytes(message);
|
|
882
|
+
const e = await getExtendedPublicKeyAsync(secretKey);
|
|
883
|
+
const rBytes = await sha512a(e.prefix, m);
|
|
884
|
+
return hashFinishA(_sign(e, rBytes, m));
|
|
885
|
+
};
|
|
886
|
+
var sign = (message, secretKey) => {
|
|
887
|
+
const m = abytes(message);
|
|
888
|
+
const e = getExtendedPublicKey(secretKey);
|
|
889
|
+
const rBytes = sha512s(e.prefix, m);
|
|
890
|
+
return hashFinishS(_sign(e, rBytes, m));
|
|
891
|
+
};
|
|
892
|
+
var defaultVerifyOpts = { zip215: true };
|
|
893
|
+
var _verify = (sig, msg, pub, opts = defaultVerifyOpts) => {
|
|
894
|
+
sig = abytes(sig, L2);
|
|
895
|
+
msg = abytes(msg);
|
|
896
|
+
pub = abytes(pub, L);
|
|
897
|
+
const { zip215 } = opts;
|
|
898
|
+
let A;
|
|
899
|
+
let R;
|
|
900
|
+
let s;
|
|
901
|
+
let SB;
|
|
902
|
+
let hashable = Uint8Array.of();
|
|
903
|
+
try {
|
|
904
|
+
A = Point.fromBytes(pub, zip215);
|
|
905
|
+
R = Point.fromBytes(sig.slice(0, L), zip215);
|
|
906
|
+
s = bytesToNumLE(sig.slice(L, L2));
|
|
907
|
+
SB = G.multiply(s, false);
|
|
908
|
+
hashable = concatBytes(R.toBytes(), A.toBytes(), msg);
|
|
909
|
+
} catch (error) {
|
|
910
|
+
}
|
|
911
|
+
const finish = (hashed) => {
|
|
912
|
+
if (SB == null)
|
|
913
|
+
return false;
|
|
914
|
+
if (!zip215 && A.isSmallOrder())
|
|
915
|
+
return false;
|
|
916
|
+
const k = modL_LE(hashed);
|
|
917
|
+
const RkA = R.add(A.multiply(k, false));
|
|
918
|
+
return RkA.add(SB.negate()).clearCofactor().is0();
|
|
919
|
+
};
|
|
920
|
+
return { hashable, finish };
|
|
921
|
+
};
|
|
922
|
+
var verifyAsync = async (signature, message, publicKey, opts = defaultVerifyOpts) => hashFinishA(_verify(signature, message, publicKey, opts));
|
|
923
|
+
var verify = (signature, message, publicKey, opts = defaultVerifyOpts) => hashFinishS(_verify(signature, message, publicKey, opts));
|
|
924
|
+
var etc = {
|
|
925
|
+
bytesToHex,
|
|
926
|
+
hexToBytes,
|
|
927
|
+
concatBytes,
|
|
928
|
+
mod: M,
|
|
929
|
+
invert,
|
|
930
|
+
randomBytes
|
|
931
|
+
};
|
|
932
|
+
var hashes = {
|
|
933
|
+
sha512Async: async (message) => {
|
|
934
|
+
const s = subtle();
|
|
935
|
+
const m = concatBytes(message);
|
|
936
|
+
return u8n(await s.digest("SHA-512", m.buffer));
|
|
937
|
+
},
|
|
938
|
+
sha512: void 0
|
|
939
|
+
};
|
|
940
|
+
var randomSecretKey = (seed = randomBytes(L)) => seed;
|
|
941
|
+
var keygen = (seed) => {
|
|
942
|
+
const secretKey = randomSecretKey(seed);
|
|
943
|
+
const publicKey = getPublicKey(secretKey);
|
|
944
|
+
return { secretKey, publicKey };
|
|
945
|
+
};
|
|
946
|
+
var keygenAsync = async (seed) => {
|
|
947
|
+
const secretKey = randomSecretKey(seed);
|
|
948
|
+
const publicKey = await getPublicKeyAsync(secretKey);
|
|
949
|
+
return { secretKey, publicKey };
|
|
950
|
+
};
|
|
951
|
+
var utils = {
|
|
952
|
+
getExtendedPublicKeyAsync,
|
|
953
|
+
getExtendedPublicKey,
|
|
954
|
+
randomSecretKey
|
|
955
|
+
};
|
|
956
|
+
var W = 8;
|
|
957
|
+
var scalarBits = 256;
|
|
958
|
+
var pwindows = Math.ceil(scalarBits / W) + 1;
|
|
959
|
+
var pwindowSize = 2 ** (W - 1);
|
|
960
|
+
var precompute = () => {
|
|
961
|
+
const points = [];
|
|
962
|
+
let p = G;
|
|
963
|
+
let b = p;
|
|
964
|
+
for (let w = 0; w < pwindows; w++) {
|
|
965
|
+
b = p;
|
|
966
|
+
points.push(b);
|
|
967
|
+
for (let i = 1; i < pwindowSize; i++) {
|
|
968
|
+
b = b.add(p);
|
|
969
|
+
points.push(b);
|
|
970
|
+
}
|
|
971
|
+
p = b.double();
|
|
972
|
+
}
|
|
973
|
+
return points;
|
|
974
|
+
};
|
|
975
|
+
var Gpows = void 0;
|
|
976
|
+
var ctneg = (cnd, p) => {
|
|
977
|
+
const n = p.negate();
|
|
978
|
+
return cnd ? n : p;
|
|
979
|
+
};
|
|
980
|
+
var wNAF = (n) => {
|
|
981
|
+
const comp = Gpows || (Gpows = precompute());
|
|
982
|
+
let p = I;
|
|
983
|
+
let f = G;
|
|
984
|
+
const pow_2_w = 2 ** W;
|
|
985
|
+
const maxNum = pow_2_w;
|
|
986
|
+
const mask = big(pow_2_w - 1);
|
|
987
|
+
const shiftBy = big(W);
|
|
988
|
+
for (let w = 0; w < pwindows; w++) {
|
|
989
|
+
let wbits = Number(n & mask);
|
|
990
|
+
n >>= shiftBy;
|
|
991
|
+
if (wbits > pwindowSize) {
|
|
992
|
+
wbits -= maxNum;
|
|
993
|
+
n += 1n;
|
|
994
|
+
}
|
|
995
|
+
const off = w * pwindowSize;
|
|
996
|
+
const offF = off;
|
|
997
|
+
const offP = off + Math.abs(wbits) - 1;
|
|
998
|
+
const isEven = w % 2 !== 0;
|
|
999
|
+
const isNeg = wbits < 0;
|
|
1000
|
+
if (wbits === 0) {
|
|
1001
|
+
f = f.add(ctneg(isEven, comp[offF]));
|
|
1002
|
+
} else {
|
|
1003
|
+
p = p.add(ctneg(isNeg, comp[offP]));
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
if (n !== 0n)
|
|
1007
|
+
err("invalid wnaf");
|
|
1008
|
+
return { p, f };
|
|
1009
|
+
};
|
|
474
1010
|
|
|
475
1011
|
// ../../node_modules/@noble/hashes/esm/utils.js
|
|
476
|
-
function
|
|
1012
|
+
function isBytes2(a) {
|
|
477
1013
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
478
1014
|
}
|
|
479
|
-
function
|
|
480
|
-
if (!
|
|
1015
|
+
function abytes2(b, ...lengths) {
|
|
1016
|
+
if (!isBytes2(b))
|
|
481
1017
|
throw new Error("Uint8Array expected");
|
|
482
1018
|
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
483
1019
|
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
@@ -489,7 +1025,7 @@ function aexists(instance, checkFinished = true) {
|
|
|
489
1025
|
throw new Error("Hash#digest() has already been called");
|
|
490
1026
|
}
|
|
491
1027
|
function aoutput(out, instance) {
|
|
492
|
-
|
|
1028
|
+
abytes2(out);
|
|
493
1029
|
const min = instance.outputLen;
|
|
494
1030
|
if (out.length < min) {
|
|
495
1031
|
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
@@ -511,7 +1047,7 @@ function utf8ToBytes(str) {
|
|
|
511
1047
|
function toBytes(data) {
|
|
512
1048
|
if (typeof data === "string")
|
|
513
1049
|
data = utf8ToBytes(data);
|
|
514
|
-
|
|
1050
|
+
abytes2(data);
|
|
515
1051
|
return data;
|
|
516
1052
|
}
|
|
517
1053
|
var Hash = class {
|
|
@@ -533,9 +1069,9 @@ function setBigUint64(view, byteOffset, value, isLE) {
|
|
|
533
1069
|
const _u32_max = BigInt(4294967295);
|
|
534
1070
|
const wh = Number(value >> _32n2 & _u32_max);
|
|
535
1071
|
const wl = Number(value & _u32_max);
|
|
536
|
-
const
|
|
1072
|
+
const h2 = isLE ? 4 : 0;
|
|
537
1073
|
const l = isLE ? 0 : 4;
|
|
538
|
-
view.setUint32(byteOffset +
|
|
1074
|
+
view.setUint32(byteOffset + h2, wh, isLE);
|
|
539
1075
|
view.setUint32(byteOffset + l, wl, isLE);
|
|
540
1076
|
}
|
|
541
1077
|
var HashMD = class extends Hash {
|
|
@@ -555,7 +1091,7 @@ var HashMD = class extends Hash {
|
|
|
555
1091
|
update(data) {
|
|
556
1092
|
aexists(this);
|
|
557
1093
|
data = toBytes(data);
|
|
558
|
-
|
|
1094
|
+
abytes2(data);
|
|
559
1095
|
const { view, buffer, blockLen } = this;
|
|
560
1096
|
const len = data.length;
|
|
561
1097
|
for (let pos = 0; pos < len; ) {
|
|
@@ -660,17 +1196,17 @@ function split(lst, le = false) {
|
|
|
660
1196
|
let Ah = new Uint32Array(len);
|
|
661
1197
|
let Al = new Uint32Array(len);
|
|
662
1198
|
for (let i = 0; i < len; i++) {
|
|
663
|
-
const { h, l } = fromBig(lst[i], le);
|
|
664
|
-
[Ah[i], Al[i]] = [
|
|
1199
|
+
const { h: h2, l } = fromBig(lst[i], le);
|
|
1200
|
+
[Ah[i], Al[i]] = [h2, l];
|
|
665
1201
|
}
|
|
666
1202
|
return [Ah, Al];
|
|
667
1203
|
}
|
|
668
|
-
var shrSH = (
|
|
669
|
-
var shrSL = (
|
|
670
|
-
var rotrSH = (
|
|
671
|
-
var rotrSL = (
|
|
672
|
-
var rotrBH = (
|
|
673
|
-
var rotrBL = (
|
|
1204
|
+
var shrSH = (h2, _l, s) => h2 >>> s;
|
|
1205
|
+
var shrSL = (h2, l, s) => h2 << 32 - s | l >>> s;
|
|
1206
|
+
var rotrSH = (h2, l, s) => h2 >>> s | l << 32 - s;
|
|
1207
|
+
var rotrSL = (h2, l, s) => h2 << 32 - s | l >>> s;
|
|
1208
|
+
var rotrBH = (h2, l, s) => h2 << 64 - s | l >>> s - 32;
|
|
1209
|
+
var rotrBL = (h2, l, s) => h2 >>> s - 32 | l << 64 - s;
|
|
674
1210
|
function add(Ah, Al, Bh, Bl) {
|
|
675
1211
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
676
1212
|
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
@@ -886,10 +1422,10 @@ var sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
|
|
|
886
1422
|
var sha5122 = sha512;
|
|
887
1423
|
|
|
888
1424
|
// src/sdk/ed25519-setup.ts
|
|
889
|
-
|
|
1425
|
+
hashes.sha512 = sha5122;
|
|
890
1426
|
|
|
891
1427
|
// ../../node_modules/@scure/base/lib/esm/index.js
|
|
892
|
-
function
|
|
1428
|
+
function isBytes3(a) {
|
|
893
1429
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
894
1430
|
}
|
|
895
1431
|
function isArrayOf(isString, arr) {
|
|
@@ -1027,7 +1563,7 @@ function radix(num) {
|
|
|
1027
1563
|
const _256 = 2 ** 8;
|
|
1028
1564
|
return {
|
|
1029
1565
|
encode: (bytes) => {
|
|
1030
|
-
if (!
|
|
1566
|
+
if (!isBytes3(bytes))
|
|
1031
1567
|
throw new Error("radix.encode input should be Uint8Array");
|
|
1032
1568
|
return convertRadix(Array.from(bytes), _256, num);
|
|
1033
1569
|
},
|
|
@@ -2236,9 +2772,6 @@ var WarpFastsetWallet = class {
|
|
|
2236
2772
|
this.config = config;
|
|
2237
2773
|
this.chain = chain2;
|
|
2238
2774
|
this.client = getConfiguredFastsetClient(this.config, this.chain);
|
|
2239
|
-
const privateKey = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
2240
|
-
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2241
|
-
this.privateKey = privateKey;
|
|
2242
2775
|
}
|
|
2243
2776
|
async signTransaction(tx) {
|
|
2244
2777
|
const msg = Transaction.serialize(tx);
|
|
@@ -2247,14 +2780,18 @@ var WarpFastsetWallet = class {
|
|
|
2247
2780
|
const dataToSign = new Uint8Array(prefix.length + msgBytes.length);
|
|
2248
2781
|
dataToSign.set(prefix, 0);
|
|
2249
2782
|
dataToSign.set(msgBytes, prefix.length);
|
|
2250
|
-
const
|
|
2251
|
-
|
|
2783
|
+
const privateKey = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
2784
|
+
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2785
|
+
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2786
|
+
const signature = ed25519_exports.sign(dataToSign, privateKeyBytes);
|
|
2252
2787
|
return { ...tx, signature };
|
|
2253
2788
|
}
|
|
2254
2789
|
async signMessage(message) {
|
|
2255
2790
|
const messageBytes = stringToUint8Array(message);
|
|
2256
|
-
const
|
|
2257
|
-
|
|
2791
|
+
const privateKey = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
2792
|
+
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2793
|
+
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2794
|
+
const signature = ed25519_exports.sign(messageBytes, privateKeyBytes);
|
|
2258
2795
|
return uint8ArrayToHex(signature);
|
|
2259
2796
|
}
|
|
2260
2797
|
async sendTransaction(tx) {
|
|
@@ -2269,13 +2806,13 @@ var WarpFastsetWallet = class {
|
|
|
2269
2806
|
create(mnemonic) {
|
|
2270
2807
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
2271
2808
|
const privateKey = seed.slice(0, 32);
|
|
2272
|
-
const publicKey =
|
|
2809
|
+
const publicKey = ed25519_exports.getPublicKey(privateKey);
|
|
2273
2810
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2274
2811
|
return { address, privateKey: uint8ArrayToHex(privateKey), mnemonic };
|
|
2275
2812
|
}
|
|
2276
2813
|
generate() {
|
|
2277
|
-
const privateKey =
|
|
2278
|
-
const publicKey =
|
|
2814
|
+
const privateKey = ed25519_exports.utils.randomPrivateKey();
|
|
2815
|
+
const publicKey = ed25519_exports.getPublicKey(privateKey);
|
|
2279
2816
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2280
2817
|
return { address, privateKey: uint8ArrayToHex(privateKey), mnemonic: null };
|
|
2281
2818
|
}
|
|
@@ -2356,6 +2893,9 @@ var getFastsetAdapter = createFastsetAdapter(import_warps6.WarpChainName.Fastset
|
|
|
2356
2893
|
});
|
|
2357
2894
|
/*! Bundled license information:
|
|
2358
2895
|
|
|
2896
|
+
@noble/ed25519/index.js:
|
|
2897
|
+
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
2898
|
+
|
|
2359
2899
|
@noble/hashes/esm/utils.js:
|
|
2360
2900
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2361
2901
|
|