@vleap/warps-adapter-fastset 0.1.0-beta.46 → 0.1.0-beta.47
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 +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +32 -568
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -570
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -32,10 +32,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32
32
|
// src/index.ts
|
|
33
33
|
var index_exports = {};
|
|
34
34
|
__export(index_exports, {
|
|
35
|
+
FastsetAdapter: () => FastsetAdapter,
|
|
35
36
|
NativeTokenSet: () => NativeTokenSet,
|
|
36
37
|
WarpFastsetExecutor: () => WarpFastsetExecutor,
|
|
37
|
-
WarpFastsetWallet: () => WarpFastsetWallet
|
|
38
|
-
getFastsetAdapter: () => getFastsetAdapter
|
|
38
|
+
WarpFastsetWallet: () => WarpFastsetWallet
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(index_exports);
|
|
41
41
|
|
|
@@ -1733,8 +1733,8 @@ var WarpFastsetExplorer = class {
|
|
|
1733
1733
|
getAccountUrl(address) {
|
|
1734
1734
|
return `${this.explorerUrl}/account/${address}`;
|
|
1735
1735
|
}
|
|
1736
|
-
getTransactionUrl(
|
|
1737
|
-
return `${this.explorerUrl}/txs/${HEX_PREFIX}${
|
|
1736
|
+
getTransactionUrl(hash) {
|
|
1737
|
+
return `${this.explorerUrl}/txs/${HEX_PREFIX}${hash}`;
|
|
1738
1738
|
}
|
|
1739
1739
|
getAssetUrl(identifier) {
|
|
1740
1740
|
return `${this.explorerUrl}/asset/${HEX_PREFIX}${identifier}`;
|
|
@@ -1960,549 +1960,15 @@ var WarpFastsetOutput = class {
|
|
|
1960
1960
|
var bip39 = __toESM(require("@scure/bip39"), 1);
|
|
1961
1961
|
var import_warps5 = require("@vleap/warps");
|
|
1962
1962
|
|
|
1963
|
-
//
|
|
1964
|
-
var
|
|
1965
|
-
__export(ed25519_exports, {
|
|
1966
|
-
Point: () => Point,
|
|
1967
|
-
etc: () => etc,
|
|
1968
|
-
getPublicKey: () => getPublicKey,
|
|
1969
|
-
getPublicKeyAsync: () => getPublicKeyAsync,
|
|
1970
|
-
hash: () => hash,
|
|
1971
|
-
hashes: () => hashes,
|
|
1972
|
-
keygen: () => keygen,
|
|
1973
|
-
keygenAsync: () => keygenAsync,
|
|
1974
|
-
sign: () => sign,
|
|
1975
|
-
signAsync: () => signAsync,
|
|
1976
|
-
utils: () => utils,
|
|
1977
|
-
verify: () => verify,
|
|
1978
|
-
verifyAsync: () => verifyAsync
|
|
1979
|
-
});
|
|
1980
|
-
var ed25519_CURVE = {
|
|
1981
|
-
p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
|
|
1982
|
-
n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
|
|
1983
|
-
h: 8n,
|
|
1984
|
-
a: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,
|
|
1985
|
-
d: 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,
|
|
1986
|
-
Gx: 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,
|
|
1987
|
-
Gy: 0x6666666666666666666666666666666666666666666666666666666666666658n
|
|
1988
|
-
};
|
|
1989
|
-
var { p: P, n: N, Gx, Gy, a: _a, d: _d, h } = ed25519_CURVE;
|
|
1990
|
-
var L = 32;
|
|
1991
|
-
var L2 = 64;
|
|
1992
|
-
var captureTrace = (...args) => {
|
|
1993
|
-
if ("captureStackTrace" in Error && typeof Error.captureStackTrace === "function") {
|
|
1994
|
-
Error.captureStackTrace(...args);
|
|
1995
|
-
}
|
|
1996
|
-
};
|
|
1997
|
-
var err = (message = "") => {
|
|
1998
|
-
const e = new Error(message);
|
|
1999
|
-
captureTrace(e, err);
|
|
2000
|
-
throw e;
|
|
2001
|
-
};
|
|
2002
|
-
var isBig = (n) => typeof n === "bigint";
|
|
2003
|
-
var isStr = (s) => typeof s === "string";
|
|
2004
|
-
var isBytes2 = (a) => a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
2005
|
-
var abytes = (value, length, title = "") => {
|
|
2006
|
-
const bytes = isBytes2(value);
|
|
2007
|
-
const len = value?.length;
|
|
2008
|
-
const needsLen = length !== void 0;
|
|
2009
|
-
if (!bytes || needsLen && len !== length) {
|
|
2010
|
-
const prefix = title && `"${title}" `;
|
|
2011
|
-
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
2012
|
-
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
2013
|
-
err(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
2014
|
-
}
|
|
2015
|
-
return value;
|
|
2016
|
-
};
|
|
2017
|
-
var u8n = (len) => new Uint8Array(len);
|
|
2018
|
-
var u8fr = (buf) => Uint8Array.from(buf);
|
|
2019
|
-
var padh = (n, pad) => n.toString(16).padStart(pad, "0");
|
|
2020
|
-
var bytesToHex = (b) => Array.from(abytes(b)).map((e) => padh(e, 2)).join("");
|
|
2021
|
-
var C = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
2022
|
-
var _ch = (ch) => {
|
|
2023
|
-
if (ch >= C._0 && ch <= C._9)
|
|
2024
|
-
return ch - C._0;
|
|
2025
|
-
if (ch >= C.A && ch <= C.F)
|
|
2026
|
-
return ch - (C.A - 10);
|
|
2027
|
-
if (ch >= C.a && ch <= C.f)
|
|
2028
|
-
return ch - (C.a - 10);
|
|
2029
|
-
return;
|
|
2030
|
-
};
|
|
2031
|
-
var hexToBytes = (hex) => {
|
|
2032
|
-
const e = "hex invalid";
|
|
2033
|
-
if (!isStr(hex))
|
|
2034
|
-
return err(e);
|
|
2035
|
-
const hl = hex.length;
|
|
2036
|
-
const al = hl / 2;
|
|
2037
|
-
if (hl % 2)
|
|
2038
|
-
return err(e);
|
|
2039
|
-
const array = u8n(al);
|
|
2040
|
-
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
2041
|
-
const n1 = _ch(hex.charCodeAt(hi));
|
|
2042
|
-
const n2 = _ch(hex.charCodeAt(hi + 1));
|
|
2043
|
-
if (n1 === void 0 || n2 === void 0)
|
|
2044
|
-
return err(e);
|
|
2045
|
-
array[ai] = n1 * 16 + n2;
|
|
2046
|
-
}
|
|
2047
|
-
return array;
|
|
2048
|
-
};
|
|
2049
|
-
var cr = () => globalThis?.crypto;
|
|
2050
|
-
var subtle = () => cr()?.subtle ?? err("crypto.subtle must be defined, consider polyfill");
|
|
2051
|
-
var concatBytes = (...arrs) => {
|
|
2052
|
-
const r = u8n(arrs.reduce((sum, a) => sum + abytes(a).length, 0));
|
|
2053
|
-
let pad = 0;
|
|
2054
|
-
arrs.forEach((a) => {
|
|
2055
|
-
r.set(a, pad);
|
|
2056
|
-
pad += a.length;
|
|
2057
|
-
});
|
|
2058
|
-
return r;
|
|
2059
|
-
};
|
|
2060
|
-
var randomBytes = (len = L) => {
|
|
2061
|
-
const c = cr();
|
|
2062
|
-
return c.getRandomValues(u8n(len));
|
|
2063
|
-
};
|
|
2064
|
-
var big = BigInt;
|
|
2065
|
-
var assertRange = (n, min, max, msg = "bad number: out of range") => isBig(n) && min <= n && n < max ? n : err(msg);
|
|
2066
|
-
var M = (a, b = P) => {
|
|
2067
|
-
const r = a % b;
|
|
2068
|
-
return r >= 0n ? r : b + r;
|
|
2069
|
-
};
|
|
2070
|
-
var modN = (a) => M(a, N);
|
|
2071
|
-
var invert = (num, md) => {
|
|
2072
|
-
if (num === 0n || md <= 0n)
|
|
2073
|
-
err("no inverse n=" + num + " mod=" + md);
|
|
2074
|
-
let a = M(num, md), b = md, x = 0n, y = 1n, u = 1n, v = 0n;
|
|
2075
|
-
while (a !== 0n) {
|
|
2076
|
-
const q = b / a, r = b % a;
|
|
2077
|
-
const m = x - u * q, n = y - v * q;
|
|
2078
|
-
b = a, a = r, x = u, y = v, u = m, v = n;
|
|
2079
|
-
}
|
|
2080
|
-
return b === 1n ? M(x, md) : err("no inverse");
|
|
2081
|
-
};
|
|
2082
|
-
var callHash = (name) => {
|
|
2083
|
-
const fn = hashes[name];
|
|
2084
|
-
if (typeof fn !== "function")
|
|
2085
|
-
err("hashes." + name + " not set");
|
|
2086
|
-
return fn;
|
|
2087
|
-
};
|
|
2088
|
-
var hash = (msg) => callHash("sha512")(msg);
|
|
2089
|
-
var apoint = (p) => p instanceof Point ? p : err("Point expected");
|
|
2090
|
-
var B256 = 2n ** 256n;
|
|
2091
|
-
var _Point = class _Point {
|
|
2092
|
-
constructor(X, Y, Z, T) {
|
|
2093
|
-
__publicField(this, "X");
|
|
2094
|
-
__publicField(this, "Y");
|
|
2095
|
-
__publicField(this, "Z");
|
|
2096
|
-
__publicField(this, "T");
|
|
2097
|
-
const max = B256;
|
|
2098
|
-
this.X = assertRange(X, 0n, max);
|
|
2099
|
-
this.Y = assertRange(Y, 0n, max);
|
|
2100
|
-
this.Z = assertRange(Z, 1n, max);
|
|
2101
|
-
this.T = assertRange(T, 0n, max);
|
|
2102
|
-
Object.freeze(this);
|
|
2103
|
-
}
|
|
2104
|
-
static CURVE() {
|
|
2105
|
-
return ed25519_CURVE;
|
|
2106
|
-
}
|
|
2107
|
-
static fromAffine(p) {
|
|
2108
|
-
return new _Point(p.x, p.y, 1n, M(p.x * p.y));
|
|
2109
|
-
}
|
|
2110
|
-
/** RFC8032 5.1.3: Uint8Array to Point. */
|
|
2111
|
-
static fromBytes(hex, zip215 = false) {
|
|
2112
|
-
const d = _d;
|
|
2113
|
-
const normed = u8fr(abytes(hex, L));
|
|
2114
|
-
const lastByte = hex[31];
|
|
2115
|
-
normed[31] = lastByte & ~128;
|
|
2116
|
-
const y = bytesToNumLE(normed);
|
|
2117
|
-
const max = zip215 ? B256 : P;
|
|
2118
|
-
assertRange(y, 0n, max);
|
|
2119
|
-
const y2 = M(y * y);
|
|
2120
|
-
const u = M(y2 - 1n);
|
|
2121
|
-
const v = M(d * y2 + 1n);
|
|
2122
|
-
let { isValid, value: x } = uvRatio(u, v);
|
|
2123
|
-
if (!isValid)
|
|
2124
|
-
err("bad point: y not sqrt");
|
|
2125
|
-
const isXOdd = (x & 1n) === 1n;
|
|
2126
|
-
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
2127
|
-
if (!zip215 && x === 0n && isLastByteOdd)
|
|
2128
|
-
err("bad point: x==0, isLastByteOdd");
|
|
2129
|
-
if (isLastByteOdd !== isXOdd)
|
|
2130
|
-
x = M(-x);
|
|
2131
|
-
return new _Point(x, y, 1n, M(x * y));
|
|
2132
|
-
}
|
|
2133
|
-
static fromHex(hex, zip215) {
|
|
2134
|
-
return _Point.fromBytes(hexToBytes(hex), zip215);
|
|
2135
|
-
}
|
|
2136
|
-
get x() {
|
|
2137
|
-
return this.toAffine().x;
|
|
2138
|
-
}
|
|
2139
|
-
get y() {
|
|
2140
|
-
return this.toAffine().y;
|
|
2141
|
-
}
|
|
2142
|
-
/** Checks if the point is valid and on-curve. */
|
|
2143
|
-
assertValidity() {
|
|
2144
|
-
const a = _a;
|
|
2145
|
-
const d = _d;
|
|
2146
|
-
const p = this;
|
|
2147
|
-
if (p.is0())
|
|
2148
|
-
return err("bad point: ZERO");
|
|
2149
|
-
const { X, Y, Z, T } = p;
|
|
2150
|
-
const X2 = M(X * X);
|
|
2151
|
-
const Y2 = M(Y * Y);
|
|
2152
|
-
const Z2 = M(Z * Z);
|
|
2153
|
-
const Z4 = M(Z2 * Z2);
|
|
2154
|
-
const aX2 = M(X2 * a);
|
|
2155
|
-
const left = M(Z2 * M(aX2 + Y2));
|
|
2156
|
-
const right = M(Z4 + M(d * M(X2 * Y2)));
|
|
2157
|
-
if (left !== right)
|
|
2158
|
-
return err("bad point: equation left != right (1)");
|
|
2159
|
-
const XY = M(X * Y);
|
|
2160
|
-
const ZT = M(Z * T);
|
|
2161
|
-
if (XY !== ZT)
|
|
2162
|
-
return err("bad point: equation left != right (2)");
|
|
2163
|
-
return this;
|
|
2164
|
-
}
|
|
2165
|
-
/** Equality check: compare points P&Q. */
|
|
2166
|
-
equals(other) {
|
|
2167
|
-
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
2168
|
-
const { X: X2, Y: Y2, Z: Z2 } = apoint(other);
|
|
2169
|
-
const X1Z2 = M(X1 * Z2);
|
|
2170
|
-
const X2Z1 = M(X2 * Z1);
|
|
2171
|
-
const Y1Z2 = M(Y1 * Z2);
|
|
2172
|
-
const Y2Z1 = M(Y2 * Z1);
|
|
2173
|
-
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
2174
|
-
}
|
|
2175
|
-
is0() {
|
|
2176
|
-
return this.equals(I);
|
|
2177
|
-
}
|
|
2178
|
-
/** Flip point over y coordinate. */
|
|
2179
|
-
negate() {
|
|
2180
|
-
return new _Point(M(-this.X), this.Y, this.Z, M(-this.T));
|
|
2181
|
-
}
|
|
2182
|
-
/** Point doubling. Complete formula. Cost: `4M + 4S + 1*a + 6add + 1*2`. */
|
|
2183
|
-
double() {
|
|
2184
|
-
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
2185
|
-
const a = _a;
|
|
2186
|
-
const A = M(X1 * X1);
|
|
2187
|
-
const B = M(Y1 * Y1);
|
|
2188
|
-
const C2 = M(2n * M(Z1 * Z1));
|
|
2189
|
-
const D = M(a * A);
|
|
2190
|
-
const x1y1 = X1 + Y1;
|
|
2191
|
-
const E = M(M(x1y1 * x1y1) - A - B);
|
|
2192
|
-
const G2 = D + B;
|
|
2193
|
-
const F = G2 - C2;
|
|
2194
|
-
const H = D - B;
|
|
2195
|
-
const X3 = M(E * F);
|
|
2196
|
-
const Y3 = M(G2 * H);
|
|
2197
|
-
const T3 = M(E * H);
|
|
2198
|
-
const Z3 = M(F * G2);
|
|
2199
|
-
return new _Point(X3, Y3, Z3, T3);
|
|
2200
|
-
}
|
|
2201
|
-
/** Point addition. Complete formula. Cost: `8M + 1*k + 8add + 1*2`. */
|
|
2202
|
-
add(other) {
|
|
2203
|
-
const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
|
|
2204
|
-
const { X: X2, Y: Y2, Z: Z2, T: T2 } = apoint(other);
|
|
2205
|
-
const a = _a;
|
|
2206
|
-
const d = _d;
|
|
2207
|
-
const A = M(X1 * X2);
|
|
2208
|
-
const B = M(Y1 * Y2);
|
|
2209
|
-
const C2 = M(T1 * d * T2);
|
|
2210
|
-
const D = M(Z1 * Z2);
|
|
2211
|
-
const E = M((X1 + Y1) * (X2 + Y2) - A - B);
|
|
2212
|
-
const F = M(D - C2);
|
|
2213
|
-
const G2 = M(D + C2);
|
|
2214
|
-
const H = M(B - a * A);
|
|
2215
|
-
const X3 = M(E * F);
|
|
2216
|
-
const Y3 = M(G2 * H);
|
|
2217
|
-
const T3 = M(E * H);
|
|
2218
|
-
const Z3 = M(F * G2);
|
|
2219
|
-
return new _Point(X3, Y3, Z3, T3);
|
|
2220
|
-
}
|
|
2221
|
-
subtract(other) {
|
|
2222
|
-
return this.add(apoint(other).negate());
|
|
2223
|
-
}
|
|
2224
|
-
/**
|
|
2225
|
-
* Point-by-scalar multiplication. Scalar must be in range 1 <= n < CURVE.n.
|
|
2226
|
-
* Uses {@link wNAF} for base point.
|
|
2227
|
-
* Uses fake point to mitigate side-channel leakage.
|
|
2228
|
-
* @param n scalar by which point is multiplied
|
|
2229
|
-
* @param safe safe mode guards against timing attacks; unsafe mode is faster
|
|
2230
|
-
*/
|
|
2231
|
-
multiply(n, safe = true) {
|
|
2232
|
-
if (!safe && (n === 0n || this.is0()))
|
|
2233
|
-
return I;
|
|
2234
|
-
assertRange(n, 1n, N);
|
|
2235
|
-
if (n === 1n)
|
|
2236
|
-
return this;
|
|
2237
|
-
if (this.equals(G))
|
|
2238
|
-
return wNAF(n).p;
|
|
2239
|
-
let p = I;
|
|
2240
|
-
let f = G;
|
|
2241
|
-
for (let d = this; n > 0n; d = d.double(), n >>= 1n) {
|
|
2242
|
-
if (n & 1n)
|
|
2243
|
-
p = p.add(d);
|
|
2244
|
-
else if (safe)
|
|
2245
|
-
f = f.add(d);
|
|
2246
|
-
}
|
|
2247
|
-
return p;
|
|
2248
|
-
}
|
|
2249
|
-
multiplyUnsafe(scalar) {
|
|
2250
|
-
return this.multiply(scalar, false);
|
|
2251
|
-
}
|
|
2252
|
-
/** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
|
|
2253
|
-
toAffine() {
|
|
2254
|
-
const { X, Y, Z } = this;
|
|
2255
|
-
if (this.equals(I))
|
|
2256
|
-
return { x: 0n, y: 1n };
|
|
2257
|
-
const iz = invert(Z, P);
|
|
2258
|
-
if (M(Z * iz) !== 1n)
|
|
2259
|
-
err("invalid inverse");
|
|
2260
|
-
const x = M(X * iz);
|
|
2261
|
-
const y = M(Y * iz);
|
|
2262
|
-
return { x, y };
|
|
2263
|
-
}
|
|
2264
|
-
toBytes() {
|
|
2265
|
-
const { x, y } = this.assertValidity().toAffine();
|
|
2266
|
-
const b = numTo32bLE(y);
|
|
2267
|
-
b[31] |= x & 1n ? 128 : 0;
|
|
2268
|
-
return b;
|
|
2269
|
-
}
|
|
2270
|
-
toHex() {
|
|
2271
|
-
return bytesToHex(this.toBytes());
|
|
2272
|
-
}
|
|
2273
|
-
clearCofactor() {
|
|
2274
|
-
return this.multiply(big(h), false);
|
|
2275
|
-
}
|
|
2276
|
-
isSmallOrder() {
|
|
2277
|
-
return this.clearCofactor().is0();
|
|
2278
|
-
}
|
|
2279
|
-
isTorsionFree() {
|
|
2280
|
-
let p = this.multiply(N / 2n, false).double();
|
|
2281
|
-
if (N % 2n)
|
|
2282
|
-
p = p.add(this);
|
|
2283
|
-
return p.is0();
|
|
2284
|
-
}
|
|
2285
|
-
};
|
|
2286
|
-
__publicField(_Point, "BASE");
|
|
2287
|
-
__publicField(_Point, "ZERO");
|
|
2288
|
-
var Point = _Point;
|
|
2289
|
-
var G = new Point(Gx, Gy, 1n, M(Gx * Gy));
|
|
2290
|
-
var I = new Point(0n, 1n, 1n, 0n);
|
|
2291
|
-
Point.BASE = G;
|
|
2292
|
-
Point.ZERO = I;
|
|
2293
|
-
var numTo32bLE = (num) => hexToBytes(padh(assertRange(num, 0n, B256), L2)).reverse();
|
|
2294
|
-
var bytesToNumLE = (b) => big("0x" + bytesToHex(u8fr(abytes(b)).reverse()));
|
|
2295
|
-
var pow2 = (x, power) => {
|
|
2296
|
-
let r = x;
|
|
2297
|
-
while (power-- > 0n) {
|
|
2298
|
-
r *= r;
|
|
2299
|
-
r %= P;
|
|
2300
|
-
}
|
|
2301
|
-
return r;
|
|
2302
|
-
};
|
|
2303
|
-
var pow_2_252_3 = (x) => {
|
|
2304
|
-
const x2 = x * x % P;
|
|
2305
|
-
const b2 = x2 * x % P;
|
|
2306
|
-
const b4 = pow2(b2, 2n) * b2 % P;
|
|
2307
|
-
const b5 = pow2(b4, 1n) * x % P;
|
|
2308
|
-
const b10 = pow2(b5, 5n) * b5 % P;
|
|
2309
|
-
const b20 = pow2(b10, 10n) * b10 % P;
|
|
2310
|
-
const b40 = pow2(b20, 20n) * b20 % P;
|
|
2311
|
-
const b80 = pow2(b40, 40n) * b40 % P;
|
|
2312
|
-
const b160 = pow2(b80, 80n) * b80 % P;
|
|
2313
|
-
const b240 = pow2(b160, 80n) * b80 % P;
|
|
2314
|
-
const b250 = pow2(b240, 10n) * b10 % P;
|
|
2315
|
-
const pow_p_5_8 = pow2(b250, 2n) * x % P;
|
|
2316
|
-
return { pow_p_5_8, b2 };
|
|
2317
|
-
};
|
|
2318
|
-
var RM1 = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n;
|
|
2319
|
-
var uvRatio = (u, v) => {
|
|
2320
|
-
const v3 = M(v * v * v);
|
|
2321
|
-
const v7 = M(v3 * v3 * v);
|
|
2322
|
-
const pow = pow_2_252_3(u * v7).pow_p_5_8;
|
|
2323
|
-
let x = M(u * v3 * pow);
|
|
2324
|
-
const vx2 = M(v * x * x);
|
|
2325
|
-
const root1 = x;
|
|
2326
|
-
const root2 = M(x * RM1);
|
|
2327
|
-
const useRoot1 = vx2 === u;
|
|
2328
|
-
const useRoot2 = vx2 === M(-u);
|
|
2329
|
-
const noRoot = vx2 === M(-u * RM1);
|
|
2330
|
-
if (useRoot1)
|
|
2331
|
-
x = root1;
|
|
2332
|
-
if (useRoot2 || noRoot)
|
|
2333
|
-
x = root2;
|
|
2334
|
-
if ((M(x) & 1n) === 1n)
|
|
2335
|
-
x = M(-x);
|
|
2336
|
-
return { isValid: useRoot1 || useRoot2, value: x };
|
|
2337
|
-
};
|
|
2338
|
-
var modL_LE = (hash2) => modN(bytesToNumLE(hash2));
|
|
2339
|
-
var sha512a = (...m) => hashes.sha512Async(concatBytes(...m));
|
|
2340
|
-
var sha512s = (...m) => callHash("sha512")(concatBytes(...m));
|
|
2341
|
-
var hash2extK = (hashed) => {
|
|
2342
|
-
const head = hashed.slice(0, L);
|
|
2343
|
-
head[0] &= 248;
|
|
2344
|
-
head[31] &= 127;
|
|
2345
|
-
head[31] |= 64;
|
|
2346
|
-
const prefix = hashed.slice(L, L2);
|
|
2347
|
-
const scalar = modL_LE(head);
|
|
2348
|
-
const point = G.multiply(scalar);
|
|
2349
|
-
const pointBytes = point.toBytes();
|
|
2350
|
-
return { head, prefix, scalar, point, pointBytes };
|
|
2351
|
-
};
|
|
2352
|
-
var getExtendedPublicKeyAsync = (secretKey) => sha512a(abytes(secretKey, L)).then(hash2extK);
|
|
2353
|
-
var getExtendedPublicKey = (secretKey) => hash2extK(sha512s(abytes(secretKey, L)));
|
|
2354
|
-
var getPublicKeyAsync = (secretKey) => getExtendedPublicKeyAsync(secretKey).then((p) => p.pointBytes);
|
|
2355
|
-
var getPublicKey = (priv) => getExtendedPublicKey(priv).pointBytes;
|
|
2356
|
-
var hashFinishA = (res) => sha512a(res.hashable).then(res.finish);
|
|
2357
|
-
var hashFinishS = (res) => res.finish(sha512s(res.hashable));
|
|
2358
|
-
var _sign = (e, rBytes, msg) => {
|
|
2359
|
-
const { pointBytes: P2, scalar: s } = e;
|
|
2360
|
-
const r = modL_LE(rBytes);
|
|
2361
|
-
const R = G.multiply(r).toBytes();
|
|
2362
|
-
const hashable = concatBytes(R, P2, msg);
|
|
2363
|
-
const finish = (hashed) => {
|
|
2364
|
-
const S = modN(r + modL_LE(hashed) * s);
|
|
2365
|
-
return abytes(concatBytes(R, numTo32bLE(S)), L2);
|
|
2366
|
-
};
|
|
2367
|
-
return { hashable, finish };
|
|
2368
|
-
};
|
|
2369
|
-
var signAsync = async (message, secretKey) => {
|
|
2370
|
-
const m = abytes(message);
|
|
2371
|
-
const e = await getExtendedPublicKeyAsync(secretKey);
|
|
2372
|
-
const rBytes = await sha512a(e.prefix, m);
|
|
2373
|
-
return hashFinishA(_sign(e, rBytes, m));
|
|
2374
|
-
};
|
|
2375
|
-
var sign = (message, secretKey) => {
|
|
2376
|
-
const m = abytes(message);
|
|
2377
|
-
const e = getExtendedPublicKey(secretKey);
|
|
2378
|
-
const rBytes = sha512s(e.prefix, m);
|
|
2379
|
-
return hashFinishS(_sign(e, rBytes, m));
|
|
2380
|
-
};
|
|
2381
|
-
var defaultVerifyOpts = { zip215: true };
|
|
2382
|
-
var _verify = (sig, msg, pub, opts = defaultVerifyOpts) => {
|
|
2383
|
-
sig = abytes(sig, L2);
|
|
2384
|
-
msg = abytes(msg);
|
|
2385
|
-
pub = abytes(pub, L);
|
|
2386
|
-
const { zip215 } = opts;
|
|
2387
|
-
let A;
|
|
2388
|
-
let R;
|
|
2389
|
-
let s;
|
|
2390
|
-
let SB;
|
|
2391
|
-
let hashable = Uint8Array.of();
|
|
2392
|
-
try {
|
|
2393
|
-
A = Point.fromBytes(pub, zip215);
|
|
2394
|
-
R = Point.fromBytes(sig.slice(0, L), zip215);
|
|
2395
|
-
s = bytesToNumLE(sig.slice(L, L2));
|
|
2396
|
-
SB = G.multiply(s, false);
|
|
2397
|
-
hashable = concatBytes(R.toBytes(), A.toBytes(), msg);
|
|
2398
|
-
} catch (error) {
|
|
2399
|
-
}
|
|
2400
|
-
const finish = (hashed) => {
|
|
2401
|
-
if (SB == null)
|
|
2402
|
-
return false;
|
|
2403
|
-
if (!zip215 && A.isSmallOrder())
|
|
2404
|
-
return false;
|
|
2405
|
-
const k = modL_LE(hashed);
|
|
2406
|
-
const RkA = R.add(A.multiply(k, false));
|
|
2407
|
-
return RkA.add(SB.negate()).clearCofactor().is0();
|
|
2408
|
-
};
|
|
2409
|
-
return { hashable, finish };
|
|
2410
|
-
};
|
|
2411
|
-
var verifyAsync = async (signature, message, publicKey, opts = defaultVerifyOpts) => hashFinishA(_verify(signature, message, publicKey, opts));
|
|
2412
|
-
var verify = (signature, message, publicKey, opts = defaultVerifyOpts) => hashFinishS(_verify(signature, message, publicKey, opts));
|
|
2413
|
-
var etc = {
|
|
2414
|
-
bytesToHex,
|
|
2415
|
-
hexToBytes,
|
|
2416
|
-
concatBytes,
|
|
2417
|
-
mod: M,
|
|
2418
|
-
invert,
|
|
2419
|
-
randomBytes
|
|
2420
|
-
};
|
|
2421
|
-
var hashes = {
|
|
2422
|
-
sha512Async: async (message) => {
|
|
2423
|
-
const s = subtle();
|
|
2424
|
-
const m = concatBytes(message);
|
|
2425
|
-
return u8n(await s.digest("SHA-512", m.buffer));
|
|
2426
|
-
},
|
|
2427
|
-
sha512: void 0
|
|
2428
|
-
};
|
|
2429
|
-
var randomSecretKey = (seed = randomBytes(L)) => seed;
|
|
2430
|
-
var keygen = (seed) => {
|
|
2431
|
-
const secretKey = randomSecretKey(seed);
|
|
2432
|
-
const publicKey = getPublicKey(secretKey);
|
|
2433
|
-
return { secretKey, publicKey };
|
|
2434
|
-
};
|
|
2435
|
-
var keygenAsync = async (seed) => {
|
|
2436
|
-
const secretKey = randomSecretKey(seed);
|
|
2437
|
-
const publicKey = await getPublicKeyAsync(secretKey);
|
|
2438
|
-
return { secretKey, publicKey };
|
|
2439
|
-
};
|
|
2440
|
-
var utils = {
|
|
2441
|
-
getExtendedPublicKeyAsync,
|
|
2442
|
-
getExtendedPublicKey,
|
|
2443
|
-
randomSecretKey
|
|
2444
|
-
};
|
|
2445
|
-
var W = 8;
|
|
2446
|
-
var scalarBits = 256;
|
|
2447
|
-
var pwindows = Math.ceil(scalarBits / W) + 1;
|
|
2448
|
-
var pwindowSize = 2 ** (W - 1);
|
|
2449
|
-
var precompute = () => {
|
|
2450
|
-
const points = [];
|
|
2451
|
-
let p = G;
|
|
2452
|
-
let b = p;
|
|
2453
|
-
for (let w = 0; w < pwindows; w++) {
|
|
2454
|
-
b = p;
|
|
2455
|
-
points.push(b);
|
|
2456
|
-
for (let i = 1; i < pwindowSize; i++) {
|
|
2457
|
-
b = b.add(p);
|
|
2458
|
-
points.push(b);
|
|
2459
|
-
}
|
|
2460
|
-
p = b.double();
|
|
2461
|
-
}
|
|
2462
|
-
return points;
|
|
2463
|
-
};
|
|
2464
|
-
var Gpows = void 0;
|
|
2465
|
-
var ctneg = (cnd, p) => {
|
|
2466
|
-
const n = p.negate();
|
|
2467
|
-
return cnd ? n : p;
|
|
2468
|
-
};
|
|
2469
|
-
var wNAF = (n) => {
|
|
2470
|
-
const comp = Gpows || (Gpows = precompute());
|
|
2471
|
-
let p = I;
|
|
2472
|
-
let f = G;
|
|
2473
|
-
const pow_2_w = 2 ** W;
|
|
2474
|
-
const maxNum = pow_2_w;
|
|
2475
|
-
const mask = big(pow_2_w - 1);
|
|
2476
|
-
const shiftBy = big(W);
|
|
2477
|
-
for (let w = 0; w < pwindows; w++) {
|
|
2478
|
-
let wbits = Number(n & mask);
|
|
2479
|
-
n >>= shiftBy;
|
|
2480
|
-
if (wbits > pwindowSize) {
|
|
2481
|
-
wbits -= maxNum;
|
|
2482
|
-
n += 1n;
|
|
2483
|
-
}
|
|
2484
|
-
const off = w * pwindowSize;
|
|
2485
|
-
const offF = off;
|
|
2486
|
-
const offP = off + Math.abs(wbits) - 1;
|
|
2487
|
-
const isEven = w % 2 !== 0;
|
|
2488
|
-
const isNeg = wbits < 0;
|
|
2489
|
-
if (wbits === 0) {
|
|
2490
|
-
f = f.add(ctneg(isEven, comp[offF]));
|
|
2491
|
-
} else {
|
|
2492
|
-
p = p.add(ctneg(isNeg, comp[offP]));
|
|
2493
|
-
}
|
|
2494
|
-
}
|
|
2495
|
-
if (n !== 0n)
|
|
2496
|
-
err("invalid wnaf");
|
|
2497
|
-
return { p, f };
|
|
2498
|
-
};
|
|
1963
|
+
// src/sdk/ed25519-setup.ts
|
|
1964
|
+
var ed25519 = __toESM(require("@noble/ed25519"), 1);
|
|
2499
1965
|
|
|
2500
1966
|
// node_modules/@noble/hashes/utils.js
|
|
2501
|
-
function
|
|
1967
|
+
function isBytes2(a) {
|
|
2502
1968
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
2503
1969
|
}
|
|
2504
|
-
function
|
|
2505
|
-
const bytes =
|
|
1970
|
+
function abytes(value, length, title = "") {
|
|
1971
|
+
const bytes = isBytes2(value);
|
|
2506
1972
|
const len = value?.length;
|
|
2507
1973
|
const needsLen = length !== void 0;
|
|
2508
1974
|
if (!bytes || needsLen && len !== length) {
|
|
@@ -2520,7 +1986,7 @@ function aexists(instance, checkFinished = true) {
|
|
|
2520
1986
|
throw new Error("Hash#digest() has already been called");
|
|
2521
1987
|
}
|
|
2522
1988
|
function aoutput(out, instance) {
|
|
2523
|
-
|
|
1989
|
+
abytes(out, void 0, "digestInto() output");
|
|
2524
1990
|
const min = instance.outputLen;
|
|
2525
1991
|
if (out.length < min) {
|
|
2526
1992
|
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
@@ -2570,7 +2036,7 @@ var HashMD = class {
|
|
|
2570
2036
|
}
|
|
2571
2037
|
update(data) {
|
|
2572
2038
|
aexists(this);
|
|
2573
|
-
|
|
2039
|
+
abytes(data);
|
|
2574
2040
|
const { view, buffer, blockLen } = this;
|
|
2575
2041
|
const len = data.length;
|
|
2576
2042
|
for (let pos = 0; pos < len; ) {
|
|
@@ -2675,17 +2141,17 @@ function split(lst, le = false) {
|
|
|
2675
2141
|
let Ah = new Uint32Array(len);
|
|
2676
2142
|
let Al = new Uint32Array(len);
|
|
2677
2143
|
for (let i = 0; i < len; i++) {
|
|
2678
|
-
const { h
|
|
2679
|
-
[Ah[i], Al[i]] = [
|
|
2144
|
+
const { h, l } = fromBig(lst[i], le);
|
|
2145
|
+
[Ah[i], Al[i]] = [h, l];
|
|
2680
2146
|
}
|
|
2681
2147
|
return [Ah, Al];
|
|
2682
2148
|
}
|
|
2683
|
-
var shrSH = (
|
|
2684
|
-
var shrSL = (
|
|
2685
|
-
var rotrSH = (
|
|
2686
|
-
var rotrSL = (
|
|
2687
|
-
var rotrBH = (
|
|
2688
|
-
var rotrBL = (
|
|
2149
|
+
var shrSH = (h, _l, s) => h >>> s;
|
|
2150
|
+
var shrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2151
|
+
var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
|
|
2152
|
+
var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
|
|
2153
|
+
var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
|
|
2154
|
+
var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
|
|
2689
2155
|
function add(Ah, Al, Bh, Bl) {
|
|
2690
2156
|
const l = (Al >>> 0) + (Bl >>> 0);
|
|
2691
2157
|
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
@@ -2906,7 +2372,8 @@ var sha512 = /* @__PURE__ */ createHasher(
|
|
|
2906
2372
|
);
|
|
2907
2373
|
|
|
2908
2374
|
// src/sdk/ed25519-setup.ts
|
|
2909
|
-
hashes.sha512 = sha512;
|
|
2375
|
+
ed25519.hashes.sha512 = sha512;
|
|
2376
|
+
var ed = ed25519;
|
|
2910
2377
|
|
|
2911
2378
|
// src/WarpFastsetWallet.ts
|
|
2912
2379
|
var WarpFastsetWallet = class {
|
|
@@ -2925,7 +2392,7 @@ var WarpFastsetWallet = class {
|
|
|
2925
2392
|
const privateKey = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
2926
2393
|
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2927
2394
|
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2928
|
-
const signature =
|
|
2395
|
+
const signature = ed.sign(dataToSign, privateKeyBytes);
|
|
2929
2396
|
return { ...tx, signature };
|
|
2930
2397
|
}
|
|
2931
2398
|
async signMessage(message) {
|
|
@@ -2933,7 +2400,7 @@ var WarpFastsetWallet = class {
|
|
|
2933
2400
|
const privateKey = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
2934
2401
|
if (!privateKey) throw new Error("Wallet not initialized - no private key provided");
|
|
2935
2402
|
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2936
|
-
const signature =
|
|
2403
|
+
const signature = ed.sign(messageBytes, privateKeyBytes);
|
|
2937
2404
|
return uint8ArrayToHex(signature);
|
|
2938
2405
|
}
|
|
2939
2406
|
async signTransactions(txs) {
|
|
@@ -2950,15 +2417,15 @@ var WarpFastsetWallet = class {
|
|
|
2950
2417
|
create(mnemonic) {
|
|
2951
2418
|
const seed = bip39.mnemonicToSeedSync(mnemonic);
|
|
2952
2419
|
const privateKey = seed.slice(0, 32);
|
|
2953
|
-
const publicKey =
|
|
2420
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2954
2421
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2955
|
-
return { address, privateKey: uint8ArrayToHex(privateKey), mnemonic };
|
|
2422
|
+
return { provider: "privateKey", address, privateKey: uint8ArrayToHex(privateKey), mnemonic };
|
|
2956
2423
|
}
|
|
2957
2424
|
generate() {
|
|
2958
|
-
const privateKey =
|
|
2959
|
-
const publicKey =
|
|
2425
|
+
const privateKey = ed.utils.randomSecretKey();
|
|
2426
|
+
const publicKey = ed.getPublicKey(privateKey);
|
|
2960
2427
|
const address = FastsetClient.encodeBech32Address(publicKey);
|
|
2961
|
-
return { address, privateKey: uint8ArrayToHex(privateKey), mnemonic: null };
|
|
2428
|
+
return { provider: "privateKey", address, privateKey: uint8ArrayToHex(privateKey), mnemonic: null };
|
|
2962
2429
|
}
|
|
2963
2430
|
getAddress() {
|
|
2964
2431
|
return (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
@@ -2967,7 +2434,7 @@ var WarpFastsetWallet = class {
|
|
|
2967
2434
|
const privateKey = (0, import_warps5.getWarpWalletPrivateKeyFromConfig)(this.config, this.chain.name);
|
|
2968
2435
|
if (privateKey) {
|
|
2969
2436
|
const privateKeyBytes = hexToUint8Array(privateKey);
|
|
2970
|
-
const publicKey =
|
|
2437
|
+
const publicKey = ed.getPublicKey(privateKeyBytes);
|
|
2971
2438
|
return uint8ArrayToHex(publicKey);
|
|
2972
2439
|
}
|
|
2973
2440
|
const address = (0, import_warps5.getWarpWalletAddressFromConfig)(this.config, this.chain.name);
|
|
@@ -3010,7 +2477,7 @@ function createFastsetAdapter(chainName, chainInfos) {
|
|
|
3010
2477
|
};
|
|
3011
2478
|
};
|
|
3012
2479
|
}
|
|
3013
|
-
var
|
|
2480
|
+
var FastsetAdapter = createFastsetAdapter(import_warps6.WarpChainName.Fastset, {
|
|
3014
2481
|
mainnet: {
|
|
3015
2482
|
name: import_warps6.WarpChainName.Fastset,
|
|
3016
2483
|
displayName: "FastSet",
|
|
@@ -3044,19 +2511,16 @@ var getFastsetAdapter = createFastsetAdapter(import_warps6.WarpChainName.Fastset
|
|
|
3044
2511
|
});
|
|
3045
2512
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3046
2513
|
0 && (module.exports = {
|
|
2514
|
+
FastsetAdapter,
|
|
3047
2515
|
NativeTokenSet,
|
|
3048
2516
|
WarpFastsetExecutor,
|
|
3049
|
-
WarpFastsetWallet
|
|
3050
|
-
getFastsetAdapter
|
|
2517
|
+
WarpFastsetWallet
|
|
3051
2518
|
});
|
|
3052
2519
|
/*! Bundled license information:
|
|
3053
2520
|
|
|
3054
2521
|
@scure/base/lib/esm/index.js:
|
|
3055
2522
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
3056
2523
|
|
|
3057
|
-
@noble/ed25519/index.js:
|
|
3058
|
-
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
3059
|
-
|
|
3060
2524
|
@noble/hashes/utils.js:
|
|
3061
2525
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
3062
2526
|
*/
|