@etherplay/dev-wallet-host 0.1.2 → 0.2.0
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/package.json +1 -1
- package/site/assets/{App-DDcApMye.js → App-xSBx5ak5.js} +2617 -829
- package/site/assets/App-xSBx5ak5.js.map +1 -0
- package/site/assets/{bignumbers-DEXSwWwa.js → bignumbers-C7-lnukQ.js} +2 -2
- package/site/assets/{bignumbers-DEXSwWwa.js.map → bignumbers-C7-lnukQ.js.map} +1 -1
- package/site/assets/{index-BpgHGts3.js → index-BSfEJRCZ.js} +3 -3
- package/site/assets/{index-BpgHGts3.js.map → index-BSfEJRCZ.js.map} +1 -1
- package/site/assets/{index-Boiz7eM2.js → index-B_E-HnzD.js} +8 -8
- package/site/assets/{index-Boiz7eM2.js.map → index-B_E-HnzD.js.map} +1 -1
- package/site/assets/{index-BAWUHBts.js → index-Bz0M5Gj5.js} +4 -4
- package/site/assets/{index-BAWUHBts.js.map → index-Bz0M5Gj5.js.map} +1 -1
- package/site/assets/{index-BrlXb28n.js → index-CkvCbn7v.js} +2 -2
- package/site/assets/{index-BrlXb28n.js.map → index-CkvCbn7v.js.map} +1 -1
- package/site/assets/{index-BXoUMG4U.js → index-IIDV-e6n.js} +6 -6
- package/site/assets/{index-BXoUMG4U.js.map → index-IIDV-e6n.js.map} +1 -1
- package/site/assets/{index-NKFZZPPE.js → index-LN4UBwKA.js} +6 -6
- package/site/assets/{index-NKFZZPPE.js.map → index-LN4UBwKA.js.map} +1 -1
- package/site/assets/{login-Bm1QORQJ.js → login-CT3CiPqL.js} +3 -3
- package/site/assets/{login-Bm1QORQJ.js.map → login-CT3CiPqL.js.map} +1 -1
- package/site/assets/{typed-data-CUGl6Sw8.js → typed-data-kK2YTiXf.js} +4 -4
- package/site/assets/{typed-data-CUGl6Sw8.js.map → typed-data-kK2YTiXf.js.map} +1 -1
- package/site/assets/{utf8-xywbIwOw.js → utf8-DUBJCSEI.js} +2 -2
- package/site/assets/{utf8-xywbIwOw.js.map → utf8-DUBJCSEI.js.map} +1 -1
- package/site/login/index.html +1 -1
- package/site/assets/App-DDcApMye.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BSfEJRCZ.js","assets/index-client-8kPxwRn_.js","assets/login-CT3CiPqL.js","assets/login-Dm0rG43D.css","assets/index-IIDV-e6n.js","assets/typed-data-kK2YTiXf.js","assets/utf8-DUBJCSEI.js","assets/index-CkvCbn7v.js","assets/index-LN4UBwKA.js","assets/bignumbers-C7-lnukQ.js","assets/index-B_E-HnzD.js","assets/index-Bz0M5Gj5.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __typeError = (msg) => {
|
|
4
4
|
throw TypeError(msg);
|
|
@@ -20,7 +20,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
20
20
|
});
|
|
21
21
|
var _a, _b, _c, _d, _e, _t, _e2, _s, _a2, _i, _r, _o, _n, _h, _d2, _c2, _p, _E_instances, m_fn, _f, _e3, _s2, _t2, _i2, _o2, _r2, _n2, _a3, _c3, _g2, _h2, _d3, _l, _g, _h3;
|
|
22
22
|
import { i as is_array, g as get_prototype_of, o as object_prototype, c as create_text, a as active_effect, b as get_first_child, d as is_firefox, T as TEMPLATE_FRAGMENT, e as TEMPLATE_USE_IMPORT_NODE, f as block, E as EFFECT_TRANSPARENT, r as resume_effect, h as branch, p as pause_effect, U as UNINITIALIZED, j as get$2, k as derived_safe_equal, I as INERT, l as array_from, m as mutable_source, s as source$1, n as internal_set, q as pause_children, t as clear_text_content, u as run_out_transitions, v as destroy_effect, w as EACH_INDEX_REACTIVE, x as EACH_ITEM_REACTIVE, y as EACH_ITEM_IMMUTABLE, z as get_next_sibling, A as EACH_IS_CONTROLLED, B as queue_micro_task, C as EACH_IS_ANIMATED, D as effect, F as untrack, G as render_effect, H as deep_read_state, J as safe_not_equal$1, L as LOADING_ATTR_SYMBOL, N as NAMESPACE_HTML, K as get_descriptors, S as STATE_SYMBOL, M as component_context, O as user_pre_effect, P as user_effect, Q as run_all, R as run, V as derived, W as noop$3, X as teardown, Y as define_property, Z as set, _ as proxy, $ as get_descriptor, a0 as props_invalid_value, a1 as LEGACY_DERIVED_PROP, a2 as PROPS_IS_UPDATED, a3 as safe_equals, a4 as PROPS_IS_BINDABLE, a5 as LEGACY_PROPS, a6 as PROPS_IS_LAZY_INITIAL, a7 as legacy_mode_flag, a8 as PROPS_IS_RUNES, a9 as PROPS_IS_IMMUTABLE, aa as enable_legacy_mode_flag, ab as delegate, ac as push, ad as user_derived, ae as sibling, af as pop, ag as child, ah as template_effect, ai as set_text, aj as first_child, ak as onMount, al as event, am as state } from "./index-client-8kPxwRn_.js";
|
|
23
|
-
import { _ as __vitePreload, h as hostConfig } from "./login-
|
|
23
|
+
import { _ as __vitePreload, h as hostConfig } from "./login-CT3CiPqL.js";
|
|
24
24
|
const empty = [];
|
|
25
25
|
function snapshot(value, skip_warning = false) {
|
|
26
26
|
return clone(value, /* @__PURE__ */ new Map(), "", empty);
|
|
@@ -1839,6 +1839,7 @@ function Loading($$anchor) {
|
|
|
1839
1839
|
var main2 = root$2();
|
|
1840
1840
|
append($$anchor, main2);
|
|
1841
1841
|
}
|
|
1842
|
+
const crypto$2 = typeof globalThis === "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
1842
1843
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1843
1844
|
function isBytes$5(a5) {
|
|
1844
1845
|
return a5 instanceof Uint8Array || ArrayBuffer.isView(a5) && a5.constructor.name === "Uint8Array";
|
|
@@ -1853,6 +1854,12 @@ function abytes$2(b2, ...lengths) {
|
|
|
1853
1854
|
if (lengths.length > 0 && !lengths.includes(b2.length))
|
|
1854
1855
|
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b2.length);
|
|
1855
1856
|
}
|
|
1857
|
+
function ahash$1(h2) {
|
|
1858
|
+
if (typeof h2 !== "function" || typeof h2.create !== "function")
|
|
1859
|
+
throw new Error("Hash should be wrapped by utils.createHasher");
|
|
1860
|
+
anumber$3(h2.outputLen);
|
|
1861
|
+
anumber$3(h2.blockLen);
|
|
1862
|
+
}
|
|
1856
1863
|
function aexists$1(instance, checkFinished = true) {
|
|
1857
1864
|
if (instance.destroyed)
|
|
1858
1865
|
throw new Error("Hash instance has been destroyed");
|
|
@@ -1948,6 +1955,21 @@ function toBytes$1(data) {
|
|
|
1948
1955
|
abytes$2(data);
|
|
1949
1956
|
return data;
|
|
1950
1957
|
}
|
|
1958
|
+
function concatBytes$2(...arrays) {
|
|
1959
|
+
let sum = 0;
|
|
1960
|
+
for (let i3 = 0; i3 < arrays.length; i3++) {
|
|
1961
|
+
const a5 = arrays[i3];
|
|
1962
|
+
abytes$2(a5);
|
|
1963
|
+
sum += a5.length;
|
|
1964
|
+
}
|
|
1965
|
+
const res = new Uint8Array(sum);
|
|
1966
|
+
for (let i3 = 0, pad = 0; i3 < arrays.length; i3++) {
|
|
1967
|
+
const a5 = arrays[i3];
|
|
1968
|
+
res.set(a5, pad);
|
|
1969
|
+
pad += a5.length;
|
|
1970
|
+
}
|
|
1971
|
+
return res;
|
|
1972
|
+
}
|
|
1951
1973
|
let Hash$1 = class Hash {
|
|
1952
1974
|
};
|
|
1953
1975
|
function createHasher(hashCons) {
|
|
@@ -1958,6 +1980,81 @@ function createHasher(hashCons) {
|
|
|
1958
1980
|
hashC.create = () => hashCons();
|
|
1959
1981
|
return hashC;
|
|
1960
1982
|
}
|
|
1983
|
+
function randomBytes$1(bytesLength = 32) {
|
|
1984
|
+
if (crypto$2 && typeof crypto$2.getRandomValues === "function") {
|
|
1985
|
+
return crypto$2.getRandomValues(new Uint8Array(bytesLength));
|
|
1986
|
+
}
|
|
1987
|
+
if (crypto$2 && typeof crypto$2.randomBytes === "function") {
|
|
1988
|
+
return Uint8Array.from(crypto$2.randomBytes(bytesLength));
|
|
1989
|
+
}
|
|
1990
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
1991
|
+
}
|
|
1992
|
+
let HMAC$1 = class HMAC extends Hash$1 {
|
|
1993
|
+
constructor(hash, _key) {
|
|
1994
|
+
super();
|
|
1995
|
+
this.finished = false;
|
|
1996
|
+
this.destroyed = false;
|
|
1997
|
+
ahash$1(hash);
|
|
1998
|
+
const key = toBytes$1(_key);
|
|
1999
|
+
this.iHash = hash.create();
|
|
2000
|
+
if (typeof this.iHash.update !== "function")
|
|
2001
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
2002
|
+
this.blockLen = this.iHash.blockLen;
|
|
2003
|
+
this.outputLen = this.iHash.outputLen;
|
|
2004
|
+
const blockLen = this.blockLen;
|
|
2005
|
+
const pad = new Uint8Array(blockLen);
|
|
2006
|
+
pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
|
|
2007
|
+
for (let i3 = 0; i3 < pad.length; i3++)
|
|
2008
|
+
pad[i3] ^= 54;
|
|
2009
|
+
this.iHash.update(pad);
|
|
2010
|
+
this.oHash = hash.create();
|
|
2011
|
+
for (let i3 = 0; i3 < pad.length; i3++)
|
|
2012
|
+
pad[i3] ^= 54 ^ 92;
|
|
2013
|
+
this.oHash.update(pad);
|
|
2014
|
+
clean(pad);
|
|
2015
|
+
}
|
|
2016
|
+
update(buf) {
|
|
2017
|
+
aexists$1(this);
|
|
2018
|
+
this.iHash.update(buf);
|
|
2019
|
+
return this;
|
|
2020
|
+
}
|
|
2021
|
+
digestInto(out) {
|
|
2022
|
+
aexists$1(this);
|
|
2023
|
+
abytes$2(out, this.outputLen);
|
|
2024
|
+
this.finished = true;
|
|
2025
|
+
this.iHash.digestInto(out);
|
|
2026
|
+
this.oHash.update(out);
|
|
2027
|
+
this.oHash.digestInto(out);
|
|
2028
|
+
this.destroy();
|
|
2029
|
+
}
|
|
2030
|
+
digest() {
|
|
2031
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
2032
|
+
this.digestInto(out);
|
|
2033
|
+
return out;
|
|
2034
|
+
}
|
|
2035
|
+
_cloneInto(to) {
|
|
2036
|
+
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
2037
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
2038
|
+
to = to;
|
|
2039
|
+
to.finished = finished;
|
|
2040
|
+
to.destroyed = destroyed;
|
|
2041
|
+
to.blockLen = blockLen;
|
|
2042
|
+
to.outputLen = outputLen;
|
|
2043
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
2044
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
2045
|
+
return to;
|
|
2046
|
+
}
|
|
2047
|
+
clone() {
|
|
2048
|
+
return this._cloneInto();
|
|
2049
|
+
}
|
|
2050
|
+
destroy() {
|
|
2051
|
+
this.destroyed = true;
|
|
2052
|
+
this.oHash.destroy();
|
|
2053
|
+
this.iHash.destroy();
|
|
2054
|
+
}
|
|
2055
|
+
};
|
|
2056
|
+
const hmac$1 = (hash, key, message) => new HMAC$1(hash, key).update(message).digest();
|
|
2057
|
+
hmac$1.create = (hash, key) => new HMAC$1(hash, key);
|
|
1961
2058
|
function setBigUint64$1(view, byteOffset, value, isLE2) {
|
|
1962
2059
|
if (typeof view.setBigUint64 === "function")
|
|
1963
2060
|
return view.setBigUint64(byteOffset, value, isLE2);
|
|
@@ -2076,6 +2173,24 @@ const SHA256_IV$1 = /* @__PURE__ */ Uint32Array.from([
|
|
|
2076
2173
|
528734635,
|
|
2077
2174
|
1541459225
|
|
2078
2175
|
]);
|
|
2176
|
+
const SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
2177
|
+
1779033703,
|
|
2178
|
+
4089235720,
|
|
2179
|
+
3144134277,
|
|
2180
|
+
2227873595,
|
|
2181
|
+
1013904242,
|
|
2182
|
+
4271175723,
|
|
2183
|
+
2773480762,
|
|
2184
|
+
1595750129,
|
|
2185
|
+
1359893119,
|
|
2186
|
+
2917565137,
|
|
2187
|
+
2600822924,
|
|
2188
|
+
725511199,
|
|
2189
|
+
528734635,
|
|
2190
|
+
4215389547,
|
|
2191
|
+
1541459225,
|
|
2192
|
+
327033209
|
|
2193
|
+
]);
|
|
2079
2194
|
const U32_MASK64$1 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
2080
2195
|
const _32n$1 = /* @__PURE__ */ BigInt(32);
|
|
2081
2196
|
function fromBig$1(n4, le = false) {
|
|
@@ -2093,10 +2208,26 @@ function split$1(lst, le = false) {
|
|
|
2093
2208
|
}
|
|
2094
2209
|
return [Ah, Al];
|
|
2095
2210
|
}
|
|
2211
|
+
const shrSH$1 = (h2, _l2, s5) => h2 >>> s5;
|
|
2212
|
+
const shrSL$1 = (h2, l3, s5) => h2 << 32 - s5 | l3 >>> s5;
|
|
2213
|
+
const rotrSH$1 = (h2, l3, s5) => h2 >>> s5 | l3 << 32 - s5;
|
|
2214
|
+
const rotrSL$1 = (h2, l3, s5) => h2 << 32 - s5 | l3 >>> s5;
|
|
2215
|
+
const rotrBH$1 = (h2, l3, s5) => h2 << 64 - s5 | l3 >>> s5 - 32;
|
|
2216
|
+
const rotrBL$1 = (h2, l3, s5) => h2 >>> s5 - 32 | l3 << 64 - s5;
|
|
2096
2217
|
const rotlSH$1 = (h2, l3, s5) => h2 << s5 | l3 >>> 32 - s5;
|
|
2097
2218
|
const rotlSL$1 = (h2, l3, s5) => l3 << s5 | h2 >>> 32 - s5;
|
|
2098
2219
|
const rotlBH$1 = (h2, l3, s5) => l3 << s5 - 32 | h2 >>> 64 - s5;
|
|
2099
2220
|
const rotlBL$1 = (h2, l3, s5) => h2 << s5 - 32 | l3 >>> 64 - s5;
|
|
2221
|
+
function add$1(Ah, Al, Bh, Bl) {
|
|
2222
|
+
const l3 = (Al >>> 0) + (Bl >>> 0);
|
|
2223
|
+
return { h: Ah + Bh + (l3 / 2 ** 32 | 0) | 0, l: l3 | 0 };
|
|
2224
|
+
}
|
|
2225
|
+
const add3L$1 = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
2226
|
+
const add3H$1 = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
2227
|
+
const add4L$1 = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
2228
|
+
const add4H$1 = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
2229
|
+
const add5L$1 = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
2230
|
+
const add5H$1 = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
2100
2231
|
const SHA256_K$1 = /* @__PURE__ */ Uint32Array.from([
|
|
2101
2232
|
1116352408,
|
|
2102
2233
|
1899447441,
|
|
@@ -2177,14 +2308,14 @@ let SHA256$1 = class SHA256 extends HashMD$1 {
|
|
|
2177
2308
|
this.H = SHA256_IV$1[7] | 0;
|
|
2178
2309
|
}
|
|
2179
2310
|
get() {
|
|
2180
|
-
const { A: A3, B, C:
|
|
2181
|
-
return [A3, B,
|
|
2311
|
+
const { A: A3, B, C: C2, D: D2, E: E2, F, G: G2, H } = this;
|
|
2312
|
+
return [A3, B, C2, D2, E2, F, G2, H];
|
|
2182
2313
|
}
|
|
2183
2314
|
// prettier-ignore
|
|
2184
|
-
set(A3, B,
|
|
2315
|
+
set(A3, B, C2, D2, E2, F, G2, H) {
|
|
2185
2316
|
this.A = A3 | 0;
|
|
2186
2317
|
this.B = B | 0;
|
|
2187
|
-
this.C =
|
|
2318
|
+
this.C = C2 | 0;
|
|
2188
2319
|
this.D = D2 | 0;
|
|
2189
2320
|
this.E = E2 | 0;
|
|
2190
2321
|
this.F = F | 0;
|
|
@@ -2201,30 +2332,30 @@ let SHA256$1 = class SHA256 extends HashMD$1 {
|
|
|
2201
2332
|
const s1 = rotr$1(W2, 17) ^ rotr$1(W2, 19) ^ W2 >>> 10;
|
|
2202
2333
|
SHA256_W$1[i3] = s1 + SHA256_W$1[i3 - 7] + s0 + SHA256_W$1[i3 - 16] | 0;
|
|
2203
2334
|
}
|
|
2204
|
-
let { A: A3, B, C:
|
|
2335
|
+
let { A: A3, B, C: C2, D: D2, E: E2, F, G: G2, H } = this;
|
|
2205
2336
|
for (let i3 = 0; i3 < 64; i3++) {
|
|
2206
2337
|
const sigma1 = rotr$1(E2, 6) ^ rotr$1(E2, 11) ^ rotr$1(E2, 25);
|
|
2207
2338
|
const T1 = H + sigma1 + Chi$1(E2, F, G2) + SHA256_K$1[i3] + SHA256_W$1[i3] | 0;
|
|
2208
2339
|
const sigma0 = rotr$1(A3, 2) ^ rotr$1(A3, 13) ^ rotr$1(A3, 22);
|
|
2209
|
-
const T22 = sigma0 + Maj$1(A3, B,
|
|
2340
|
+
const T22 = sigma0 + Maj$1(A3, B, C2) | 0;
|
|
2210
2341
|
H = G2;
|
|
2211
2342
|
G2 = F;
|
|
2212
2343
|
F = E2;
|
|
2213
2344
|
E2 = D2 + T1 | 0;
|
|
2214
|
-
D2 =
|
|
2215
|
-
|
|
2345
|
+
D2 = C2;
|
|
2346
|
+
C2 = B;
|
|
2216
2347
|
B = A3;
|
|
2217
2348
|
A3 = T1 + T22 | 0;
|
|
2218
2349
|
}
|
|
2219
2350
|
A3 = A3 + this.A | 0;
|
|
2220
2351
|
B = B + this.B | 0;
|
|
2221
|
-
|
|
2352
|
+
C2 = C2 + this.C | 0;
|
|
2222
2353
|
D2 = D2 + this.D | 0;
|
|
2223
2354
|
E2 = E2 + this.E | 0;
|
|
2224
2355
|
F = F + this.F | 0;
|
|
2225
2356
|
G2 = G2 + this.G | 0;
|
|
2226
2357
|
H = H + this.H | 0;
|
|
2227
|
-
this.set(A3, B,
|
|
2358
|
+
this.set(A3, B, C2, D2, E2, F, G2, H);
|
|
2228
2359
|
}
|
|
2229
2360
|
roundClean() {
|
|
2230
2361
|
clean(SHA256_W$1);
|
|
@@ -2234,7 +2365,205 @@ let SHA256$1 = class SHA256 extends HashMD$1 {
|
|
|
2234
2365
|
clean(this.buffer);
|
|
2235
2366
|
}
|
|
2236
2367
|
};
|
|
2368
|
+
const K512 = /* @__PURE__ */ (() => split$1([
|
|
2369
|
+
"0x428a2f98d728ae22",
|
|
2370
|
+
"0x7137449123ef65cd",
|
|
2371
|
+
"0xb5c0fbcfec4d3b2f",
|
|
2372
|
+
"0xe9b5dba58189dbbc",
|
|
2373
|
+
"0x3956c25bf348b538",
|
|
2374
|
+
"0x59f111f1b605d019",
|
|
2375
|
+
"0x923f82a4af194f9b",
|
|
2376
|
+
"0xab1c5ed5da6d8118",
|
|
2377
|
+
"0xd807aa98a3030242",
|
|
2378
|
+
"0x12835b0145706fbe",
|
|
2379
|
+
"0x243185be4ee4b28c",
|
|
2380
|
+
"0x550c7dc3d5ffb4e2",
|
|
2381
|
+
"0x72be5d74f27b896f",
|
|
2382
|
+
"0x80deb1fe3b1696b1",
|
|
2383
|
+
"0x9bdc06a725c71235",
|
|
2384
|
+
"0xc19bf174cf692694",
|
|
2385
|
+
"0xe49b69c19ef14ad2",
|
|
2386
|
+
"0xefbe4786384f25e3",
|
|
2387
|
+
"0x0fc19dc68b8cd5b5",
|
|
2388
|
+
"0x240ca1cc77ac9c65",
|
|
2389
|
+
"0x2de92c6f592b0275",
|
|
2390
|
+
"0x4a7484aa6ea6e483",
|
|
2391
|
+
"0x5cb0a9dcbd41fbd4",
|
|
2392
|
+
"0x76f988da831153b5",
|
|
2393
|
+
"0x983e5152ee66dfab",
|
|
2394
|
+
"0xa831c66d2db43210",
|
|
2395
|
+
"0xb00327c898fb213f",
|
|
2396
|
+
"0xbf597fc7beef0ee4",
|
|
2397
|
+
"0xc6e00bf33da88fc2",
|
|
2398
|
+
"0xd5a79147930aa725",
|
|
2399
|
+
"0x06ca6351e003826f",
|
|
2400
|
+
"0x142929670a0e6e70",
|
|
2401
|
+
"0x27b70a8546d22ffc",
|
|
2402
|
+
"0x2e1b21385c26c926",
|
|
2403
|
+
"0x4d2c6dfc5ac42aed",
|
|
2404
|
+
"0x53380d139d95b3df",
|
|
2405
|
+
"0x650a73548baf63de",
|
|
2406
|
+
"0x766a0abb3c77b2a8",
|
|
2407
|
+
"0x81c2c92e47edaee6",
|
|
2408
|
+
"0x92722c851482353b",
|
|
2409
|
+
"0xa2bfe8a14cf10364",
|
|
2410
|
+
"0xa81a664bbc423001",
|
|
2411
|
+
"0xc24b8b70d0f89791",
|
|
2412
|
+
"0xc76c51a30654be30",
|
|
2413
|
+
"0xd192e819d6ef5218",
|
|
2414
|
+
"0xd69906245565a910",
|
|
2415
|
+
"0xf40e35855771202a",
|
|
2416
|
+
"0x106aa07032bbd1b8",
|
|
2417
|
+
"0x19a4c116b8d2d0c8",
|
|
2418
|
+
"0x1e376c085141ab53",
|
|
2419
|
+
"0x2748774cdf8eeb99",
|
|
2420
|
+
"0x34b0bcb5e19b48a8",
|
|
2421
|
+
"0x391c0cb3c5c95a63",
|
|
2422
|
+
"0x4ed8aa4ae3418acb",
|
|
2423
|
+
"0x5b9cca4f7763e373",
|
|
2424
|
+
"0x682e6ff3d6b2b8a3",
|
|
2425
|
+
"0x748f82ee5defb2fc",
|
|
2426
|
+
"0x78a5636f43172f60",
|
|
2427
|
+
"0x84c87814a1f0ab72",
|
|
2428
|
+
"0x8cc702081a6439ec",
|
|
2429
|
+
"0x90befffa23631e28",
|
|
2430
|
+
"0xa4506cebde82bde9",
|
|
2431
|
+
"0xbef9a3f7b2c67915",
|
|
2432
|
+
"0xc67178f2e372532b",
|
|
2433
|
+
"0xca273eceea26619c",
|
|
2434
|
+
"0xd186b8c721c0c207",
|
|
2435
|
+
"0xeada7dd6cde0eb1e",
|
|
2436
|
+
"0xf57d4f7fee6ed178",
|
|
2437
|
+
"0x06f067aa72176fba",
|
|
2438
|
+
"0x0a637dc5a2c898a6",
|
|
2439
|
+
"0x113f9804bef90dae",
|
|
2440
|
+
"0x1b710b35131c471b",
|
|
2441
|
+
"0x28db77f523047d84",
|
|
2442
|
+
"0x32caab7b40c72493",
|
|
2443
|
+
"0x3c9ebe0a15c9bebc",
|
|
2444
|
+
"0x431d67c49c100d4c",
|
|
2445
|
+
"0x4cc5d4becb3e42b6",
|
|
2446
|
+
"0x597f299cfc657e2a",
|
|
2447
|
+
"0x5fcb6fab3ad6faec",
|
|
2448
|
+
"0x6c44198c4a475817"
|
|
2449
|
+
].map((n4) => BigInt(n4))))();
|
|
2450
|
+
const SHA512_Kh$1 = /* @__PURE__ */ (() => K512[0])();
|
|
2451
|
+
const SHA512_Kl$1 = /* @__PURE__ */ (() => K512[1])();
|
|
2452
|
+
const SHA512_W_H$1 = /* @__PURE__ */ new Uint32Array(80);
|
|
2453
|
+
const SHA512_W_L$1 = /* @__PURE__ */ new Uint32Array(80);
|
|
2454
|
+
let SHA512$1 = class SHA512 extends HashMD$1 {
|
|
2455
|
+
constructor(outputLen = 64) {
|
|
2456
|
+
super(128, outputLen, 16, false);
|
|
2457
|
+
this.Ah = SHA512_IV[0] | 0;
|
|
2458
|
+
this.Al = SHA512_IV[1] | 0;
|
|
2459
|
+
this.Bh = SHA512_IV[2] | 0;
|
|
2460
|
+
this.Bl = SHA512_IV[3] | 0;
|
|
2461
|
+
this.Ch = SHA512_IV[4] | 0;
|
|
2462
|
+
this.Cl = SHA512_IV[5] | 0;
|
|
2463
|
+
this.Dh = SHA512_IV[6] | 0;
|
|
2464
|
+
this.Dl = SHA512_IV[7] | 0;
|
|
2465
|
+
this.Eh = SHA512_IV[8] | 0;
|
|
2466
|
+
this.El = SHA512_IV[9] | 0;
|
|
2467
|
+
this.Fh = SHA512_IV[10] | 0;
|
|
2468
|
+
this.Fl = SHA512_IV[11] | 0;
|
|
2469
|
+
this.Gh = SHA512_IV[12] | 0;
|
|
2470
|
+
this.Gl = SHA512_IV[13] | 0;
|
|
2471
|
+
this.Hh = SHA512_IV[14] | 0;
|
|
2472
|
+
this.Hl = SHA512_IV[15] | 0;
|
|
2473
|
+
}
|
|
2474
|
+
// prettier-ignore
|
|
2475
|
+
get() {
|
|
2476
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
2477
|
+
return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
|
|
2478
|
+
}
|
|
2479
|
+
// prettier-ignore
|
|
2480
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
2481
|
+
this.Ah = Ah | 0;
|
|
2482
|
+
this.Al = Al | 0;
|
|
2483
|
+
this.Bh = Bh | 0;
|
|
2484
|
+
this.Bl = Bl | 0;
|
|
2485
|
+
this.Ch = Ch | 0;
|
|
2486
|
+
this.Cl = Cl | 0;
|
|
2487
|
+
this.Dh = Dh | 0;
|
|
2488
|
+
this.Dl = Dl | 0;
|
|
2489
|
+
this.Eh = Eh | 0;
|
|
2490
|
+
this.El = El | 0;
|
|
2491
|
+
this.Fh = Fh | 0;
|
|
2492
|
+
this.Fl = Fl | 0;
|
|
2493
|
+
this.Gh = Gh | 0;
|
|
2494
|
+
this.Gl = Gl | 0;
|
|
2495
|
+
this.Hh = Hh | 0;
|
|
2496
|
+
this.Hl = Hl | 0;
|
|
2497
|
+
}
|
|
2498
|
+
process(view, offset) {
|
|
2499
|
+
for (let i3 = 0; i3 < 16; i3++, offset += 4) {
|
|
2500
|
+
SHA512_W_H$1[i3] = view.getUint32(offset);
|
|
2501
|
+
SHA512_W_L$1[i3] = view.getUint32(offset += 4);
|
|
2502
|
+
}
|
|
2503
|
+
for (let i3 = 16; i3 < 80; i3++) {
|
|
2504
|
+
const W15h = SHA512_W_H$1[i3 - 15] | 0;
|
|
2505
|
+
const W15l = SHA512_W_L$1[i3 - 15] | 0;
|
|
2506
|
+
const s0h = rotrSH$1(W15h, W15l, 1) ^ rotrSH$1(W15h, W15l, 8) ^ shrSH$1(W15h, W15l, 7);
|
|
2507
|
+
const s0l = rotrSL$1(W15h, W15l, 1) ^ rotrSL$1(W15h, W15l, 8) ^ shrSL$1(W15h, W15l, 7);
|
|
2508
|
+
const W2h = SHA512_W_H$1[i3 - 2] | 0;
|
|
2509
|
+
const W2l = SHA512_W_L$1[i3 - 2] | 0;
|
|
2510
|
+
const s1h = rotrSH$1(W2h, W2l, 19) ^ rotrBH$1(W2h, W2l, 61) ^ shrSH$1(W2h, W2l, 6);
|
|
2511
|
+
const s1l = rotrSL$1(W2h, W2l, 19) ^ rotrBL$1(W2h, W2l, 61) ^ shrSL$1(W2h, W2l, 6);
|
|
2512
|
+
const SUMl = add4L$1(s0l, s1l, SHA512_W_L$1[i3 - 7], SHA512_W_L$1[i3 - 16]);
|
|
2513
|
+
const SUMh = add4H$1(SUMl, s0h, s1h, SHA512_W_H$1[i3 - 7], SHA512_W_H$1[i3 - 16]);
|
|
2514
|
+
SHA512_W_H$1[i3] = SUMh | 0;
|
|
2515
|
+
SHA512_W_L$1[i3] = SUMl | 0;
|
|
2516
|
+
}
|
|
2517
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
2518
|
+
for (let i3 = 0; i3 < 80; i3++) {
|
|
2519
|
+
const sigma1h = rotrSH$1(Eh, El, 14) ^ rotrSH$1(Eh, El, 18) ^ rotrBH$1(Eh, El, 41);
|
|
2520
|
+
const sigma1l = rotrSL$1(Eh, El, 14) ^ rotrSL$1(Eh, El, 18) ^ rotrBL$1(Eh, El, 41);
|
|
2521
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
2522
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
2523
|
+
const T1ll = add5L$1(Hl, sigma1l, CHIl, SHA512_Kl$1[i3], SHA512_W_L$1[i3]);
|
|
2524
|
+
const T1h = add5H$1(T1ll, Hh, sigma1h, CHIh, SHA512_Kh$1[i3], SHA512_W_H$1[i3]);
|
|
2525
|
+
const T1l = T1ll | 0;
|
|
2526
|
+
const sigma0h = rotrSH$1(Ah, Al, 28) ^ rotrBH$1(Ah, Al, 34) ^ rotrBH$1(Ah, Al, 39);
|
|
2527
|
+
const sigma0l = rotrSL$1(Ah, Al, 28) ^ rotrBL$1(Ah, Al, 34) ^ rotrBL$1(Ah, Al, 39);
|
|
2528
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
2529
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
2530
|
+
Hh = Gh | 0;
|
|
2531
|
+
Hl = Gl | 0;
|
|
2532
|
+
Gh = Fh | 0;
|
|
2533
|
+
Gl = Fl | 0;
|
|
2534
|
+
Fh = Eh | 0;
|
|
2535
|
+
Fl = El | 0;
|
|
2536
|
+
({ h: Eh, l: El } = add$1(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
2537
|
+
Dh = Ch | 0;
|
|
2538
|
+
Dl = Cl | 0;
|
|
2539
|
+
Ch = Bh | 0;
|
|
2540
|
+
Cl = Bl | 0;
|
|
2541
|
+
Bh = Ah | 0;
|
|
2542
|
+
Bl = Al | 0;
|
|
2543
|
+
const All = add3L$1(T1l, sigma0l, MAJl);
|
|
2544
|
+
Ah = add3H$1(All, T1h, sigma0h, MAJh);
|
|
2545
|
+
Al = All | 0;
|
|
2546
|
+
}
|
|
2547
|
+
({ h: Ah, l: Al } = add$1(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
2548
|
+
({ h: Bh, l: Bl } = add$1(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
2549
|
+
({ h: Ch, l: Cl } = add$1(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
2550
|
+
({ h: Dh, l: Dl } = add$1(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
2551
|
+
({ h: Eh, l: El } = add$1(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
2552
|
+
({ h: Fh, l: Fl } = add$1(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
2553
|
+
({ h: Gh, l: Gl } = add$1(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
2554
|
+
({ h: Hh, l: Hl } = add$1(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
2555
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
2556
|
+
}
|
|
2557
|
+
roundClean() {
|
|
2558
|
+
clean(SHA512_W_H$1, SHA512_W_L$1);
|
|
2559
|
+
}
|
|
2560
|
+
destroy() {
|
|
2561
|
+
clean(this.buffer);
|
|
2562
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
2563
|
+
}
|
|
2564
|
+
};
|
|
2237
2565
|
const sha256$1 = /* @__PURE__ */ createHasher(() => new SHA256$1());
|
|
2566
|
+
const sha512$1 = /* @__PURE__ */ createHasher(() => new SHA512$1());
|
|
2238
2567
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
2239
2568
|
function isBytes$4(a5) {
|
|
2240
2569
|
return a5 instanceof Uint8Array || ArrayBuffer.isView(a5) && a5.constructor.name === "Uint8Array";
|
|
@@ -4606,38 +4935,718 @@ zebra
|
|
|
4606
4935
|
zero
|
|
4607
4936
|
zone
|
|
4608
4937
|
zoo`.split("\n");
|
|
4609
|
-
|
|
4610
|
-
const
|
|
4611
|
-
const
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
const
|
|
4615
|
-
|
|
4616
|
-
const SHA3_ROTL$1 = [];
|
|
4617
|
-
const _SHA3_IOTA$1 = [];
|
|
4618
|
-
for (let round = 0, R2 = _1n$6, x2 = 1, y3 = 0; round < 24; round++) {
|
|
4619
|
-
[x2, y3] = [y3, (2 * x2 + 3 * y3) % 5];
|
|
4620
|
-
SHA3_PI$1.push(2 * (5 * y3 + x2));
|
|
4621
|
-
SHA3_ROTL$1.push((round + 1) * (round + 2) / 2 % 64);
|
|
4622
|
-
let t6 = _0n$5;
|
|
4623
|
-
for (let j = 0; j < 7; j++) {
|
|
4624
|
-
R2 = (R2 << _1n$6 ^ (R2 >> _7n$1) * _0x71n$1) % _256n$1;
|
|
4625
|
-
if (R2 & _2n$4)
|
|
4626
|
-
t6 ^= _1n$6 << (_1n$6 << /* @__PURE__ */ BigInt(j)) - _1n$6;
|
|
4938
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
4939
|
+
const _0n$a = /* @__PURE__ */ BigInt(0);
|
|
4940
|
+
const _1n$c = /* @__PURE__ */ BigInt(1);
|
|
4941
|
+
function _abool2(value, title = "") {
|
|
4942
|
+
if (typeof value !== "boolean") {
|
|
4943
|
+
const prefix = title && `"${title}"`;
|
|
4944
|
+
throw new Error(prefix + "expected boolean, got type=" + typeof value);
|
|
4627
4945
|
}
|
|
4628
|
-
|
|
4946
|
+
return value;
|
|
4629
4947
|
}
|
|
4630
|
-
|
|
4631
|
-
const
|
|
4632
|
-
const
|
|
4633
|
-
const
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4948
|
+
function _abytes2(value, length, title = "") {
|
|
4949
|
+
const bytes = isBytes$5(value);
|
|
4950
|
+
const len = value == null ? void 0 : value.length;
|
|
4951
|
+
const needsLen = length !== void 0;
|
|
4952
|
+
if (!bytes || needsLen && len !== length) {
|
|
4953
|
+
const prefix = title && `"${title}" `;
|
|
4954
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
4955
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
4956
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
4957
|
+
}
|
|
4958
|
+
return value;
|
|
4959
|
+
}
|
|
4960
|
+
function hexToNumber$1(hex) {
|
|
4961
|
+
if (typeof hex !== "string")
|
|
4962
|
+
throw new Error("hex string expected, got " + typeof hex);
|
|
4963
|
+
return hex === "" ? _0n$a : BigInt("0x" + hex);
|
|
4964
|
+
}
|
|
4965
|
+
function bytesToNumberBE$1(bytes) {
|
|
4966
|
+
return hexToNumber$1(bytesToHex$2(bytes));
|
|
4967
|
+
}
|
|
4968
|
+
function bytesToNumberLE$1(bytes) {
|
|
4969
|
+
abytes$2(bytes);
|
|
4970
|
+
return hexToNumber$1(bytesToHex$2(Uint8Array.from(bytes).reverse()));
|
|
4971
|
+
}
|
|
4972
|
+
function numberToBytesBE$1(n4, len) {
|
|
4973
|
+
return hexToBytes$2(n4.toString(16).padStart(len * 2, "0"));
|
|
4974
|
+
}
|
|
4975
|
+
function numberToBytesLE$1(n4, len) {
|
|
4976
|
+
return numberToBytesBE$1(n4, len).reverse();
|
|
4977
|
+
}
|
|
4978
|
+
function ensureBytes$1(title, hex, expectedLength) {
|
|
4979
|
+
let res;
|
|
4980
|
+
if (typeof hex === "string") {
|
|
4981
|
+
try {
|
|
4982
|
+
res = hexToBytes$2(hex);
|
|
4983
|
+
} catch (e4) {
|
|
4984
|
+
throw new Error(title + " must be hex string or Uint8Array, cause: " + e4);
|
|
4985
|
+
}
|
|
4986
|
+
} else if (isBytes$5(hex)) {
|
|
4987
|
+
res = Uint8Array.from(hex);
|
|
4988
|
+
} else {
|
|
4989
|
+
throw new Error(title + " must be hex string or Uint8Array");
|
|
4990
|
+
}
|
|
4991
|
+
const len = res.length;
|
|
4992
|
+
if (typeof expectedLength === "number" && len !== expectedLength)
|
|
4993
|
+
throw new Error(title + " of length " + expectedLength + " expected, got " + len);
|
|
4994
|
+
return res;
|
|
4995
|
+
}
|
|
4996
|
+
function copyBytes(bytes) {
|
|
4997
|
+
return Uint8Array.from(bytes);
|
|
4998
|
+
}
|
|
4999
|
+
const isPosBig$1 = (n4) => typeof n4 === "bigint" && _0n$a <= n4;
|
|
5000
|
+
function inRange$1(n4, min, max) {
|
|
5001
|
+
return isPosBig$1(n4) && isPosBig$1(min) && isPosBig$1(max) && min <= n4 && n4 < max;
|
|
5002
|
+
}
|
|
5003
|
+
function aInRange$1(title, n4, min, max) {
|
|
5004
|
+
if (!inRange$1(n4, min, max))
|
|
5005
|
+
throw new Error("expected valid " + title + ": " + min + " <= n < " + max + ", got " + n4);
|
|
5006
|
+
}
|
|
5007
|
+
function bitLen$1(n4) {
|
|
5008
|
+
let len;
|
|
5009
|
+
for (len = 0; n4 > _0n$a; n4 >>= _1n$c, len += 1)
|
|
5010
|
+
;
|
|
5011
|
+
return len;
|
|
5012
|
+
}
|
|
5013
|
+
const bitMask$1 = (n4) => (_1n$c << BigInt(n4)) - _1n$c;
|
|
5014
|
+
function _validateObject(object, fields, optFields = {}) {
|
|
5015
|
+
if (!object || typeof object !== "object")
|
|
5016
|
+
throw new Error("expected valid options object");
|
|
5017
|
+
function checkField(fieldName, expectedType, isOpt) {
|
|
5018
|
+
const val = object[fieldName];
|
|
5019
|
+
if (isOpt && val === void 0)
|
|
5020
|
+
return;
|
|
5021
|
+
const current = typeof val;
|
|
5022
|
+
if (current !== expectedType || val === null)
|
|
5023
|
+
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
5024
|
+
}
|
|
5025
|
+
Object.entries(fields).forEach(([k2, v2]) => checkField(k2, v2, false));
|
|
5026
|
+
Object.entries(optFields).forEach(([k2, v2]) => checkField(k2, v2, true));
|
|
5027
|
+
}
|
|
5028
|
+
function memoized$1(fn) {
|
|
5029
|
+
const map = /* @__PURE__ */ new WeakMap();
|
|
5030
|
+
return (arg, ...args) => {
|
|
5031
|
+
const val = map.get(arg);
|
|
5032
|
+
if (val !== void 0)
|
|
5033
|
+
return val;
|
|
5034
|
+
const computed = fn(arg, ...args);
|
|
5035
|
+
map.set(arg, computed);
|
|
5036
|
+
return computed;
|
|
5037
|
+
};
|
|
5038
|
+
}
|
|
5039
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5040
|
+
const _0n$9 = BigInt(0), _1n$b = BigInt(1), _2n$8 = /* @__PURE__ */ BigInt(2), _3n$3 = /* @__PURE__ */ BigInt(3);
|
|
5041
|
+
const _4n$1 = /* @__PURE__ */ BigInt(4), _5n$2 = /* @__PURE__ */ BigInt(5), _7n$2 = /* @__PURE__ */ BigInt(7);
|
|
5042
|
+
const _8n$3 = /* @__PURE__ */ BigInt(8), _9n = /* @__PURE__ */ BigInt(9), _16n = /* @__PURE__ */ BigInt(16);
|
|
5043
|
+
function mod$1(a5, b2) {
|
|
5044
|
+
const result = a5 % b2;
|
|
5045
|
+
return result >= _0n$9 ? result : b2 + result;
|
|
5046
|
+
}
|
|
5047
|
+
function pow2$1(x2, power, modulo) {
|
|
5048
|
+
let res = x2;
|
|
5049
|
+
while (power-- > _0n$9) {
|
|
5050
|
+
res *= res;
|
|
5051
|
+
res %= modulo;
|
|
5052
|
+
}
|
|
5053
|
+
return res;
|
|
5054
|
+
}
|
|
5055
|
+
function invert$1(number, modulo) {
|
|
5056
|
+
if (number === _0n$9)
|
|
5057
|
+
throw new Error("invert: expected non-zero number");
|
|
5058
|
+
if (modulo <= _0n$9)
|
|
5059
|
+
throw new Error("invert: expected positive modulus, got " + modulo);
|
|
5060
|
+
let a5 = mod$1(number, modulo);
|
|
5061
|
+
let b2 = modulo;
|
|
5062
|
+
let x2 = _0n$9, u4 = _1n$b;
|
|
5063
|
+
while (a5 !== _0n$9) {
|
|
5064
|
+
const q2 = b2 / a5;
|
|
5065
|
+
const r7 = b2 % a5;
|
|
5066
|
+
const m2 = x2 - u4 * q2;
|
|
5067
|
+
b2 = a5, a5 = r7, x2 = u4, u4 = m2;
|
|
5068
|
+
}
|
|
5069
|
+
const gcd2 = b2;
|
|
5070
|
+
if (gcd2 !== _1n$b)
|
|
5071
|
+
throw new Error("invert: does not exist");
|
|
5072
|
+
return mod$1(x2, modulo);
|
|
5073
|
+
}
|
|
5074
|
+
function assertIsSquare(Fp2, root2, n4) {
|
|
5075
|
+
if (!Fp2.eql(Fp2.sqr(root2), n4))
|
|
5076
|
+
throw new Error("Cannot find square root");
|
|
5077
|
+
}
|
|
5078
|
+
function sqrt3mod4(Fp2, n4) {
|
|
5079
|
+
const p1div4 = (Fp2.ORDER + _1n$b) / _4n$1;
|
|
5080
|
+
const root2 = Fp2.pow(n4, p1div4);
|
|
5081
|
+
assertIsSquare(Fp2, root2, n4);
|
|
5082
|
+
return root2;
|
|
5083
|
+
}
|
|
5084
|
+
function sqrt5mod8(Fp2, n4) {
|
|
5085
|
+
const p5div8 = (Fp2.ORDER - _5n$2) / _8n$3;
|
|
5086
|
+
const n22 = Fp2.mul(n4, _2n$8);
|
|
5087
|
+
const v2 = Fp2.pow(n22, p5div8);
|
|
5088
|
+
const nv = Fp2.mul(n4, v2);
|
|
5089
|
+
const i3 = Fp2.mul(Fp2.mul(nv, _2n$8), v2);
|
|
5090
|
+
const root2 = Fp2.mul(nv, Fp2.sub(i3, Fp2.ONE));
|
|
5091
|
+
assertIsSquare(Fp2, root2, n4);
|
|
5092
|
+
return root2;
|
|
5093
|
+
}
|
|
5094
|
+
function sqrt9mod16(P2) {
|
|
5095
|
+
const Fp_ = Field$1(P2);
|
|
5096
|
+
const tn = tonelliShanks$1(P2);
|
|
5097
|
+
const c1 = tn(Fp_, Fp_.neg(Fp_.ONE));
|
|
5098
|
+
const c22 = tn(Fp_, c1);
|
|
5099
|
+
const c3 = tn(Fp_, Fp_.neg(c1));
|
|
5100
|
+
const c4 = (P2 + _7n$2) / _16n;
|
|
5101
|
+
return (Fp2, n4) => {
|
|
5102
|
+
let tv1 = Fp2.pow(n4, c4);
|
|
5103
|
+
let tv2 = Fp2.mul(tv1, c1);
|
|
5104
|
+
const tv3 = Fp2.mul(tv1, c22);
|
|
5105
|
+
const tv4 = Fp2.mul(tv1, c3);
|
|
5106
|
+
const e1 = Fp2.eql(Fp2.sqr(tv2), n4);
|
|
5107
|
+
const e22 = Fp2.eql(Fp2.sqr(tv3), n4);
|
|
5108
|
+
tv1 = Fp2.cmov(tv1, tv2, e1);
|
|
5109
|
+
tv2 = Fp2.cmov(tv4, tv3, e22);
|
|
5110
|
+
const e32 = Fp2.eql(Fp2.sqr(tv2), n4);
|
|
5111
|
+
const root2 = Fp2.cmov(tv1, tv2, e32);
|
|
5112
|
+
assertIsSquare(Fp2, root2, n4);
|
|
5113
|
+
return root2;
|
|
5114
|
+
};
|
|
5115
|
+
}
|
|
5116
|
+
function tonelliShanks$1(P2) {
|
|
5117
|
+
if (P2 < _3n$3)
|
|
5118
|
+
throw new Error("sqrt is not defined for small field");
|
|
5119
|
+
let Q = P2 - _1n$b;
|
|
5120
|
+
let S2 = 0;
|
|
5121
|
+
while (Q % _2n$8 === _0n$9) {
|
|
5122
|
+
Q /= _2n$8;
|
|
5123
|
+
S2++;
|
|
5124
|
+
}
|
|
5125
|
+
let Z = _2n$8;
|
|
5126
|
+
const _Fp = Field$1(P2);
|
|
5127
|
+
while (FpLegendre(_Fp, Z) === 1) {
|
|
5128
|
+
if (Z++ > 1e3)
|
|
5129
|
+
throw new Error("Cannot find square root: probably non-prime P");
|
|
5130
|
+
}
|
|
5131
|
+
if (S2 === 1)
|
|
5132
|
+
return sqrt3mod4;
|
|
5133
|
+
let cc = _Fp.pow(Z, Q);
|
|
5134
|
+
const Q1div2 = (Q + _1n$b) / _2n$8;
|
|
5135
|
+
return function tonelliSlow(Fp2, n4) {
|
|
5136
|
+
if (Fp2.is0(n4))
|
|
5137
|
+
return n4;
|
|
5138
|
+
if (FpLegendre(Fp2, n4) !== 1)
|
|
5139
|
+
throw new Error("Cannot find square root");
|
|
5140
|
+
let M2 = S2;
|
|
5141
|
+
let c3 = Fp2.mul(Fp2.ONE, cc);
|
|
5142
|
+
let t6 = Fp2.pow(n4, Q);
|
|
5143
|
+
let R2 = Fp2.pow(n4, Q1div2);
|
|
5144
|
+
while (!Fp2.eql(t6, Fp2.ONE)) {
|
|
5145
|
+
if (Fp2.is0(t6))
|
|
5146
|
+
return Fp2.ZERO;
|
|
5147
|
+
let i3 = 1;
|
|
5148
|
+
let t_tmp = Fp2.sqr(t6);
|
|
5149
|
+
while (!Fp2.eql(t_tmp, Fp2.ONE)) {
|
|
5150
|
+
i3++;
|
|
5151
|
+
t_tmp = Fp2.sqr(t_tmp);
|
|
5152
|
+
if (i3 === M2)
|
|
5153
|
+
throw new Error("Cannot find square root");
|
|
5154
|
+
}
|
|
5155
|
+
const exponent = _1n$b << BigInt(M2 - i3 - 1);
|
|
5156
|
+
const b2 = Fp2.pow(c3, exponent);
|
|
5157
|
+
M2 = i3;
|
|
5158
|
+
c3 = Fp2.sqr(b2);
|
|
5159
|
+
t6 = Fp2.mul(t6, c3);
|
|
5160
|
+
R2 = Fp2.mul(R2, b2);
|
|
5161
|
+
}
|
|
5162
|
+
return R2;
|
|
5163
|
+
};
|
|
5164
|
+
}
|
|
5165
|
+
function FpSqrt$1(P2) {
|
|
5166
|
+
if (P2 % _4n$1 === _3n$3)
|
|
5167
|
+
return sqrt3mod4;
|
|
5168
|
+
if (P2 % _8n$3 === _5n$2)
|
|
5169
|
+
return sqrt5mod8;
|
|
5170
|
+
if (P2 % _16n === _9n)
|
|
5171
|
+
return sqrt9mod16(P2);
|
|
5172
|
+
return tonelliShanks$1(P2);
|
|
5173
|
+
}
|
|
5174
|
+
const isNegativeLE = (num, modulo) => (mod$1(num, modulo) & _1n$b) === _1n$b;
|
|
5175
|
+
const FIELD_FIELDS$1 = [
|
|
5176
|
+
"create",
|
|
5177
|
+
"isValid",
|
|
5178
|
+
"is0",
|
|
5179
|
+
"neg",
|
|
5180
|
+
"inv",
|
|
5181
|
+
"sqrt",
|
|
5182
|
+
"sqr",
|
|
5183
|
+
"eql",
|
|
5184
|
+
"add",
|
|
5185
|
+
"sub",
|
|
5186
|
+
"mul",
|
|
5187
|
+
"pow",
|
|
5188
|
+
"div",
|
|
5189
|
+
"addN",
|
|
5190
|
+
"subN",
|
|
5191
|
+
"mulN",
|
|
5192
|
+
"sqrN"
|
|
5193
|
+
];
|
|
5194
|
+
function validateField$1(field) {
|
|
5195
|
+
const initial = {
|
|
5196
|
+
ORDER: "bigint",
|
|
5197
|
+
MASK: "bigint",
|
|
5198
|
+
BYTES: "number",
|
|
5199
|
+
BITS: "number"
|
|
5200
|
+
};
|
|
5201
|
+
const opts = FIELD_FIELDS$1.reduce((map, val) => {
|
|
5202
|
+
map[val] = "function";
|
|
5203
|
+
return map;
|
|
5204
|
+
}, initial);
|
|
5205
|
+
_validateObject(field, opts);
|
|
5206
|
+
return field;
|
|
5207
|
+
}
|
|
5208
|
+
function FpPow$1(Fp2, num, power) {
|
|
5209
|
+
if (power < _0n$9)
|
|
5210
|
+
throw new Error("invalid exponent, negatives unsupported");
|
|
5211
|
+
if (power === _0n$9)
|
|
5212
|
+
return Fp2.ONE;
|
|
5213
|
+
if (power === _1n$b)
|
|
5214
|
+
return num;
|
|
5215
|
+
let p5 = Fp2.ONE;
|
|
5216
|
+
let d2 = num;
|
|
5217
|
+
while (power > _0n$9) {
|
|
5218
|
+
if (power & _1n$b)
|
|
5219
|
+
p5 = Fp2.mul(p5, d2);
|
|
5220
|
+
d2 = Fp2.sqr(d2);
|
|
5221
|
+
power >>= _1n$b;
|
|
5222
|
+
}
|
|
5223
|
+
return p5;
|
|
5224
|
+
}
|
|
5225
|
+
function FpInvertBatch$1(Fp2, nums, passZero = false) {
|
|
5226
|
+
const inverted = new Array(nums.length).fill(passZero ? Fp2.ZERO : void 0);
|
|
5227
|
+
const multipliedAcc = nums.reduce((acc, num, i3) => {
|
|
5228
|
+
if (Fp2.is0(num))
|
|
5229
|
+
return acc;
|
|
5230
|
+
inverted[i3] = acc;
|
|
5231
|
+
return Fp2.mul(acc, num);
|
|
5232
|
+
}, Fp2.ONE);
|
|
5233
|
+
const invertedAcc = Fp2.inv(multipliedAcc);
|
|
5234
|
+
nums.reduceRight((acc, num, i3) => {
|
|
5235
|
+
if (Fp2.is0(num))
|
|
5236
|
+
return acc;
|
|
5237
|
+
inverted[i3] = Fp2.mul(acc, inverted[i3]);
|
|
5238
|
+
return Fp2.mul(acc, num);
|
|
5239
|
+
}, invertedAcc);
|
|
5240
|
+
return inverted;
|
|
5241
|
+
}
|
|
5242
|
+
function FpLegendre(Fp2, n4) {
|
|
5243
|
+
const p1mod2 = (Fp2.ORDER - _1n$b) / _2n$8;
|
|
5244
|
+
const powered = Fp2.pow(n4, p1mod2);
|
|
5245
|
+
const yes = Fp2.eql(powered, Fp2.ONE);
|
|
5246
|
+
const zero = Fp2.eql(powered, Fp2.ZERO);
|
|
5247
|
+
const no = Fp2.eql(powered, Fp2.neg(Fp2.ONE));
|
|
5248
|
+
if (!yes && !zero && !no)
|
|
5249
|
+
throw new Error("invalid Legendre symbol result");
|
|
5250
|
+
return yes ? 1 : zero ? 0 : -1;
|
|
5251
|
+
}
|
|
5252
|
+
function nLength$1(n4, nBitLength) {
|
|
5253
|
+
if (nBitLength !== void 0)
|
|
5254
|
+
anumber$3(nBitLength);
|
|
5255
|
+
const _nBitLength = nBitLength !== void 0 ? nBitLength : n4.toString(2).length;
|
|
5256
|
+
const nByteLength = Math.ceil(_nBitLength / 8);
|
|
5257
|
+
return { nBitLength: _nBitLength, nByteLength };
|
|
5258
|
+
}
|
|
5259
|
+
function Field$1(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
|
|
5260
|
+
if (ORDER <= _0n$9)
|
|
5261
|
+
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
|
5262
|
+
let _nbitLength = void 0;
|
|
5263
|
+
let _sqrt = void 0;
|
|
5264
|
+
let modFromBytes = false;
|
|
5265
|
+
let allowedLengths = void 0;
|
|
5266
|
+
if (typeof bitLenOrOpts === "object" && bitLenOrOpts != null) {
|
|
5267
|
+
if (opts.sqrt || isLE2)
|
|
5268
|
+
throw new Error("cannot specify opts in two arguments");
|
|
5269
|
+
const _opts = bitLenOrOpts;
|
|
5270
|
+
if (_opts.BITS)
|
|
5271
|
+
_nbitLength = _opts.BITS;
|
|
5272
|
+
if (_opts.sqrt)
|
|
5273
|
+
_sqrt = _opts.sqrt;
|
|
5274
|
+
if (typeof _opts.isLE === "boolean")
|
|
5275
|
+
isLE2 = _opts.isLE;
|
|
5276
|
+
if (typeof _opts.modFromBytes === "boolean")
|
|
5277
|
+
modFromBytes = _opts.modFromBytes;
|
|
5278
|
+
allowedLengths = _opts.allowedLengths;
|
|
5279
|
+
} else {
|
|
5280
|
+
if (typeof bitLenOrOpts === "number")
|
|
5281
|
+
_nbitLength = bitLenOrOpts;
|
|
5282
|
+
if (opts.sqrt)
|
|
5283
|
+
_sqrt = opts.sqrt;
|
|
5284
|
+
}
|
|
5285
|
+
const { nBitLength: BITS, nByteLength: BYTES } = nLength$1(ORDER, _nbitLength);
|
|
5286
|
+
if (BYTES > 2048)
|
|
5287
|
+
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
5288
|
+
let sqrtP;
|
|
5289
|
+
const f3 = Object.freeze({
|
|
5290
|
+
ORDER,
|
|
5291
|
+
isLE: isLE2,
|
|
5292
|
+
BITS,
|
|
5293
|
+
BYTES,
|
|
5294
|
+
MASK: bitMask$1(BITS),
|
|
5295
|
+
ZERO: _0n$9,
|
|
5296
|
+
ONE: _1n$b,
|
|
5297
|
+
allowedLengths,
|
|
5298
|
+
create: (num) => mod$1(num, ORDER),
|
|
5299
|
+
isValid: (num) => {
|
|
5300
|
+
if (typeof num !== "bigint")
|
|
5301
|
+
throw new Error("invalid field element: expected bigint, got " + typeof num);
|
|
5302
|
+
return _0n$9 <= num && num < ORDER;
|
|
5303
|
+
},
|
|
5304
|
+
is0: (num) => num === _0n$9,
|
|
5305
|
+
// is valid and invertible
|
|
5306
|
+
isValidNot0: (num) => !f3.is0(num) && f3.isValid(num),
|
|
5307
|
+
isOdd: (num) => (num & _1n$b) === _1n$b,
|
|
5308
|
+
neg: (num) => mod$1(-num, ORDER),
|
|
5309
|
+
eql: (lhs, rhs) => lhs === rhs,
|
|
5310
|
+
sqr: (num) => mod$1(num * num, ORDER),
|
|
5311
|
+
add: (lhs, rhs) => mod$1(lhs + rhs, ORDER),
|
|
5312
|
+
sub: (lhs, rhs) => mod$1(lhs - rhs, ORDER),
|
|
5313
|
+
mul: (lhs, rhs) => mod$1(lhs * rhs, ORDER),
|
|
5314
|
+
pow: (num, power) => FpPow$1(f3, num, power),
|
|
5315
|
+
div: (lhs, rhs) => mod$1(lhs * invert$1(rhs, ORDER), ORDER),
|
|
5316
|
+
// Same as above, but doesn't normalize
|
|
5317
|
+
sqrN: (num) => num * num,
|
|
5318
|
+
addN: (lhs, rhs) => lhs + rhs,
|
|
5319
|
+
subN: (lhs, rhs) => lhs - rhs,
|
|
5320
|
+
mulN: (lhs, rhs) => lhs * rhs,
|
|
5321
|
+
inv: (num) => invert$1(num, ORDER),
|
|
5322
|
+
sqrt: _sqrt || ((n4) => {
|
|
5323
|
+
if (!sqrtP)
|
|
5324
|
+
sqrtP = FpSqrt$1(ORDER);
|
|
5325
|
+
return sqrtP(f3, n4);
|
|
5326
|
+
}),
|
|
5327
|
+
toBytes: (num) => isLE2 ? numberToBytesLE$1(num, BYTES) : numberToBytesBE$1(num, BYTES),
|
|
5328
|
+
fromBytes: (bytes, skipValidation = true) => {
|
|
5329
|
+
if (allowedLengths) {
|
|
5330
|
+
if (!allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
|
|
5331
|
+
throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
|
|
5332
|
+
}
|
|
5333
|
+
const padded = new Uint8Array(BYTES);
|
|
5334
|
+
padded.set(bytes, isLE2 ? 0 : padded.length - bytes.length);
|
|
5335
|
+
bytes = padded;
|
|
5336
|
+
}
|
|
5337
|
+
if (bytes.length !== BYTES)
|
|
5338
|
+
throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
|
|
5339
|
+
let scalar = isLE2 ? bytesToNumberLE$1(bytes) : bytesToNumberBE$1(bytes);
|
|
5340
|
+
if (modFromBytes)
|
|
5341
|
+
scalar = mod$1(scalar, ORDER);
|
|
5342
|
+
if (!skipValidation) {
|
|
5343
|
+
if (!f3.isValid(scalar))
|
|
5344
|
+
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
5345
|
+
}
|
|
5346
|
+
return scalar;
|
|
5347
|
+
},
|
|
5348
|
+
// TODO: we don't need it here, move out to separate fn
|
|
5349
|
+
invertBatch: (lst) => FpInvertBatch$1(f3, lst),
|
|
5350
|
+
// We can't move this out because Fp6, Fp12 implement it
|
|
5351
|
+
// and it's unclear what to return in there.
|
|
5352
|
+
cmov: (a5, b2, c3) => c3 ? b2 : a5
|
|
5353
|
+
});
|
|
5354
|
+
return Object.freeze(f3);
|
|
5355
|
+
}
|
|
5356
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5357
|
+
const _0n$8 = BigInt(0);
|
|
5358
|
+
const _1n$a = BigInt(1);
|
|
5359
|
+
function negateCt(condition, item) {
|
|
5360
|
+
const neg = item.negate();
|
|
5361
|
+
return condition ? neg : item;
|
|
5362
|
+
}
|
|
5363
|
+
function normalizeZ(c3, points) {
|
|
5364
|
+
const invertedZs = FpInvertBatch$1(c3.Fp, points.map((p5) => p5.Z));
|
|
5365
|
+
return points.map((p5, i3) => c3.fromAffine(p5.toAffine(invertedZs[i3])));
|
|
5366
|
+
}
|
|
5367
|
+
function validateW$1(W2, bits) {
|
|
5368
|
+
if (!Number.isSafeInteger(W2) || W2 <= 0 || W2 > bits)
|
|
5369
|
+
throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W2);
|
|
5370
|
+
}
|
|
5371
|
+
function calcWOpts$1(W2, scalarBits) {
|
|
5372
|
+
validateW$1(W2, scalarBits);
|
|
5373
|
+
const windows = Math.ceil(scalarBits / W2) + 1;
|
|
5374
|
+
const windowSize = 2 ** (W2 - 1);
|
|
5375
|
+
const maxNumber = 2 ** W2;
|
|
5376
|
+
const mask = bitMask$1(W2);
|
|
5377
|
+
const shiftBy = BigInt(W2);
|
|
5378
|
+
return { windows, windowSize, mask, maxNumber, shiftBy };
|
|
5379
|
+
}
|
|
5380
|
+
function calcOffsets(n4, window2, wOpts) {
|
|
5381
|
+
const { windowSize, mask, maxNumber, shiftBy } = wOpts;
|
|
5382
|
+
let wbits = Number(n4 & mask);
|
|
5383
|
+
let nextN = n4 >> shiftBy;
|
|
5384
|
+
if (wbits > windowSize) {
|
|
5385
|
+
wbits -= maxNumber;
|
|
5386
|
+
nextN += _1n$a;
|
|
5387
|
+
}
|
|
5388
|
+
const offsetStart = window2 * windowSize;
|
|
5389
|
+
const offset = offsetStart + Math.abs(wbits) - 1;
|
|
5390
|
+
const isZero = wbits === 0;
|
|
5391
|
+
const isNeg = wbits < 0;
|
|
5392
|
+
const isNegF = window2 % 2 !== 0;
|
|
5393
|
+
const offsetF = offsetStart;
|
|
5394
|
+
return { nextN, offset, isZero, isNeg, isNegF, offsetF };
|
|
5395
|
+
}
|
|
5396
|
+
function validateMSMPoints$1(points, c3) {
|
|
5397
|
+
if (!Array.isArray(points))
|
|
5398
|
+
throw new Error("array expected");
|
|
5399
|
+
points.forEach((p5, i3) => {
|
|
5400
|
+
if (!(p5 instanceof c3))
|
|
5401
|
+
throw new Error("invalid point at index " + i3);
|
|
5402
|
+
});
|
|
5403
|
+
}
|
|
5404
|
+
function validateMSMScalars$1(scalars, field) {
|
|
5405
|
+
if (!Array.isArray(scalars))
|
|
5406
|
+
throw new Error("array of scalars expected");
|
|
5407
|
+
scalars.forEach((s5, i3) => {
|
|
5408
|
+
if (!field.isValid(s5))
|
|
5409
|
+
throw new Error("invalid scalar at index " + i3);
|
|
5410
|
+
});
|
|
5411
|
+
}
|
|
5412
|
+
const pointPrecomputes$1 = /* @__PURE__ */ new WeakMap();
|
|
5413
|
+
const pointWindowSizes$1 = /* @__PURE__ */ new WeakMap();
|
|
5414
|
+
function getW$1(P2) {
|
|
5415
|
+
return pointWindowSizes$1.get(P2) || 1;
|
|
5416
|
+
}
|
|
5417
|
+
function assert0(n4) {
|
|
5418
|
+
if (n4 !== _0n$8)
|
|
5419
|
+
throw new Error("invalid wNAF");
|
|
5420
|
+
}
|
|
5421
|
+
let wNAF$2 = class wNAF {
|
|
5422
|
+
// Parametrized with a given Point class (not individual point)
|
|
5423
|
+
constructor(Point3, bits) {
|
|
5424
|
+
this.BASE = Point3.BASE;
|
|
5425
|
+
this.ZERO = Point3.ZERO;
|
|
5426
|
+
this.Fn = Point3.Fn;
|
|
5427
|
+
this.bits = bits;
|
|
5428
|
+
}
|
|
5429
|
+
// non-const time multiplication ladder
|
|
5430
|
+
_unsafeLadder(elm, n4, p5 = this.ZERO) {
|
|
5431
|
+
let d2 = elm;
|
|
5432
|
+
while (n4 > _0n$8) {
|
|
5433
|
+
if (n4 & _1n$a)
|
|
5434
|
+
p5 = p5.add(d2);
|
|
5435
|
+
d2 = d2.double();
|
|
5436
|
+
n4 >>= _1n$a;
|
|
5437
|
+
}
|
|
5438
|
+
return p5;
|
|
5439
|
+
}
|
|
5440
|
+
/**
|
|
5441
|
+
* Creates a wNAF precomputation window. Used for caching.
|
|
5442
|
+
* Default window size is set by `utils.precompute()` and is equal to 8.
|
|
5443
|
+
* Number of precomputed points depends on the curve size:
|
|
5444
|
+
* 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
|
|
5445
|
+
* - 𝑊 is the window size
|
|
5446
|
+
* - 𝑛 is the bitlength of the curve order.
|
|
5447
|
+
* For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
|
|
5448
|
+
* @param point Point instance
|
|
5449
|
+
* @param W window size
|
|
5450
|
+
* @returns precomputed point tables flattened to a single array
|
|
5451
|
+
*/
|
|
5452
|
+
precomputeWindow(point, W2) {
|
|
5453
|
+
const { windows, windowSize } = calcWOpts$1(W2, this.bits);
|
|
5454
|
+
const points = [];
|
|
5455
|
+
let p5 = point;
|
|
5456
|
+
let base = p5;
|
|
5457
|
+
for (let window2 = 0; window2 < windows; window2++) {
|
|
5458
|
+
base = p5;
|
|
5459
|
+
points.push(base);
|
|
5460
|
+
for (let i3 = 1; i3 < windowSize; i3++) {
|
|
5461
|
+
base = base.add(p5);
|
|
5462
|
+
points.push(base);
|
|
5463
|
+
}
|
|
5464
|
+
p5 = base.double();
|
|
5465
|
+
}
|
|
5466
|
+
return points;
|
|
5467
|
+
}
|
|
5468
|
+
/**
|
|
5469
|
+
* Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
|
|
5470
|
+
* More compact implementation:
|
|
5471
|
+
* https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541
|
|
5472
|
+
* @returns real and fake (for const-time) points
|
|
5473
|
+
*/
|
|
5474
|
+
wNAF(W2, precomputes, n4) {
|
|
5475
|
+
if (!this.Fn.isValid(n4))
|
|
5476
|
+
throw new Error("invalid scalar");
|
|
5477
|
+
let p5 = this.ZERO;
|
|
5478
|
+
let f3 = this.BASE;
|
|
5479
|
+
const wo = calcWOpts$1(W2, this.bits);
|
|
5480
|
+
for (let window2 = 0; window2 < wo.windows; window2++) {
|
|
5481
|
+
const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n4, window2, wo);
|
|
5482
|
+
n4 = nextN;
|
|
5483
|
+
if (isZero) {
|
|
5484
|
+
f3 = f3.add(negateCt(isNegF, precomputes[offsetF]));
|
|
5485
|
+
} else {
|
|
5486
|
+
p5 = p5.add(negateCt(isNeg, precomputes[offset]));
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
assert0(n4);
|
|
5490
|
+
return { p: p5, f: f3 };
|
|
5491
|
+
}
|
|
5492
|
+
/**
|
|
5493
|
+
* Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
|
|
5494
|
+
* @param acc accumulator point to add result of multiplication
|
|
5495
|
+
* @returns point
|
|
5496
|
+
*/
|
|
5497
|
+
wNAFUnsafe(W2, precomputes, n4, acc = this.ZERO) {
|
|
5498
|
+
const wo = calcWOpts$1(W2, this.bits);
|
|
5499
|
+
for (let window2 = 0; window2 < wo.windows; window2++) {
|
|
5500
|
+
if (n4 === _0n$8)
|
|
5501
|
+
break;
|
|
5502
|
+
const { nextN, offset, isZero, isNeg } = calcOffsets(n4, window2, wo);
|
|
5503
|
+
n4 = nextN;
|
|
5504
|
+
if (isZero) {
|
|
5505
|
+
continue;
|
|
5506
|
+
} else {
|
|
5507
|
+
const item = precomputes[offset];
|
|
5508
|
+
acc = acc.add(isNeg ? item.negate() : item);
|
|
5509
|
+
}
|
|
5510
|
+
}
|
|
5511
|
+
assert0(n4);
|
|
5512
|
+
return acc;
|
|
5513
|
+
}
|
|
5514
|
+
getPrecomputes(W2, point, transform) {
|
|
5515
|
+
let comp = pointPrecomputes$1.get(point);
|
|
5516
|
+
if (!comp) {
|
|
5517
|
+
comp = this.precomputeWindow(point, W2);
|
|
5518
|
+
if (W2 !== 1) {
|
|
5519
|
+
if (typeof transform === "function")
|
|
5520
|
+
comp = transform(comp);
|
|
5521
|
+
pointPrecomputes$1.set(point, comp);
|
|
5522
|
+
}
|
|
5523
|
+
}
|
|
5524
|
+
return comp;
|
|
5525
|
+
}
|
|
5526
|
+
cached(point, scalar, transform) {
|
|
5527
|
+
const W2 = getW$1(point);
|
|
5528
|
+
return this.wNAF(W2, this.getPrecomputes(W2, point, transform), scalar);
|
|
5529
|
+
}
|
|
5530
|
+
unsafe(point, scalar, transform, prev) {
|
|
5531
|
+
const W2 = getW$1(point);
|
|
5532
|
+
if (W2 === 1)
|
|
5533
|
+
return this._unsafeLadder(point, scalar, prev);
|
|
5534
|
+
return this.wNAFUnsafe(W2, this.getPrecomputes(W2, point, transform), scalar, prev);
|
|
5535
|
+
}
|
|
5536
|
+
// We calculate precomputes for elliptic curve point multiplication
|
|
5537
|
+
// using windowed method. This specifies window size and
|
|
5538
|
+
// stores precomputed values. Usually only base point would be precomputed.
|
|
5539
|
+
createCache(P2, W2) {
|
|
5540
|
+
validateW$1(W2, this.bits);
|
|
5541
|
+
pointWindowSizes$1.set(P2, W2);
|
|
5542
|
+
pointPrecomputes$1.delete(P2);
|
|
5543
|
+
}
|
|
5544
|
+
hasCache(elm) {
|
|
5545
|
+
return getW$1(elm) !== 1;
|
|
5546
|
+
}
|
|
5547
|
+
};
|
|
5548
|
+
function pippenger$1(c3, fieldN, points, scalars) {
|
|
5549
|
+
validateMSMPoints$1(points, c3);
|
|
5550
|
+
validateMSMScalars$1(scalars, fieldN);
|
|
5551
|
+
const plength = points.length;
|
|
5552
|
+
const slength = scalars.length;
|
|
5553
|
+
if (plength !== slength)
|
|
5554
|
+
throw new Error("arrays of points and scalars must have equal length");
|
|
5555
|
+
const zero = c3.ZERO;
|
|
5556
|
+
const wbits = bitLen$1(BigInt(plength));
|
|
5557
|
+
let windowSize = 1;
|
|
5558
|
+
if (wbits > 12)
|
|
5559
|
+
windowSize = wbits - 3;
|
|
5560
|
+
else if (wbits > 4)
|
|
5561
|
+
windowSize = wbits - 2;
|
|
5562
|
+
else if (wbits > 0)
|
|
5563
|
+
windowSize = 2;
|
|
5564
|
+
const MASK = bitMask$1(windowSize);
|
|
5565
|
+
const buckets = new Array(Number(MASK) + 1).fill(zero);
|
|
5566
|
+
const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
|
|
5567
|
+
let sum = zero;
|
|
5568
|
+
for (let i3 = lastBits; i3 >= 0; i3 -= windowSize) {
|
|
5569
|
+
buckets.fill(zero);
|
|
5570
|
+
for (let j = 0; j < slength; j++) {
|
|
5571
|
+
const scalar = scalars[j];
|
|
5572
|
+
const wbits2 = Number(scalar >> BigInt(i3) & MASK);
|
|
5573
|
+
buckets[wbits2] = buckets[wbits2].add(points[j]);
|
|
5574
|
+
}
|
|
5575
|
+
let resI = zero;
|
|
5576
|
+
for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {
|
|
5577
|
+
sumI = sumI.add(buckets[j]);
|
|
5578
|
+
resI = resI.add(sumI);
|
|
5579
|
+
}
|
|
5580
|
+
sum = sum.add(resI);
|
|
5581
|
+
if (i3 !== 0)
|
|
5582
|
+
for (let j = 0; j < windowSize; j++)
|
|
5583
|
+
sum = sum.double();
|
|
5584
|
+
}
|
|
5585
|
+
return sum;
|
|
5586
|
+
}
|
|
5587
|
+
function createField(order, field, isLE2) {
|
|
5588
|
+
if (field) {
|
|
5589
|
+
if (field.ORDER !== order)
|
|
5590
|
+
throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
5591
|
+
validateField$1(field);
|
|
5592
|
+
return field;
|
|
5593
|
+
} else {
|
|
5594
|
+
return Field$1(order, { isLE: isLE2 });
|
|
5595
|
+
}
|
|
5596
|
+
}
|
|
5597
|
+
function _createCurveFields(type2, CURVE2, curveOpts = {}, FpFnLE) {
|
|
5598
|
+
if (FpFnLE === void 0)
|
|
5599
|
+
FpFnLE = type2 === "edwards";
|
|
5600
|
+
if (!CURVE2 || typeof CURVE2 !== "object")
|
|
5601
|
+
throw new Error(`expected valid ${type2} CURVE object`);
|
|
5602
|
+
for (const p5 of ["p", "n", "h"]) {
|
|
5603
|
+
const val = CURVE2[p5];
|
|
5604
|
+
if (!(typeof val === "bigint" && val > _0n$8))
|
|
5605
|
+
throw new Error(`CURVE.${p5} must be positive bigint`);
|
|
5606
|
+
}
|
|
5607
|
+
const Fp2 = createField(CURVE2.p, curveOpts.Fp, FpFnLE);
|
|
5608
|
+
const Fn = createField(CURVE2.n, curveOpts.Fn, FpFnLE);
|
|
5609
|
+
const _b2 = "d";
|
|
5610
|
+
const params = ["Gx", "Gy", "a", _b2];
|
|
5611
|
+
for (const p5 of params) {
|
|
5612
|
+
if (!Fp2.isValid(CURVE2[p5]))
|
|
5613
|
+
throw new Error(`CURVE.${p5} must be valid field element of CURVE.Fp`);
|
|
5614
|
+
}
|
|
5615
|
+
CURVE2 = Object.freeze(Object.assign({}, CURVE2));
|
|
5616
|
+
return { CURVE: CURVE2, Fp: Fp2, Fn };
|
|
5617
|
+
}
|
|
5618
|
+
const _0n$7 = BigInt(0);
|
|
5619
|
+
const _1n$9 = BigInt(1);
|
|
5620
|
+
const _2n$7 = BigInt(2);
|
|
5621
|
+
const _7n$1 = BigInt(7);
|
|
5622
|
+
const _256n$1 = BigInt(256);
|
|
5623
|
+
const _0x71n$1 = BigInt(113);
|
|
5624
|
+
const SHA3_PI$1 = [];
|
|
5625
|
+
const SHA3_ROTL$1 = [];
|
|
5626
|
+
const _SHA3_IOTA$1 = [];
|
|
5627
|
+
for (let round = 0, R2 = _1n$9, x2 = 1, y3 = 0; round < 24; round++) {
|
|
5628
|
+
[x2, y3] = [y3, (2 * x2 + 3 * y3) % 5];
|
|
5629
|
+
SHA3_PI$1.push(2 * (5 * y3 + x2));
|
|
5630
|
+
SHA3_ROTL$1.push((round + 1) * (round + 2) / 2 % 64);
|
|
5631
|
+
let t6 = _0n$7;
|
|
5632
|
+
for (let j = 0; j < 7; j++) {
|
|
5633
|
+
R2 = (R2 << _1n$9 ^ (R2 >> _7n$1) * _0x71n$1) % _256n$1;
|
|
5634
|
+
if (R2 & _2n$7)
|
|
5635
|
+
t6 ^= _1n$9 << (_1n$9 << /* @__PURE__ */ BigInt(j)) - _1n$9;
|
|
5636
|
+
}
|
|
5637
|
+
_SHA3_IOTA$1.push(t6);
|
|
5638
|
+
}
|
|
5639
|
+
const IOTAS = split$1(_SHA3_IOTA$1, true);
|
|
5640
|
+
const SHA3_IOTA_H$1 = IOTAS[0];
|
|
5641
|
+
const SHA3_IOTA_L$1 = IOTAS[1];
|
|
5642
|
+
const rotlH$1 = (h2, l3, s5) => s5 > 32 ? rotlBH$1(h2, l3, s5) : rotlSH$1(h2, l3, s5);
|
|
5643
|
+
const rotlL$1 = (h2, l3, s5) => s5 > 32 ? rotlBL$1(h2, l3, s5) : rotlSL$1(h2, l3, s5);
|
|
5644
|
+
function keccakP$1(s5, rounds = 24) {
|
|
5645
|
+
const B = new Uint32Array(5 * 2);
|
|
5646
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
5647
|
+
for (let x2 = 0; x2 < 10; x2++)
|
|
5648
|
+
B[x2] = s5[x2] ^ s5[x2 + 10] ^ s5[x2 + 20] ^ s5[x2 + 30] ^ s5[x2 + 40];
|
|
5649
|
+
for (let x2 = 0; x2 < 10; x2 += 2) {
|
|
4641
5650
|
const idx1 = (x2 + 8) % 10;
|
|
4642
5651
|
const idx0 = (x2 + 2) % 10;
|
|
4643
5652
|
const B0 = B[idx0];
|
|
@@ -5127,14 +6136,14 @@ class SHA2562 extends HashMD2 {
|
|
|
5127
6136
|
this.H = SHA256_IV[7] | 0;
|
|
5128
6137
|
}
|
|
5129
6138
|
get() {
|
|
5130
|
-
const { A: A3, B, C:
|
|
5131
|
-
return [A3, B,
|
|
6139
|
+
const { A: A3, B, C: C2, D: D2, E: E2, F, G: G2, H } = this;
|
|
6140
|
+
return [A3, B, C2, D2, E2, F, G2, H];
|
|
5132
6141
|
}
|
|
5133
6142
|
// prettier-ignore
|
|
5134
|
-
set(A3, B,
|
|
6143
|
+
set(A3, B, C2, D2, E2, F, G2, H) {
|
|
5135
6144
|
this.A = A3 | 0;
|
|
5136
6145
|
this.B = B | 0;
|
|
5137
|
-
this.C =
|
|
6146
|
+
this.C = C2 | 0;
|
|
5138
6147
|
this.D = D2 | 0;
|
|
5139
6148
|
this.E = E2 | 0;
|
|
5140
6149
|
this.F = F | 0;
|
|
@@ -5151,30 +6160,30 @@ class SHA2562 extends HashMD2 {
|
|
|
5151
6160
|
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
5152
6161
|
SHA256_W[i3] = s1 + SHA256_W[i3 - 7] + s0 + SHA256_W[i3 - 16] | 0;
|
|
5153
6162
|
}
|
|
5154
|
-
let { A: A3, B, C:
|
|
6163
|
+
let { A: A3, B, C: C2, D: D2, E: E2, F, G: G2, H } = this;
|
|
5155
6164
|
for (let i3 = 0; i3 < 64; i3++) {
|
|
5156
6165
|
const sigma1 = rotr(E2, 6) ^ rotr(E2, 11) ^ rotr(E2, 25);
|
|
5157
6166
|
const T1 = H + sigma1 + Chi(E2, F, G2) + SHA256_K[i3] + SHA256_W[i3] | 0;
|
|
5158
6167
|
const sigma0 = rotr(A3, 2) ^ rotr(A3, 13) ^ rotr(A3, 22);
|
|
5159
|
-
const T22 = sigma0 + Maj(A3, B,
|
|
6168
|
+
const T22 = sigma0 + Maj(A3, B, C2) | 0;
|
|
5160
6169
|
H = G2;
|
|
5161
6170
|
G2 = F;
|
|
5162
6171
|
F = E2;
|
|
5163
6172
|
E2 = D2 + T1 | 0;
|
|
5164
|
-
D2 =
|
|
5165
|
-
|
|
6173
|
+
D2 = C2;
|
|
6174
|
+
C2 = B;
|
|
5166
6175
|
B = A3;
|
|
5167
6176
|
A3 = T1 + T22 | 0;
|
|
5168
6177
|
}
|
|
5169
6178
|
A3 = A3 + this.A | 0;
|
|
5170
6179
|
B = B + this.B | 0;
|
|
5171
|
-
|
|
6180
|
+
C2 = C2 + this.C | 0;
|
|
5172
6181
|
D2 = D2 + this.D | 0;
|
|
5173
6182
|
E2 = E2 + this.E | 0;
|
|
5174
6183
|
F = F + this.F | 0;
|
|
5175
6184
|
G2 = G2 + this.G | 0;
|
|
5176
6185
|
H = H + this.H | 0;
|
|
5177
|
-
this.set(A3, B,
|
|
6186
|
+
this.set(A3, B, C2, D2, E2, F, G2, H);
|
|
5178
6187
|
}
|
|
5179
6188
|
roundClean() {
|
|
5180
6189
|
SHA256_W.fill(0);
|
|
@@ -5185,7 +6194,7 @@ class SHA2562 extends HashMD2 {
|
|
|
5185
6194
|
}
|
|
5186
6195
|
}
|
|
5187
6196
|
const sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA2562());
|
|
5188
|
-
class
|
|
6197
|
+
class HMAC2 extends Hash2 {
|
|
5189
6198
|
constructor(hash, _key) {
|
|
5190
6199
|
super();
|
|
5191
6200
|
this.finished = false;
|
|
@@ -5246,12 +6255,12 @@ class HMAC extends Hash2 {
|
|
|
5246
6255
|
this.iHash.destroy();
|
|
5247
6256
|
}
|
|
5248
6257
|
}
|
|
5249
|
-
const hmac = (hash, key, message) => new
|
|
5250
|
-
hmac.create = (hash, key) => new
|
|
6258
|
+
const hmac = (hash, key, message) => new HMAC2(hash, key).update(message).digest();
|
|
6259
|
+
hmac.create = (hash, key) => new HMAC2(hash, key);
|
|
5251
6260
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5252
|
-
const _0n$
|
|
5253
|
-
const _1n$
|
|
5254
|
-
const _2n$
|
|
6261
|
+
const _0n$6 = /* @__PURE__ */ BigInt(0);
|
|
6262
|
+
const _1n$8 = /* @__PURE__ */ BigInt(1);
|
|
6263
|
+
const _2n$6 = /* @__PURE__ */ BigInt(2);
|
|
5255
6264
|
function isBytes$2(a5) {
|
|
5256
6265
|
return a5 instanceof Uint8Array || ArrayBuffer.isView(a5) && a5.constructor.name === "Uint8Array";
|
|
5257
6266
|
}
|
|
@@ -5279,7 +6288,7 @@ function numberToHexUnpadded(num) {
|
|
|
5279
6288
|
function hexToNumber(hex) {
|
|
5280
6289
|
if (typeof hex !== "string")
|
|
5281
6290
|
throw new Error("hex string expected, got " + typeof hex);
|
|
5282
|
-
return hex === "" ? _0n$
|
|
6291
|
+
return hex === "" ? _0n$6 : BigInt("0x" + hex);
|
|
5283
6292
|
}
|
|
5284
6293
|
const asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
5285
6294
|
function asciiToBase16(ch) {
|
|
@@ -5372,7 +6381,7 @@ function utf8ToBytes(str) {
|
|
|
5372
6381
|
throw new Error("string expected");
|
|
5373
6382
|
return new Uint8Array(new TextEncoder().encode(str));
|
|
5374
6383
|
}
|
|
5375
|
-
const isPosBig = (n4) => typeof n4 === "bigint" && _0n$
|
|
6384
|
+
const isPosBig = (n4) => typeof n4 === "bigint" && _0n$6 <= n4;
|
|
5376
6385
|
function inRange(n4, min, max) {
|
|
5377
6386
|
return isPosBig(n4) && isPosBig(min) && isPosBig(max) && min <= n4 && n4 < max;
|
|
5378
6387
|
}
|
|
@@ -5382,17 +6391,17 @@ function aInRange(title, n4, min, max) {
|
|
|
5382
6391
|
}
|
|
5383
6392
|
function bitLen(n4) {
|
|
5384
6393
|
let len;
|
|
5385
|
-
for (len = 0; n4 > _0n$
|
|
6394
|
+
for (len = 0; n4 > _0n$6; n4 >>= _1n$8, len += 1)
|
|
5386
6395
|
;
|
|
5387
6396
|
return len;
|
|
5388
6397
|
}
|
|
5389
6398
|
function bitGet(n4, pos) {
|
|
5390
|
-
return n4 >> BigInt(pos) & _1n$
|
|
6399
|
+
return n4 >> BigInt(pos) & _1n$8;
|
|
5391
6400
|
}
|
|
5392
6401
|
function bitSet(n4, pos, value) {
|
|
5393
|
-
return n4 | (value ? _1n$
|
|
6402
|
+
return n4 | (value ? _1n$8 : _0n$6) << BigInt(pos);
|
|
5394
6403
|
}
|
|
5395
|
-
const bitMask = (n4) => (_2n$
|
|
6404
|
+
const bitMask = (n4) => (_2n$6 << BigInt(n4 - 1)) - _1n$8;
|
|
5396
6405
|
const u8n$1 = (data) => new Uint8Array(data);
|
|
5397
6406
|
const u8fr = (arr) => Uint8Array.from(arr);
|
|
5398
6407
|
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
@@ -5516,123 +6525,123 @@ const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
5516
6525
|
validateObject
|
|
5517
6526
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
5518
6527
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5519
|
-
const _0n$
|
|
5520
|
-
const _4n = /* @__PURE__ */ BigInt(4), _5n = /* @__PURE__ */ BigInt(5), _8n = /* @__PURE__ */ BigInt(8);
|
|
6528
|
+
const _0n$5 = BigInt(0), _1n$7 = BigInt(1), _2n$5 = /* @__PURE__ */ BigInt(2), _3n$2 = /* @__PURE__ */ BigInt(3);
|
|
6529
|
+
const _4n = /* @__PURE__ */ BigInt(4), _5n$1 = /* @__PURE__ */ BigInt(5), _8n$2 = /* @__PURE__ */ BigInt(8);
|
|
5521
6530
|
function mod(a5, b2) {
|
|
5522
6531
|
const result = a5 % b2;
|
|
5523
|
-
return result >= _0n$
|
|
6532
|
+
return result >= _0n$5 ? result : b2 + result;
|
|
5524
6533
|
}
|
|
5525
6534
|
function pow(num, power, modulo) {
|
|
5526
|
-
if (power < _0n$
|
|
6535
|
+
if (power < _0n$5)
|
|
5527
6536
|
throw new Error("invalid exponent, negatives unsupported");
|
|
5528
|
-
if (modulo <= _0n$
|
|
6537
|
+
if (modulo <= _0n$5)
|
|
5529
6538
|
throw new Error("invalid modulus");
|
|
5530
|
-
if (modulo === _1n$
|
|
5531
|
-
return _0n$
|
|
5532
|
-
let res = _1n$
|
|
5533
|
-
while (power > _0n$
|
|
5534
|
-
if (power & _1n$
|
|
6539
|
+
if (modulo === _1n$7)
|
|
6540
|
+
return _0n$5;
|
|
6541
|
+
let res = _1n$7;
|
|
6542
|
+
while (power > _0n$5) {
|
|
6543
|
+
if (power & _1n$7)
|
|
5535
6544
|
res = res * num % modulo;
|
|
5536
6545
|
num = num * num % modulo;
|
|
5537
|
-
power >>= _1n$
|
|
6546
|
+
power >>= _1n$7;
|
|
5538
6547
|
}
|
|
5539
6548
|
return res;
|
|
5540
6549
|
}
|
|
5541
6550
|
function pow2(x2, power, modulo) {
|
|
5542
6551
|
let res = x2;
|
|
5543
|
-
while (power-- > _0n$
|
|
6552
|
+
while (power-- > _0n$5) {
|
|
5544
6553
|
res *= res;
|
|
5545
6554
|
res %= modulo;
|
|
5546
6555
|
}
|
|
5547
6556
|
return res;
|
|
5548
6557
|
}
|
|
5549
6558
|
function invert(number, modulo) {
|
|
5550
|
-
if (number === _0n$
|
|
6559
|
+
if (number === _0n$5)
|
|
5551
6560
|
throw new Error("invert: expected non-zero number");
|
|
5552
|
-
if (modulo <= _0n$
|
|
6561
|
+
if (modulo <= _0n$5)
|
|
5553
6562
|
throw new Error("invert: expected positive modulus, got " + modulo);
|
|
5554
6563
|
let a5 = mod(number, modulo);
|
|
5555
6564
|
let b2 = modulo;
|
|
5556
|
-
let x2 = _0n$
|
|
5557
|
-
while (a5 !== _0n$
|
|
6565
|
+
let x2 = _0n$5, u4 = _1n$7;
|
|
6566
|
+
while (a5 !== _0n$5) {
|
|
5558
6567
|
const q2 = b2 / a5;
|
|
5559
6568
|
const r7 = b2 % a5;
|
|
5560
6569
|
const m2 = x2 - u4 * q2;
|
|
5561
6570
|
b2 = a5, a5 = r7, x2 = u4, u4 = m2;
|
|
5562
6571
|
}
|
|
5563
6572
|
const gcd2 = b2;
|
|
5564
|
-
if (gcd2 !== _1n$
|
|
6573
|
+
if (gcd2 !== _1n$7)
|
|
5565
6574
|
throw new Error("invert: does not exist");
|
|
5566
6575
|
return mod(x2, modulo);
|
|
5567
6576
|
}
|
|
5568
|
-
function tonelliShanks(
|
|
5569
|
-
const legendreC = (
|
|
6577
|
+
function tonelliShanks(P2) {
|
|
6578
|
+
const legendreC = (P2 - _1n$7) / _2n$5;
|
|
5570
6579
|
let Q, S2, Z;
|
|
5571
|
-
for (Q =
|
|
6580
|
+
for (Q = P2 - _1n$7, S2 = 0; Q % _2n$5 === _0n$5; Q /= _2n$5, S2++)
|
|
5572
6581
|
;
|
|
5573
|
-
for (Z = _2n$
|
|
6582
|
+
for (Z = _2n$5; Z < P2 && pow(Z, legendreC, P2) !== P2 - _1n$7; Z++) {
|
|
5574
6583
|
if (Z > 1e3)
|
|
5575
6584
|
throw new Error("Cannot find square root: likely non-prime P");
|
|
5576
6585
|
}
|
|
5577
6586
|
if (S2 === 1) {
|
|
5578
|
-
const p1div4 = (
|
|
5579
|
-
return function tonelliFast(
|
|
5580
|
-
const root2 =
|
|
5581
|
-
if (!
|
|
6587
|
+
const p1div4 = (P2 + _1n$7) / _4n;
|
|
6588
|
+
return function tonelliFast(Fp2, n4) {
|
|
6589
|
+
const root2 = Fp2.pow(n4, p1div4);
|
|
6590
|
+
if (!Fp2.eql(Fp2.sqr(root2), n4))
|
|
5582
6591
|
throw new Error("Cannot find square root");
|
|
5583
6592
|
return root2;
|
|
5584
6593
|
};
|
|
5585
6594
|
}
|
|
5586
|
-
const Q1div2 = (Q + _1n$
|
|
5587
|
-
return function tonelliSlow(
|
|
5588
|
-
if (
|
|
6595
|
+
const Q1div2 = (Q + _1n$7) / _2n$5;
|
|
6596
|
+
return function tonelliSlow(Fp2, n4) {
|
|
6597
|
+
if (Fp2.pow(n4, legendreC) === Fp2.neg(Fp2.ONE))
|
|
5589
6598
|
throw new Error("Cannot find square root");
|
|
5590
6599
|
let r7 = S2;
|
|
5591
|
-
let g2 =
|
|
5592
|
-
let x2 =
|
|
5593
|
-
let b2 =
|
|
5594
|
-
while (!
|
|
5595
|
-
if (
|
|
5596
|
-
return
|
|
6600
|
+
let g2 = Fp2.pow(Fp2.mul(Fp2.ONE, Z), Q);
|
|
6601
|
+
let x2 = Fp2.pow(n4, Q1div2);
|
|
6602
|
+
let b2 = Fp2.pow(n4, Q);
|
|
6603
|
+
while (!Fp2.eql(b2, Fp2.ONE)) {
|
|
6604
|
+
if (Fp2.eql(b2, Fp2.ZERO))
|
|
6605
|
+
return Fp2.ZERO;
|
|
5597
6606
|
let m2 = 1;
|
|
5598
|
-
for (let t22 =
|
|
5599
|
-
if (
|
|
6607
|
+
for (let t22 = Fp2.sqr(b2); m2 < r7; m2++) {
|
|
6608
|
+
if (Fp2.eql(t22, Fp2.ONE))
|
|
5600
6609
|
break;
|
|
5601
|
-
t22 =
|
|
6610
|
+
t22 = Fp2.sqr(t22);
|
|
5602
6611
|
}
|
|
5603
|
-
const ge2 =
|
|
5604
|
-
g2 =
|
|
5605
|
-
x2 =
|
|
5606
|
-
b2 =
|
|
6612
|
+
const ge2 = Fp2.pow(g2, _1n$7 << BigInt(r7 - m2 - 1));
|
|
6613
|
+
g2 = Fp2.sqr(ge2);
|
|
6614
|
+
x2 = Fp2.mul(x2, ge2);
|
|
6615
|
+
b2 = Fp2.mul(b2, g2);
|
|
5607
6616
|
r7 = m2;
|
|
5608
6617
|
}
|
|
5609
6618
|
return x2;
|
|
5610
6619
|
};
|
|
5611
6620
|
}
|
|
5612
|
-
function FpSqrt(
|
|
5613
|
-
if (
|
|
5614
|
-
const p1div4 = (
|
|
5615
|
-
return function
|
|
5616
|
-
const root2 =
|
|
5617
|
-
if (!
|
|
6621
|
+
function FpSqrt(P2) {
|
|
6622
|
+
if (P2 % _4n === _3n$2) {
|
|
6623
|
+
const p1div4 = (P2 + _1n$7) / _4n;
|
|
6624
|
+
return function sqrt3mod42(Fp2, n4) {
|
|
6625
|
+
const root2 = Fp2.pow(n4, p1div4);
|
|
6626
|
+
if (!Fp2.eql(Fp2.sqr(root2), n4))
|
|
5618
6627
|
throw new Error("Cannot find square root");
|
|
5619
6628
|
return root2;
|
|
5620
6629
|
};
|
|
5621
6630
|
}
|
|
5622
|
-
if (
|
|
5623
|
-
const c1 = (
|
|
5624
|
-
return function
|
|
5625
|
-
const n22 =
|
|
5626
|
-
const v2 =
|
|
5627
|
-
const nv =
|
|
5628
|
-
const i3 =
|
|
5629
|
-
const root2 =
|
|
5630
|
-
if (!
|
|
6631
|
+
if (P2 % _8n$2 === _5n$1) {
|
|
6632
|
+
const c1 = (P2 - _5n$1) / _8n$2;
|
|
6633
|
+
return function sqrt5mod82(Fp2, n4) {
|
|
6634
|
+
const n22 = Fp2.mul(n4, _2n$5);
|
|
6635
|
+
const v2 = Fp2.pow(n22, c1);
|
|
6636
|
+
const nv = Fp2.mul(n4, v2);
|
|
6637
|
+
const i3 = Fp2.mul(Fp2.mul(nv, _2n$5), v2);
|
|
6638
|
+
const root2 = Fp2.mul(nv, Fp2.sub(i3, Fp2.ONE));
|
|
6639
|
+
if (!Fp2.eql(Fp2.sqr(root2), n4))
|
|
5631
6640
|
throw new Error("Cannot find square root");
|
|
5632
6641
|
return root2;
|
|
5633
6642
|
};
|
|
5634
6643
|
}
|
|
5635
|
-
return tonelliShanks(
|
|
6644
|
+
return tonelliShanks(P2);
|
|
5636
6645
|
}
|
|
5637
6646
|
const FIELD_FIELDS = [
|
|
5638
6647
|
"create",
|
|
@@ -5667,19 +6676,19 @@ function validateField(field) {
|
|
|
5667
6676
|
return validateObject(field, opts);
|
|
5668
6677
|
}
|
|
5669
6678
|
function FpPow(f3, num, power) {
|
|
5670
|
-
if (power < _0n$
|
|
6679
|
+
if (power < _0n$5)
|
|
5671
6680
|
throw new Error("invalid exponent, negatives unsupported");
|
|
5672
|
-
if (power === _0n$
|
|
6681
|
+
if (power === _0n$5)
|
|
5673
6682
|
return f3.ONE;
|
|
5674
|
-
if (power === _1n$
|
|
6683
|
+
if (power === _1n$7)
|
|
5675
6684
|
return num;
|
|
5676
6685
|
let p5 = f3.ONE;
|
|
5677
6686
|
let d2 = num;
|
|
5678
|
-
while (power > _0n$
|
|
5679
|
-
if (power & _1n$
|
|
6687
|
+
while (power > _0n$5) {
|
|
6688
|
+
if (power & _1n$7)
|
|
5680
6689
|
p5 = f3.mul(p5, d2);
|
|
5681
6690
|
d2 = f3.sqr(d2);
|
|
5682
|
-
power >>= _1n$
|
|
6691
|
+
power >>= _1n$7;
|
|
5683
6692
|
}
|
|
5684
6693
|
return p5;
|
|
5685
6694
|
}
|
|
@@ -5706,7 +6715,7 @@ function nLength(n4, nBitLength) {
|
|
|
5706
6715
|
return { nBitLength: _nBitLength, nByteLength };
|
|
5707
6716
|
}
|
|
5708
6717
|
function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
|
|
5709
|
-
if (ORDER <= _0n$
|
|
6718
|
+
if (ORDER <= _0n$5)
|
|
5710
6719
|
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
|
5711
6720
|
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
|
|
5712
6721
|
if (BYTES > 2048)
|
|
@@ -5718,16 +6727,16 @@ function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
|
|
|
5718
6727
|
BITS,
|
|
5719
6728
|
BYTES,
|
|
5720
6729
|
MASK: bitMask(BITS),
|
|
5721
|
-
ZERO: _0n$
|
|
5722
|
-
ONE: _1n$
|
|
6730
|
+
ZERO: _0n$5,
|
|
6731
|
+
ONE: _1n$7,
|
|
5723
6732
|
create: (num) => mod(num, ORDER),
|
|
5724
6733
|
isValid: (num) => {
|
|
5725
6734
|
if (typeof num !== "bigint")
|
|
5726
6735
|
throw new Error("invalid field element: expected bigint, got " + typeof num);
|
|
5727
|
-
return _0n$
|
|
6736
|
+
return _0n$5 <= num && num < ORDER;
|
|
5728
6737
|
},
|
|
5729
|
-
is0: (num) => num === _0n$
|
|
5730
|
-
isOdd: (num) => (num & _1n$
|
|
6738
|
+
is0: (num) => num === _0n$5,
|
|
6739
|
+
isOdd: (num) => (num & _1n$7) === _1n$7,
|
|
5731
6740
|
neg: (num) => mod(-num, ORDER),
|
|
5732
6741
|
eql: (lhs, rhs) => lhs === rhs,
|
|
5733
6742
|
sqr: (num) => mod(num * num, ORDER),
|
|
@@ -5777,12 +6786,12 @@ function mapHashToField(key, fieldOrder, isLE2 = false) {
|
|
|
5777
6786
|
if (len < 16 || len < minLen || len > 1024)
|
|
5778
6787
|
throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
|
|
5779
6788
|
const num = isLE2 ? bytesToNumberLE(key) : bytesToNumberBE(key);
|
|
5780
|
-
const reduced = mod(num, fieldOrder - _1n$
|
|
6789
|
+
const reduced = mod(num, fieldOrder - _1n$7) + _1n$7;
|
|
5781
6790
|
return isLE2 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
|
|
5782
6791
|
}
|
|
5783
6792
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5784
|
-
const _0n$
|
|
5785
|
-
const _1n$
|
|
6793
|
+
const _0n$4 = BigInt(0);
|
|
6794
|
+
const _1n$6 = BigInt(1);
|
|
5786
6795
|
function constTimeNegate(condition, item) {
|
|
5787
6796
|
const neg = item.negate();
|
|
5788
6797
|
return condition ? neg : item;
|
|
@@ -5815,8 +6824,8 @@ function validateMSMScalars(scalars, field) {
|
|
|
5815
6824
|
}
|
|
5816
6825
|
const pointPrecomputes = /* @__PURE__ */ new WeakMap();
|
|
5817
6826
|
const pointWindowSizes = /* @__PURE__ */ new WeakMap();
|
|
5818
|
-
function getW(
|
|
5819
|
-
return pointWindowSizes.get(
|
|
6827
|
+
function getW(P2) {
|
|
6828
|
+
return pointWindowSizes.get(P2) || 1;
|
|
5820
6829
|
}
|
|
5821
6830
|
function wNAF$1(c3, bits) {
|
|
5822
6831
|
return {
|
|
@@ -5827,11 +6836,11 @@ function wNAF$1(c3, bits) {
|
|
|
5827
6836
|
// non-const time multiplication ladder
|
|
5828
6837
|
unsafeLadder(elm, n4, p5 = c3.ZERO) {
|
|
5829
6838
|
let d2 = elm;
|
|
5830
|
-
while (n4 > _0n$
|
|
5831
|
-
if (n4 & _1n$
|
|
6839
|
+
while (n4 > _0n$4) {
|
|
6840
|
+
if (n4 & _1n$6)
|
|
5832
6841
|
p5 = p5.add(d2);
|
|
5833
6842
|
d2 = d2.double();
|
|
5834
|
-
n4 >>= _1n$
|
|
6843
|
+
n4 >>= _1n$6;
|
|
5835
6844
|
}
|
|
5836
6845
|
return p5;
|
|
5837
6846
|
},
|
|
@@ -5883,7 +6892,7 @@ function wNAF$1(c3, bits) {
|
|
|
5883
6892
|
n4 >>= shiftBy;
|
|
5884
6893
|
if (wbits > windowSize) {
|
|
5885
6894
|
wbits -= maxNumber;
|
|
5886
|
-
n4 += _1n$
|
|
6895
|
+
n4 += _1n$6;
|
|
5887
6896
|
}
|
|
5888
6897
|
const offset1 = offset;
|
|
5889
6898
|
const offset2 = offset + Math.abs(wbits) - 1;
|
|
@@ -5912,13 +6921,13 @@ function wNAF$1(c3, bits) {
|
|
|
5912
6921
|
const shiftBy = BigInt(W2);
|
|
5913
6922
|
for (let window2 = 0; window2 < windows; window2++) {
|
|
5914
6923
|
const offset = window2 * windowSize;
|
|
5915
|
-
if (n4 === _0n$
|
|
6924
|
+
if (n4 === _0n$4)
|
|
5916
6925
|
break;
|
|
5917
6926
|
let wbits = Number(n4 & mask);
|
|
5918
6927
|
n4 >>= shiftBy;
|
|
5919
6928
|
if (wbits > windowSize) {
|
|
5920
6929
|
wbits -= maxNumber;
|
|
5921
|
-
n4 += _1n$
|
|
6930
|
+
n4 += _1n$6;
|
|
5922
6931
|
}
|
|
5923
6932
|
if (wbits === 0)
|
|
5924
6933
|
continue;
|
|
@@ -5929,32 +6938,32 @@ function wNAF$1(c3, bits) {
|
|
|
5929
6938
|
}
|
|
5930
6939
|
return acc;
|
|
5931
6940
|
},
|
|
5932
|
-
getPrecomputes(W2,
|
|
5933
|
-
let comp = pointPrecomputes.get(
|
|
6941
|
+
getPrecomputes(W2, P2, transform) {
|
|
6942
|
+
let comp = pointPrecomputes.get(P2);
|
|
5934
6943
|
if (!comp) {
|
|
5935
|
-
comp = this.precomputeWindow(
|
|
6944
|
+
comp = this.precomputeWindow(P2, W2);
|
|
5936
6945
|
if (W2 !== 1)
|
|
5937
|
-
pointPrecomputes.set(
|
|
6946
|
+
pointPrecomputes.set(P2, transform(comp));
|
|
5938
6947
|
}
|
|
5939
6948
|
return comp;
|
|
5940
6949
|
},
|
|
5941
|
-
wNAFCached(
|
|
5942
|
-
const W2 = getW(
|
|
5943
|
-
return this.wNAF(W2, this.getPrecomputes(W2,
|
|
6950
|
+
wNAFCached(P2, n4, transform) {
|
|
6951
|
+
const W2 = getW(P2);
|
|
6952
|
+
return this.wNAF(W2, this.getPrecomputes(W2, P2, transform), n4);
|
|
5944
6953
|
},
|
|
5945
|
-
wNAFCachedUnsafe(
|
|
5946
|
-
const W2 = getW(
|
|
6954
|
+
wNAFCachedUnsafe(P2, n4, transform, prev) {
|
|
6955
|
+
const W2 = getW(P2);
|
|
5947
6956
|
if (W2 === 1)
|
|
5948
|
-
return this.unsafeLadder(
|
|
5949
|
-
return this.wNAFUnsafe(W2, this.getPrecomputes(W2,
|
|
6957
|
+
return this.unsafeLadder(P2, n4, prev);
|
|
6958
|
+
return this.wNAFUnsafe(W2, this.getPrecomputes(W2, P2, transform), n4, prev);
|
|
5950
6959
|
},
|
|
5951
6960
|
// We calculate precomputes for elliptic curve point multiplication
|
|
5952
6961
|
// using windowed method. This specifies window size and
|
|
5953
6962
|
// stores precomputed values. Usually only base point would be precomputed.
|
|
5954
|
-
setWindowSize(
|
|
6963
|
+
setWindowSize(P2, W2) {
|
|
5955
6964
|
validateW(W2, bits);
|
|
5956
|
-
pointWindowSizes.set(
|
|
5957
|
-
pointPrecomputes.delete(
|
|
6965
|
+
pointWindowSizes.set(P2, W2);
|
|
6966
|
+
pointPrecomputes.delete(P2);
|
|
5958
6967
|
}
|
|
5959
6968
|
};
|
|
5960
6969
|
}
|
|
@@ -6027,9 +7036,9 @@ function validatePointOpts(curve2) {
|
|
|
6027
7036
|
fromBytes: "function",
|
|
6028
7037
|
toBytes: "function"
|
|
6029
7038
|
});
|
|
6030
|
-
const { endo, Fp, a: a5 } = opts;
|
|
7039
|
+
const { endo, Fp: Fp2, a: a5 } = opts;
|
|
6031
7040
|
if (endo) {
|
|
6032
|
-
if (!
|
|
7041
|
+
if (!Fp2.eql(a5, Fp2.ZERO)) {
|
|
6033
7042
|
throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");
|
|
6034
7043
|
}
|
|
6035
7044
|
if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
|
|
@@ -6106,7 +7115,7 @@ const DER = {
|
|
|
6106
7115
|
_int: {
|
|
6107
7116
|
encode(num) {
|
|
6108
7117
|
const { Err: E2 } = DER;
|
|
6109
|
-
if (num < _0n$
|
|
7118
|
+
if (num < _0n$3)
|
|
6110
7119
|
throw new E2("integer: negative integers are not allowed");
|
|
6111
7120
|
let hex = numberToHexUnpadded(num);
|
|
6112
7121
|
if (Number.parseInt(hex[0], 16) & 8)
|
|
@@ -6145,34 +7154,34 @@ const DER = {
|
|
|
6145
7154
|
return tlv.encode(48, seq);
|
|
6146
7155
|
}
|
|
6147
7156
|
};
|
|
6148
|
-
const _0n$
|
|
7157
|
+
const _0n$3 = BigInt(0), _1n$5 = BigInt(1);
|
|
6149
7158
|
BigInt(2);
|
|
6150
|
-
const _3n = BigInt(3);
|
|
7159
|
+
const _3n$1 = BigInt(3);
|
|
6151
7160
|
BigInt(4);
|
|
6152
7161
|
function weierstrassPoints(opts) {
|
|
6153
7162
|
const CURVE2 = validatePointOpts(opts);
|
|
6154
|
-
const { Fp } = CURVE2;
|
|
7163
|
+
const { Fp: Fp2 } = CURVE2;
|
|
6155
7164
|
const Fn = Field(CURVE2.n, CURVE2.nBitLength);
|
|
6156
7165
|
const toBytes2 = CURVE2.toBytes || ((_c4, point, _isCompressed) => {
|
|
6157
7166
|
const a5 = point.toAffine();
|
|
6158
|
-
return concatBytes(Uint8Array.from([4]),
|
|
7167
|
+
return concatBytes(Uint8Array.from([4]), Fp2.toBytes(a5.x), Fp2.toBytes(a5.y));
|
|
6159
7168
|
});
|
|
6160
7169
|
const fromBytes = CURVE2.fromBytes || ((bytes) => {
|
|
6161
7170
|
const tail = bytes.subarray(1);
|
|
6162
|
-
const x2 =
|
|
6163
|
-
const y3 =
|
|
7171
|
+
const x2 = Fp2.fromBytes(tail.subarray(0, Fp2.BYTES));
|
|
7172
|
+
const y3 = Fp2.fromBytes(tail.subarray(Fp2.BYTES, 2 * Fp2.BYTES));
|
|
6164
7173
|
return { x: x2, y: y3 };
|
|
6165
7174
|
});
|
|
6166
7175
|
function weierstrassEquation(x2) {
|
|
6167
7176
|
const { a: a5, b: b2 } = CURVE2;
|
|
6168
|
-
const x22 =
|
|
6169
|
-
const x3 =
|
|
6170
|
-
return
|
|
7177
|
+
const x22 = Fp2.sqr(x2);
|
|
7178
|
+
const x3 = Fp2.mul(x22, x2);
|
|
7179
|
+
return Fp2.add(Fp2.add(x3, Fp2.mul(x2, a5)), b2);
|
|
6171
7180
|
}
|
|
6172
|
-
if (!
|
|
7181
|
+
if (!Fp2.eql(Fp2.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
|
|
6173
7182
|
throw new Error("bad generator point: equation left != right");
|
|
6174
7183
|
function isWithinCurveOrder(num) {
|
|
6175
|
-
return inRange(num, _1n$
|
|
7184
|
+
return inRange(num, _1n$5, CURVE2.n);
|
|
6176
7185
|
}
|
|
6177
7186
|
function normPrivateKeyToScalar(key) {
|
|
6178
7187
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N2 } = CURVE2;
|
|
@@ -6191,56 +7200,56 @@ function weierstrassPoints(opts) {
|
|
|
6191
7200
|
}
|
|
6192
7201
|
if (wrapPrivateKey)
|
|
6193
7202
|
num = mod(num, N2);
|
|
6194
|
-
aInRange("private key", num, _1n$
|
|
7203
|
+
aInRange("private key", num, _1n$5, N2);
|
|
6195
7204
|
return num;
|
|
6196
7205
|
}
|
|
6197
7206
|
function assertPrjPoint(other) {
|
|
6198
|
-
if (!(other instanceof
|
|
7207
|
+
if (!(other instanceof Point3))
|
|
6199
7208
|
throw new Error("ProjectivePoint expected");
|
|
6200
7209
|
}
|
|
6201
7210
|
const toAffineMemo = memoized((p5, iz) => {
|
|
6202
7211
|
const { px: x2, py: y3, pz: z2 } = p5;
|
|
6203
|
-
if (
|
|
7212
|
+
if (Fp2.eql(z2, Fp2.ONE))
|
|
6204
7213
|
return { x: x2, y: y3 };
|
|
6205
7214
|
const is0 = p5.is0();
|
|
6206
7215
|
if (iz == null)
|
|
6207
|
-
iz = is0 ?
|
|
6208
|
-
const ax =
|
|
6209
|
-
const ay =
|
|
6210
|
-
const zz =
|
|
7216
|
+
iz = is0 ? Fp2.ONE : Fp2.inv(z2);
|
|
7217
|
+
const ax = Fp2.mul(x2, iz);
|
|
7218
|
+
const ay = Fp2.mul(y3, iz);
|
|
7219
|
+
const zz = Fp2.mul(z2, iz);
|
|
6211
7220
|
if (is0)
|
|
6212
|
-
return { x:
|
|
6213
|
-
if (!
|
|
7221
|
+
return { x: Fp2.ZERO, y: Fp2.ZERO };
|
|
7222
|
+
if (!Fp2.eql(zz, Fp2.ONE))
|
|
6214
7223
|
throw new Error("invZ was invalid");
|
|
6215
7224
|
return { x: ax, y: ay };
|
|
6216
7225
|
});
|
|
6217
7226
|
const assertValidMemo = memoized((p5) => {
|
|
6218
7227
|
if (p5.is0()) {
|
|
6219
|
-
if (CURVE2.allowInfinityPoint && !
|
|
7228
|
+
if (CURVE2.allowInfinityPoint && !Fp2.is0(p5.py))
|
|
6220
7229
|
return;
|
|
6221
7230
|
throw new Error("bad point: ZERO");
|
|
6222
7231
|
}
|
|
6223
7232
|
const { x: x2, y: y3 } = p5.toAffine();
|
|
6224
|
-
if (!
|
|
7233
|
+
if (!Fp2.isValid(x2) || !Fp2.isValid(y3))
|
|
6225
7234
|
throw new Error("bad point: x or y not FE");
|
|
6226
|
-
const left =
|
|
7235
|
+
const left = Fp2.sqr(y3);
|
|
6227
7236
|
const right = weierstrassEquation(x2);
|
|
6228
|
-
if (!
|
|
7237
|
+
if (!Fp2.eql(left, right))
|
|
6229
7238
|
throw new Error("bad point: equation left != right");
|
|
6230
7239
|
if (!p5.isTorsionFree())
|
|
6231
7240
|
throw new Error("bad point: not in prime-order subgroup");
|
|
6232
7241
|
return true;
|
|
6233
7242
|
});
|
|
6234
|
-
class
|
|
7243
|
+
class Point3 {
|
|
6235
7244
|
constructor(px, py, pz) {
|
|
6236
7245
|
this.px = px;
|
|
6237
7246
|
this.py = py;
|
|
6238
7247
|
this.pz = pz;
|
|
6239
|
-
if (px == null || !
|
|
7248
|
+
if (px == null || !Fp2.isValid(px))
|
|
6240
7249
|
throw new Error("x required");
|
|
6241
|
-
if (py == null || !
|
|
7250
|
+
if (py == null || !Fp2.isValid(py))
|
|
6242
7251
|
throw new Error("y required");
|
|
6243
|
-
if (pz == null || !
|
|
7252
|
+
if (pz == null || !Fp2.isValid(pz))
|
|
6244
7253
|
throw new Error("z required");
|
|
6245
7254
|
Object.freeze(this);
|
|
6246
7255
|
}
|
|
@@ -6248,14 +7257,14 @@ function weierstrassPoints(opts) {
|
|
|
6248
7257
|
// Use fromHex instead, or call assertValidity() later.
|
|
6249
7258
|
static fromAffine(p5) {
|
|
6250
7259
|
const { x: x2, y: y3 } = p5 || {};
|
|
6251
|
-
if (!p5 || !
|
|
7260
|
+
if (!p5 || !Fp2.isValid(x2) || !Fp2.isValid(y3))
|
|
6252
7261
|
throw new Error("invalid affine point");
|
|
6253
|
-
if (p5 instanceof
|
|
7262
|
+
if (p5 instanceof Point3)
|
|
6254
7263
|
throw new Error("projective point not allowed");
|
|
6255
|
-
const is0 = (i3) =>
|
|
7264
|
+
const is0 = (i3) => Fp2.eql(i3, Fp2.ZERO);
|
|
6256
7265
|
if (is0(x2) && is0(y3))
|
|
6257
|
-
return
|
|
6258
|
-
return new
|
|
7266
|
+
return Point3.ZERO;
|
|
7267
|
+
return new Point3(x2, y3, Fp2.ONE);
|
|
6259
7268
|
}
|
|
6260
7269
|
get x() {
|
|
6261
7270
|
return this.toAffine().x;
|
|
@@ -6270,25 +7279,25 @@ function weierstrassPoints(opts) {
|
|
|
6270
7279
|
* Optimization: converts a list of projective points to a list of identical points with Z=1.
|
|
6271
7280
|
*/
|
|
6272
7281
|
static normalizeZ(points) {
|
|
6273
|
-
const toInv =
|
|
6274
|
-
return points.map((p5, i3) => p5.toAffine(toInv[i3])).map(
|
|
7282
|
+
const toInv = Fp2.invertBatch(points.map((p5) => p5.pz));
|
|
7283
|
+
return points.map((p5, i3) => p5.toAffine(toInv[i3])).map(Point3.fromAffine);
|
|
6275
7284
|
}
|
|
6276
7285
|
/**
|
|
6277
7286
|
* Converts hash string or Uint8Array to Point.
|
|
6278
7287
|
* @param hex short/long ECDSA hex
|
|
6279
7288
|
*/
|
|
6280
7289
|
static fromHex(hex) {
|
|
6281
|
-
const
|
|
6282
|
-
|
|
6283
|
-
return
|
|
7290
|
+
const P2 = Point3.fromAffine(fromBytes(ensureBytes("pointHex", hex)));
|
|
7291
|
+
P2.assertValidity();
|
|
7292
|
+
return P2;
|
|
6284
7293
|
}
|
|
6285
7294
|
// Multiplies generator point by privateKey.
|
|
6286
7295
|
static fromPrivateKey(privateKey) {
|
|
6287
|
-
return
|
|
7296
|
+
return Point3.BASE.multiply(normPrivateKeyToScalar(privateKey));
|
|
6288
7297
|
}
|
|
6289
7298
|
// Multiscalar Multiplication
|
|
6290
7299
|
static msm(points, scalars) {
|
|
6291
|
-
return pippenger(
|
|
7300
|
+
return pippenger(Point3, Fn, points, scalars);
|
|
6292
7301
|
}
|
|
6293
7302
|
// "Private method", don't use it directly
|
|
6294
7303
|
_setWindowSize(windowSize) {
|
|
@@ -6300,8 +7309,8 @@ function weierstrassPoints(opts) {
|
|
|
6300
7309
|
}
|
|
6301
7310
|
hasEvenY() {
|
|
6302
7311
|
const { y: y3 } = this.toAffine();
|
|
6303
|
-
if (
|
|
6304
|
-
return !
|
|
7312
|
+
if (Fp2.isOdd)
|
|
7313
|
+
return !Fp2.isOdd(y3);
|
|
6305
7314
|
throw new Error("Field doesn't support isOdd");
|
|
6306
7315
|
}
|
|
6307
7316
|
/**
|
|
@@ -6311,15 +7320,15 @@ function weierstrassPoints(opts) {
|
|
|
6311
7320
|
assertPrjPoint(other);
|
|
6312
7321
|
const { px: X1, py: Y1, pz: Z1 } = this;
|
|
6313
7322
|
const { px: X2, py: Y2, pz: Z2 } = other;
|
|
6314
|
-
const U1 =
|
|
6315
|
-
const U22 =
|
|
7323
|
+
const U1 = Fp2.eql(Fp2.mul(X1, Z2), Fp2.mul(X2, Z1));
|
|
7324
|
+
const U22 = Fp2.eql(Fp2.mul(Y1, Z2), Fp2.mul(Y2, Z1));
|
|
6316
7325
|
return U1 && U22;
|
|
6317
7326
|
}
|
|
6318
7327
|
/**
|
|
6319
7328
|
* Flips point to one corresponding to (x, -y) in Affine coordinates.
|
|
6320
7329
|
*/
|
|
6321
7330
|
negate() {
|
|
6322
|
-
return new
|
|
7331
|
+
return new Point3(this.px, Fp2.neg(this.py), this.pz);
|
|
6323
7332
|
}
|
|
6324
7333
|
// Renes-Costello-Batina exception-free doubling formula.
|
|
6325
7334
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -6327,41 +7336,41 @@ function weierstrassPoints(opts) {
|
|
|
6327
7336
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
6328
7337
|
double() {
|
|
6329
7338
|
const { a: a5, b: b2 } = CURVE2;
|
|
6330
|
-
const b3 =
|
|
7339
|
+
const b3 = Fp2.mul(b2, _3n$1);
|
|
6331
7340
|
const { px: X1, py: Y1, pz: Z1 } = this;
|
|
6332
|
-
let X3 =
|
|
6333
|
-
let t0 =
|
|
6334
|
-
let t1 =
|
|
6335
|
-
let t22 =
|
|
6336
|
-
let t32 =
|
|
6337
|
-
t32 =
|
|
6338
|
-
Z3 =
|
|
6339
|
-
Z3 =
|
|
6340
|
-
X3 =
|
|
6341
|
-
Y3 =
|
|
6342
|
-
Y3 =
|
|
6343
|
-
X3 =
|
|
6344
|
-
Y3 =
|
|
6345
|
-
Y3 =
|
|
6346
|
-
X3 =
|
|
6347
|
-
Z3 =
|
|
6348
|
-
t22 =
|
|
6349
|
-
t32 =
|
|
6350
|
-
t32 =
|
|
6351
|
-
t32 =
|
|
6352
|
-
Z3 =
|
|
6353
|
-
t0 =
|
|
6354
|
-
t0 =
|
|
6355
|
-
t0 =
|
|
6356
|
-
Y3 =
|
|
6357
|
-
t22 =
|
|
6358
|
-
t22 =
|
|
6359
|
-
t0 =
|
|
6360
|
-
X3 =
|
|
6361
|
-
Z3 =
|
|
6362
|
-
Z3 =
|
|
6363
|
-
Z3 =
|
|
6364
|
-
return new
|
|
7341
|
+
let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
|
|
7342
|
+
let t0 = Fp2.mul(X1, X1);
|
|
7343
|
+
let t1 = Fp2.mul(Y1, Y1);
|
|
7344
|
+
let t22 = Fp2.mul(Z1, Z1);
|
|
7345
|
+
let t32 = Fp2.mul(X1, Y1);
|
|
7346
|
+
t32 = Fp2.add(t32, t32);
|
|
7347
|
+
Z3 = Fp2.mul(X1, Z1);
|
|
7348
|
+
Z3 = Fp2.add(Z3, Z3);
|
|
7349
|
+
X3 = Fp2.mul(a5, Z3);
|
|
7350
|
+
Y3 = Fp2.mul(b3, t22);
|
|
7351
|
+
Y3 = Fp2.add(X3, Y3);
|
|
7352
|
+
X3 = Fp2.sub(t1, Y3);
|
|
7353
|
+
Y3 = Fp2.add(t1, Y3);
|
|
7354
|
+
Y3 = Fp2.mul(X3, Y3);
|
|
7355
|
+
X3 = Fp2.mul(t32, X3);
|
|
7356
|
+
Z3 = Fp2.mul(b3, Z3);
|
|
7357
|
+
t22 = Fp2.mul(a5, t22);
|
|
7358
|
+
t32 = Fp2.sub(t0, t22);
|
|
7359
|
+
t32 = Fp2.mul(a5, t32);
|
|
7360
|
+
t32 = Fp2.add(t32, Z3);
|
|
7361
|
+
Z3 = Fp2.add(t0, t0);
|
|
7362
|
+
t0 = Fp2.add(Z3, t0);
|
|
7363
|
+
t0 = Fp2.add(t0, t22);
|
|
7364
|
+
t0 = Fp2.mul(t0, t32);
|
|
7365
|
+
Y3 = Fp2.add(Y3, t0);
|
|
7366
|
+
t22 = Fp2.mul(Y1, Z1);
|
|
7367
|
+
t22 = Fp2.add(t22, t22);
|
|
7368
|
+
t0 = Fp2.mul(t22, t32);
|
|
7369
|
+
X3 = Fp2.sub(X3, t0);
|
|
7370
|
+
Z3 = Fp2.mul(t22, t1);
|
|
7371
|
+
Z3 = Fp2.add(Z3, Z3);
|
|
7372
|
+
Z3 = Fp2.add(Z3, Z3);
|
|
7373
|
+
return new Point3(X3, Y3, Z3);
|
|
6365
7374
|
}
|
|
6366
7375
|
// Renes-Costello-Batina exception-free addition formula.
|
|
6367
7376
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -6371,59 +7380,59 @@ function weierstrassPoints(opts) {
|
|
|
6371
7380
|
assertPrjPoint(other);
|
|
6372
7381
|
const { px: X1, py: Y1, pz: Z1 } = this;
|
|
6373
7382
|
const { px: X2, py: Y2, pz: Z2 } = other;
|
|
6374
|
-
let X3 =
|
|
7383
|
+
let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
|
|
6375
7384
|
const a5 = CURVE2.a;
|
|
6376
|
-
const b3 =
|
|
6377
|
-
let t0 =
|
|
6378
|
-
let t1 =
|
|
6379
|
-
let t22 =
|
|
6380
|
-
let t32 =
|
|
6381
|
-
let t42 =
|
|
6382
|
-
t32 =
|
|
6383
|
-
t42 =
|
|
6384
|
-
t32 =
|
|
6385
|
-
t42 =
|
|
6386
|
-
let t52 =
|
|
6387
|
-
t42 =
|
|
6388
|
-
t52 =
|
|
6389
|
-
t42 =
|
|
6390
|
-
t52 =
|
|
6391
|
-
X3 =
|
|
6392
|
-
t52 =
|
|
6393
|
-
X3 =
|
|
6394
|
-
t52 =
|
|
6395
|
-
Z3 =
|
|
6396
|
-
X3 =
|
|
6397
|
-
Z3 =
|
|
6398
|
-
X3 =
|
|
6399
|
-
Z3 =
|
|
6400
|
-
Y3 =
|
|
6401
|
-
t1 =
|
|
6402
|
-
t1 =
|
|
6403
|
-
t22 =
|
|
6404
|
-
t42 =
|
|
6405
|
-
t1 =
|
|
6406
|
-
t22 =
|
|
6407
|
-
t22 =
|
|
6408
|
-
t42 =
|
|
6409
|
-
t0 =
|
|
6410
|
-
Y3 =
|
|
6411
|
-
t0 =
|
|
6412
|
-
X3 =
|
|
6413
|
-
X3 =
|
|
6414
|
-
t0 =
|
|
6415
|
-
Z3 =
|
|
6416
|
-
Z3 =
|
|
6417
|
-
return new
|
|
7385
|
+
const b3 = Fp2.mul(CURVE2.b, _3n$1);
|
|
7386
|
+
let t0 = Fp2.mul(X1, X2);
|
|
7387
|
+
let t1 = Fp2.mul(Y1, Y2);
|
|
7388
|
+
let t22 = Fp2.mul(Z1, Z2);
|
|
7389
|
+
let t32 = Fp2.add(X1, Y1);
|
|
7390
|
+
let t42 = Fp2.add(X2, Y2);
|
|
7391
|
+
t32 = Fp2.mul(t32, t42);
|
|
7392
|
+
t42 = Fp2.add(t0, t1);
|
|
7393
|
+
t32 = Fp2.sub(t32, t42);
|
|
7394
|
+
t42 = Fp2.add(X1, Z1);
|
|
7395
|
+
let t52 = Fp2.add(X2, Z2);
|
|
7396
|
+
t42 = Fp2.mul(t42, t52);
|
|
7397
|
+
t52 = Fp2.add(t0, t22);
|
|
7398
|
+
t42 = Fp2.sub(t42, t52);
|
|
7399
|
+
t52 = Fp2.add(Y1, Z1);
|
|
7400
|
+
X3 = Fp2.add(Y2, Z2);
|
|
7401
|
+
t52 = Fp2.mul(t52, X3);
|
|
7402
|
+
X3 = Fp2.add(t1, t22);
|
|
7403
|
+
t52 = Fp2.sub(t52, X3);
|
|
7404
|
+
Z3 = Fp2.mul(a5, t42);
|
|
7405
|
+
X3 = Fp2.mul(b3, t22);
|
|
7406
|
+
Z3 = Fp2.add(X3, Z3);
|
|
7407
|
+
X3 = Fp2.sub(t1, Z3);
|
|
7408
|
+
Z3 = Fp2.add(t1, Z3);
|
|
7409
|
+
Y3 = Fp2.mul(X3, Z3);
|
|
7410
|
+
t1 = Fp2.add(t0, t0);
|
|
7411
|
+
t1 = Fp2.add(t1, t0);
|
|
7412
|
+
t22 = Fp2.mul(a5, t22);
|
|
7413
|
+
t42 = Fp2.mul(b3, t42);
|
|
7414
|
+
t1 = Fp2.add(t1, t22);
|
|
7415
|
+
t22 = Fp2.sub(t0, t22);
|
|
7416
|
+
t22 = Fp2.mul(a5, t22);
|
|
7417
|
+
t42 = Fp2.add(t42, t22);
|
|
7418
|
+
t0 = Fp2.mul(t1, t42);
|
|
7419
|
+
Y3 = Fp2.add(Y3, t0);
|
|
7420
|
+
t0 = Fp2.mul(t52, t42);
|
|
7421
|
+
X3 = Fp2.mul(t32, X3);
|
|
7422
|
+
X3 = Fp2.sub(X3, t0);
|
|
7423
|
+
t0 = Fp2.mul(t32, t1);
|
|
7424
|
+
Z3 = Fp2.mul(t52, Z3);
|
|
7425
|
+
Z3 = Fp2.add(Z3, t0);
|
|
7426
|
+
return new Point3(X3, Y3, Z3);
|
|
6418
7427
|
}
|
|
6419
7428
|
subtract(other) {
|
|
6420
7429
|
return this.add(other.negate());
|
|
6421
7430
|
}
|
|
6422
7431
|
is0() {
|
|
6423
|
-
return this.equals(
|
|
7432
|
+
return this.equals(Point3.ZERO);
|
|
6424
7433
|
}
|
|
6425
7434
|
wNAF(n4) {
|
|
6426
|
-
return wnaf.wNAFCached(this, n4,
|
|
7435
|
+
return wnaf.wNAFCached(this, n4, Point3.normalizeZ);
|
|
6427
7436
|
}
|
|
6428
7437
|
/**
|
|
6429
7438
|
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
@@ -6432,32 +7441,32 @@ function weierstrassPoints(opts) {
|
|
|
6432
7441
|
*/
|
|
6433
7442
|
multiplyUnsafe(sc) {
|
|
6434
7443
|
const { endo, n: N2 } = CURVE2;
|
|
6435
|
-
aInRange("scalar", sc, _0n$
|
|
6436
|
-
const
|
|
6437
|
-
if (sc === _0n$
|
|
6438
|
-
return
|
|
6439
|
-
if (this.is0() || sc === _1n$
|
|
7444
|
+
aInRange("scalar", sc, _0n$3, N2);
|
|
7445
|
+
const I2 = Point3.ZERO;
|
|
7446
|
+
if (sc === _0n$3)
|
|
7447
|
+
return I2;
|
|
7448
|
+
if (this.is0() || sc === _1n$5)
|
|
6440
7449
|
return this;
|
|
6441
7450
|
if (!endo || wnaf.hasPrecomputes(this))
|
|
6442
|
-
return wnaf.wNAFCachedUnsafe(this, sc,
|
|
7451
|
+
return wnaf.wNAFCachedUnsafe(this, sc, Point3.normalizeZ);
|
|
6443
7452
|
let { k1neg, k1, k2neg, k2 } = endo.splitScalar(sc);
|
|
6444
|
-
let k1p =
|
|
6445
|
-
let k2p =
|
|
7453
|
+
let k1p = I2;
|
|
7454
|
+
let k2p = I2;
|
|
6446
7455
|
let d2 = this;
|
|
6447
|
-
while (k1 > _0n$
|
|
6448
|
-
if (k1 & _1n$
|
|
7456
|
+
while (k1 > _0n$3 || k2 > _0n$3) {
|
|
7457
|
+
if (k1 & _1n$5)
|
|
6449
7458
|
k1p = k1p.add(d2);
|
|
6450
|
-
if (k2 & _1n$
|
|
7459
|
+
if (k2 & _1n$5)
|
|
6451
7460
|
k2p = k2p.add(d2);
|
|
6452
7461
|
d2 = d2.double();
|
|
6453
|
-
k1 >>= _1n$
|
|
6454
|
-
k2 >>= _1n$
|
|
7462
|
+
k1 >>= _1n$5;
|
|
7463
|
+
k2 >>= _1n$5;
|
|
6455
7464
|
}
|
|
6456
7465
|
if (k1neg)
|
|
6457
7466
|
k1p = k1p.negate();
|
|
6458
7467
|
if (k2neg)
|
|
6459
7468
|
k2p = k2p.negate();
|
|
6460
|
-
k2p = new
|
|
7469
|
+
k2p = new Point3(Fp2.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
|
|
6461
7470
|
return k1p.add(k2p);
|
|
6462
7471
|
}
|
|
6463
7472
|
/**
|
|
@@ -6471,7 +7480,7 @@ function weierstrassPoints(opts) {
|
|
|
6471
7480
|
*/
|
|
6472
7481
|
multiply(scalar) {
|
|
6473
7482
|
const { endo, n: N2 } = CURVE2;
|
|
6474
|
-
aInRange("scalar", scalar, _1n$
|
|
7483
|
+
aInRange("scalar", scalar, _1n$5, N2);
|
|
6475
7484
|
let point, fake;
|
|
6476
7485
|
if (endo) {
|
|
6477
7486
|
const { k1neg, k1, k2neg, k2 } = endo.splitScalar(scalar);
|
|
@@ -6479,7 +7488,7 @@ function weierstrassPoints(opts) {
|
|
|
6479
7488
|
let { p: k2p, f: f2p } = this.wNAF(k2);
|
|
6480
7489
|
k1p = wnaf.constTimeNegate(k1neg, k1p);
|
|
6481
7490
|
k2p = wnaf.constTimeNegate(k2neg, k2p);
|
|
6482
|
-
k2p = new
|
|
7491
|
+
k2p = new Point3(Fp2.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
|
|
6483
7492
|
point = k1p.add(k2p);
|
|
6484
7493
|
fake = f1p.add(f2p);
|
|
6485
7494
|
} else {
|
|
@@ -6487,7 +7496,7 @@ function weierstrassPoints(opts) {
|
|
|
6487
7496
|
point = p5;
|
|
6488
7497
|
fake = f3;
|
|
6489
7498
|
}
|
|
6490
|
-
return
|
|
7499
|
+
return Point3.normalizeZ([point, fake])[0];
|
|
6491
7500
|
}
|
|
6492
7501
|
/**
|
|
6493
7502
|
* Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
|
|
@@ -6496,8 +7505,8 @@ function weierstrassPoints(opts) {
|
|
|
6496
7505
|
* @returns non-zero affine point
|
|
6497
7506
|
*/
|
|
6498
7507
|
multiplyAndAddUnsafe(Q, a5, b2) {
|
|
6499
|
-
const G2 =
|
|
6500
|
-
const mul = (
|
|
7508
|
+
const G2 = Point3.BASE;
|
|
7509
|
+
const mul = (P2, a6) => a6 === _0n$3 || a6 === _1n$5 || !P2.equals(G2) ? P2.multiplyUnsafe(a6) : P2.multiply(a6);
|
|
6501
7510
|
const sum = mul(this, a5).add(mul(Q, b2));
|
|
6502
7511
|
return sum.is0() ? void 0 : sum;
|
|
6503
7512
|
}
|
|
@@ -6509,43 +7518,43 @@ function weierstrassPoints(opts) {
|
|
|
6509
7518
|
}
|
|
6510
7519
|
isTorsionFree() {
|
|
6511
7520
|
const { h: cofactor, isTorsionFree } = CURVE2;
|
|
6512
|
-
if (cofactor === _1n$
|
|
7521
|
+
if (cofactor === _1n$5)
|
|
6513
7522
|
return true;
|
|
6514
7523
|
if (isTorsionFree)
|
|
6515
|
-
return isTorsionFree(
|
|
7524
|
+
return isTorsionFree(Point3, this);
|
|
6516
7525
|
throw new Error("isTorsionFree() has not been declared for the elliptic curve");
|
|
6517
7526
|
}
|
|
6518
7527
|
clearCofactor() {
|
|
6519
7528
|
const { h: cofactor, clearCofactor } = CURVE2;
|
|
6520
|
-
if (cofactor === _1n$
|
|
7529
|
+
if (cofactor === _1n$5)
|
|
6521
7530
|
return this;
|
|
6522
7531
|
if (clearCofactor)
|
|
6523
|
-
return clearCofactor(
|
|
7532
|
+
return clearCofactor(Point3, this);
|
|
6524
7533
|
return this.multiplyUnsafe(CURVE2.h);
|
|
6525
7534
|
}
|
|
6526
7535
|
toRawBytes(isCompressed = true) {
|
|
6527
7536
|
abool("isCompressed", isCompressed);
|
|
6528
7537
|
this.assertValidity();
|
|
6529
|
-
return toBytes2(
|
|
7538
|
+
return toBytes2(Point3, this, isCompressed);
|
|
6530
7539
|
}
|
|
6531
7540
|
toHex(isCompressed = true) {
|
|
6532
7541
|
abool("isCompressed", isCompressed);
|
|
6533
7542
|
return bytesToHex(this.toRawBytes(isCompressed));
|
|
6534
7543
|
}
|
|
6535
7544
|
}
|
|
6536
|
-
|
|
6537
|
-
|
|
7545
|
+
Point3.BASE = new Point3(CURVE2.Gx, CURVE2.Gy, Fp2.ONE);
|
|
7546
|
+
Point3.ZERO = new Point3(Fp2.ZERO, Fp2.ONE, Fp2.ZERO);
|
|
6538
7547
|
const _bits = CURVE2.nBitLength;
|
|
6539
|
-
const wnaf = wNAF$1(
|
|
7548
|
+
const wnaf = wNAF$1(Point3, CURVE2.endo ? Math.ceil(_bits / 2) : _bits);
|
|
6540
7549
|
return {
|
|
6541
7550
|
CURVE: CURVE2,
|
|
6542
|
-
ProjectivePoint:
|
|
7551
|
+
ProjectivePoint: Point3,
|
|
6543
7552
|
normPrivateKeyToScalar,
|
|
6544
7553
|
weierstrassEquation,
|
|
6545
7554
|
isWithinCurveOrder
|
|
6546
7555
|
};
|
|
6547
7556
|
}
|
|
6548
|
-
function validateOpts(curve2) {
|
|
7557
|
+
function validateOpts$1(curve2) {
|
|
6549
7558
|
const opts = validateBasic(curve2);
|
|
6550
7559
|
validateObject(opts, {
|
|
6551
7560
|
hash: "hash",
|
|
@@ -6559,27 +7568,27 @@ function validateOpts(curve2) {
|
|
|
6559
7568
|
return Object.freeze({ lowS: true, ...opts });
|
|
6560
7569
|
}
|
|
6561
7570
|
function weierstrass(curveDef) {
|
|
6562
|
-
const CURVE2 = validateOpts(curveDef);
|
|
6563
|
-
const { Fp, n: CURVE_ORDER } = CURVE2;
|
|
6564
|
-
const compressedLen =
|
|
6565
|
-
const uncompressedLen = 2 *
|
|
7571
|
+
const CURVE2 = validateOpts$1(curveDef);
|
|
7572
|
+
const { Fp: Fp2, n: CURVE_ORDER } = CURVE2;
|
|
7573
|
+
const compressedLen = Fp2.BYTES + 1;
|
|
7574
|
+
const uncompressedLen = 2 * Fp2.BYTES + 1;
|
|
6566
7575
|
function modN(a5) {
|
|
6567
7576
|
return mod(a5, CURVE_ORDER);
|
|
6568
7577
|
}
|
|
6569
7578
|
function invN(a5) {
|
|
6570
7579
|
return invert(a5, CURVE_ORDER);
|
|
6571
7580
|
}
|
|
6572
|
-
const { ProjectivePoint:
|
|
7581
|
+
const { ProjectivePoint: Point3, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
|
|
6573
7582
|
...CURVE2,
|
|
6574
7583
|
toBytes(_c4, point, isCompressed) {
|
|
6575
7584
|
const a5 = point.toAffine();
|
|
6576
|
-
const x2 =
|
|
7585
|
+
const x2 = Fp2.toBytes(a5.x);
|
|
6577
7586
|
const cat = concatBytes;
|
|
6578
7587
|
abool("isCompressed", isCompressed);
|
|
6579
7588
|
if (isCompressed) {
|
|
6580
7589
|
return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x2);
|
|
6581
7590
|
} else {
|
|
6582
|
-
return cat(Uint8Array.from([4]), x2,
|
|
7591
|
+
return cat(Uint8Array.from([4]), x2, Fp2.toBytes(a5.y));
|
|
6583
7592
|
}
|
|
6584
7593
|
},
|
|
6585
7594
|
fromBytes(bytes) {
|
|
@@ -6588,24 +7597,24 @@ function weierstrass(curveDef) {
|
|
|
6588
7597
|
const tail = bytes.subarray(1);
|
|
6589
7598
|
if (len === compressedLen && (head === 2 || head === 3)) {
|
|
6590
7599
|
const x2 = bytesToNumberBE(tail);
|
|
6591
|
-
if (!inRange(x2, _1n$
|
|
7600
|
+
if (!inRange(x2, _1n$5, Fp2.ORDER))
|
|
6592
7601
|
throw new Error("Point is not on curve");
|
|
6593
7602
|
const y22 = weierstrassEquation(x2);
|
|
6594
7603
|
let y3;
|
|
6595
7604
|
try {
|
|
6596
|
-
y3 =
|
|
7605
|
+
y3 = Fp2.sqrt(y22);
|
|
6597
7606
|
} catch (sqrtError) {
|
|
6598
7607
|
const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
|
|
6599
7608
|
throw new Error("Point is not on curve" + suffix);
|
|
6600
7609
|
}
|
|
6601
|
-
const isYOdd = (y3 & _1n$
|
|
7610
|
+
const isYOdd = (y3 & _1n$5) === _1n$5;
|
|
6602
7611
|
const isHeadOdd = (head & 1) === 1;
|
|
6603
7612
|
if (isHeadOdd !== isYOdd)
|
|
6604
|
-
y3 =
|
|
7613
|
+
y3 = Fp2.neg(y3);
|
|
6605
7614
|
return { x: x2, y: y3 };
|
|
6606
7615
|
} else if (len === uncompressedLen && head === 4) {
|
|
6607
|
-
const x2 =
|
|
6608
|
-
const y3 =
|
|
7616
|
+
const x2 = Fp2.fromBytes(tail.subarray(0, Fp2.BYTES));
|
|
7617
|
+
const y3 = Fp2.fromBytes(tail.subarray(Fp2.BYTES, 2 * Fp2.BYTES));
|
|
6609
7618
|
return { x: x2, y: y3 };
|
|
6610
7619
|
} else {
|
|
6611
7620
|
const cl = compressedLen;
|
|
@@ -6616,7 +7625,7 @@ function weierstrass(curveDef) {
|
|
|
6616
7625
|
});
|
|
6617
7626
|
const numToNByteStr = (num) => bytesToHex(numberToBytesBE(num, CURVE2.nByteLength));
|
|
6618
7627
|
function isBiggerThanHalfOrder(number) {
|
|
6619
|
-
const HALF = CURVE_ORDER >> _1n$
|
|
7628
|
+
const HALF = CURVE_ORDER >> _1n$5;
|
|
6620
7629
|
return number > HALF;
|
|
6621
7630
|
}
|
|
6622
7631
|
function normalizeS(s5) {
|
|
@@ -6643,8 +7652,8 @@ function weierstrass(curveDef) {
|
|
|
6643
7652
|
return new Signature(r7, s5);
|
|
6644
7653
|
}
|
|
6645
7654
|
assertValidity() {
|
|
6646
|
-
aInRange("r", this.r, _1n$
|
|
6647
|
-
aInRange("s", this.s, _1n$
|
|
7655
|
+
aInRange("r", this.r, _1n$5, CURVE_ORDER);
|
|
7656
|
+
aInRange("s", this.s, _1n$5, CURVE_ORDER);
|
|
6648
7657
|
}
|
|
6649
7658
|
addRecoveryBit(recovery) {
|
|
6650
7659
|
return new Signature(this.r, this.s, recovery);
|
|
@@ -6655,14 +7664,14 @@ function weierstrass(curveDef) {
|
|
|
6655
7664
|
if (rec == null || ![0, 1, 2, 3].includes(rec))
|
|
6656
7665
|
throw new Error("recovery id invalid");
|
|
6657
7666
|
const radj = rec === 2 || rec === 3 ? r7 + CURVE2.n : r7;
|
|
6658
|
-
if (radj >=
|
|
7667
|
+
if (radj >= Fp2.ORDER)
|
|
6659
7668
|
throw new Error("recovery id 2 or 3 invalid");
|
|
6660
7669
|
const prefix = (rec & 1) === 0 ? "02" : "03";
|
|
6661
|
-
const R2 =
|
|
7670
|
+
const R2 = Point3.fromHex(prefix + numToNByteStr(radj));
|
|
6662
7671
|
const ir = invN(radj);
|
|
6663
7672
|
const u1 = modN(-h2 * ir);
|
|
6664
7673
|
const u22 = modN(s5 * ir);
|
|
6665
|
-
const Q =
|
|
7674
|
+
const Q = Point3.BASE.multiplyAndAddUnsafe(R2, u1, u22);
|
|
6666
7675
|
if (!Q)
|
|
6667
7676
|
throw new Error("point at infinify");
|
|
6668
7677
|
Q.assertValidity();
|
|
@@ -6716,14 +7725,14 @@ function weierstrass(curveDef) {
|
|
|
6716
7725
|
* const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
|
|
6717
7726
|
* fast.multiply(privKey); // much faster ECDH now
|
|
6718
7727
|
*/
|
|
6719
|
-
precompute(windowSize = 8, point =
|
|
7728
|
+
precompute(windowSize = 8, point = Point3.BASE) {
|
|
6720
7729
|
point._setWindowSize(windowSize);
|
|
6721
7730
|
point.multiply(BigInt(3));
|
|
6722
7731
|
return point;
|
|
6723
7732
|
}
|
|
6724
7733
|
};
|
|
6725
7734
|
function getPublicKey2(privateKey, isCompressed = true) {
|
|
6726
|
-
return
|
|
7735
|
+
return Point3.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
|
6727
7736
|
}
|
|
6728
7737
|
function isProbPub(item) {
|
|
6729
7738
|
const arr = isBytes$2(item);
|
|
@@ -6733,7 +7742,7 @@ function weierstrass(curveDef) {
|
|
|
6733
7742
|
return len === compressedLen || len === uncompressedLen;
|
|
6734
7743
|
if (str)
|
|
6735
7744
|
return len === 2 * compressedLen || len === 2 * uncompressedLen;
|
|
6736
|
-
if (item instanceof
|
|
7745
|
+
if (item instanceof Point3)
|
|
6737
7746
|
return true;
|
|
6738
7747
|
return false;
|
|
6739
7748
|
}
|
|
@@ -6742,7 +7751,7 @@ function weierstrass(curveDef) {
|
|
|
6742
7751
|
throw new Error("first arg must be private key");
|
|
6743
7752
|
if (!isProbPub(publicB))
|
|
6744
7753
|
throw new Error("second arg must be public key");
|
|
6745
|
-
const b2 =
|
|
7754
|
+
const b2 = Point3.fromHex(publicB);
|
|
6746
7755
|
return b2.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
|
|
6747
7756
|
}
|
|
6748
7757
|
const bits2int = CURVE2.bits2int || function(bytes) {
|
|
@@ -6757,7 +7766,7 @@ function weierstrass(curveDef) {
|
|
|
6757
7766
|
};
|
|
6758
7767
|
const ORDER_MASK = bitMask(CURVE2.nBitLength);
|
|
6759
7768
|
function int2octets(num) {
|
|
6760
|
-
aInRange("num < 2^" + CURVE2.nBitLength, num, _0n$
|
|
7769
|
+
aInRange("num < 2^" + CURVE2.nBitLength, num, _0n$3, ORDER_MASK);
|
|
6761
7770
|
return numberToBytesBE(num, CURVE2.nByteLength);
|
|
6762
7771
|
}
|
|
6763
7772
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
@@ -6775,7 +7784,7 @@ function weierstrass(curveDef) {
|
|
|
6775
7784
|
const d2 = normPrivateKeyToScalar(privateKey);
|
|
6776
7785
|
const seedArgs = [int2octets(d2), int2octets(h1int)];
|
|
6777
7786
|
if (ent != null && ent !== false) {
|
|
6778
|
-
const e4 = ent === true ? randomBytes2(
|
|
7787
|
+
const e4 = ent === true ? randomBytes2(Fp2.BYTES) : ent;
|
|
6779
7788
|
seedArgs.push(ensureBytes("extraEntropy", e4));
|
|
6780
7789
|
}
|
|
6781
7790
|
const seed = concatBytes(...seedArgs);
|
|
@@ -6785,14 +7794,14 @@ function weierstrass(curveDef) {
|
|
|
6785
7794
|
if (!isWithinCurveOrder(k2))
|
|
6786
7795
|
return;
|
|
6787
7796
|
const ik = invN(k2);
|
|
6788
|
-
const q2 =
|
|
7797
|
+
const q2 = Point3.BASE.multiply(k2).toAffine();
|
|
6789
7798
|
const r7 = modN(q2.x);
|
|
6790
|
-
if (r7 === _0n$
|
|
7799
|
+
if (r7 === _0n$3)
|
|
6791
7800
|
return;
|
|
6792
7801
|
const s5 = modN(ik * modN(m2 + r7 * d2));
|
|
6793
|
-
if (s5 === _0n$
|
|
7802
|
+
if (s5 === _0n$3)
|
|
6794
7803
|
return;
|
|
6795
|
-
let recovery = (q2.x === r7 ? 0 : 2) | Number(q2.y & _1n$
|
|
7804
|
+
let recovery = (q2.x === r7 ? 0 : 2) | Number(q2.y & _1n$5);
|
|
6796
7805
|
let normS = s5;
|
|
6797
7806
|
if (lowS && isBiggerThanHalfOrder(s5)) {
|
|
6798
7807
|
normS = normalizeS(s5);
|
|
@@ -6806,11 +7815,11 @@ function weierstrass(curveDef) {
|
|
|
6806
7815
|
const defaultVerOpts = { lowS: CURVE2.lowS, prehash: false };
|
|
6807
7816
|
function sign(msgHash, privKey, opts = defaultSigOpts) {
|
|
6808
7817
|
const { seed, k2sig } = prepSig(msgHash, privKey, opts);
|
|
6809
|
-
const
|
|
6810
|
-
const drbg = createHmacDrbg(
|
|
7818
|
+
const C2 = CURVE2;
|
|
7819
|
+
const drbg = createHmacDrbg(C2.hash.outputLen, C2.nByteLength, C2.hmac);
|
|
6811
7820
|
return drbg(seed, k2sig);
|
|
6812
7821
|
}
|
|
6813
|
-
|
|
7822
|
+
Point3.BASE._setWindowSize(8);
|
|
6814
7823
|
function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
|
|
6815
7824
|
var _a4;
|
|
6816
7825
|
const sg = signature;
|
|
@@ -6827,7 +7836,7 @@ function weierstrass(curveDef) {
|
|
|
6827
7836
|
if (!isHex && !isObj)
|
|
6828
7837
|
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
6829
7838
|
let _sig = void 0;
|
|
6830
|
-
let
|
|
7839
|
+
let P2;
|
|
6831
7840
|
try {
|
|
6832
7841
|
if (isObj)
|
|
6833
7842
|
_sig = new Signature(sg.r, sg.s);
|
|
@@ -6842,7 +7851,7 @@ function weierstrass(curveDef) {
|
|
|
6842
7851
|
if (!_sig && format !== "der")
|
|
6843
7852
|
_sig = Signature.fromCompact(sg);
|
|
6844
7853
|
}
|
|
6845
|
-
|
|
7854
|
+
P2 = Point3.fromHex(publicKey);
|
|
6846
7855
|
} catch (error) {
|
|
6847
7856
|
return false;
|
|
6848
7857
|
}
|
|
@@ -6857,7 +7866,7 @@ function weierstrass(curveDef) {
|
|
|
6857
7866
|
const is = invN(s5);
|
|
6858
7867
|
const u1 = modN(h2 * is);
|
|
6859
7868
|
const u22 = modN(r7 * is);
|
|
6860
|
-
const R2 = (_a4 =
|
|
7869
|
+
const R2 = (_a4 = Point3.BASE.multiplyAndAddUnsafe(P2, u1, u22)) == null ? void 0 : _a4.toAffine();
|
|
6861
7870
|
if (!R2)
|
|
6862
7871
|
return false;
|
|
6863
7872
|
const v2 = modN(R2.x);
|
|
@@ -6869,7 +7878,7 @@ function weierstrass(curveDef) {
|
|
|
6869
7878
|
getSharedSecret,
|
|
6870
7879
|
sign,
|
|
6871
7880
|
verify,
|
|
6872
|
-
ProjectivePoint:
|
|
7881
|
+
ProjectivePoint: Point3,
|
|
6873
7882
|
Signature,
|
|
6874
7883
|
utils: utils2
|
|
6875
7884
|
};
|
|
@@ -6889,27 +7898,27 @@ function createCurve(curveDef, defHash) {
|
|
|
6889
7898
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
6890
7899
|
const secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
|
|
6891
7900
|
const secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
|
6892
|
-
const _1n$
|
|
6893
|
-
const _2n$
|
|
6894
|
-
const divNearest = (a5, b2) => (a5 + b2 / _2n$
|
|
7901
|
+
const _1n$4 = BigInt(1);
|
|
7902
|
+
const _2n$4 = BigInt(2);
|
|
7903
|
+
const divNearest = (a5, b2) => (a5 + b2 / _2n$4) / b2;
|
|
6895
7904
|
function sqrtMod(y3) {
|
|
6896
|
-
const
|
|
7905
|
+
const P2 = secp256k1P;
|
|
6897
7906
|
const _3n2 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
|
|
6898
7907
|
const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
|
|
6899
|
-
const b2 = y3 * y3 * y3 %
|
|
6900
|
-
const b3 = b2 * b2 * y3 %
|
|
6901
|
-
const b6 = pow2(b3, _3n2,
|
|
6902
|
-
const b9 = pow2(b6, _3n2,
|
|
6903
|
-
const b11 = pow2(b9, _2n$
|
|
6904
|
-
const b22 = pow2(b11, _11n,
|
|
6905
|
-
const b44 = pow2(b22, _22n,
|
|
6906
|
-
const b88 = pow2(b44, _44n,
|
|
6907
|
-
const b176 = pow2(b88, _88n,
|
|
6908
|
-
const b220 = pow2(b176, _44n,
|
|
6909
|
-
const b223 = pow2(b220, _3n2,
|
|
6910
|
-
const t1 = pow2(b223, _23n,
|
|
6911
|
-
const t22 = pow2(t1, _6n,
|
|
6912
|
-
const root2 = pow2(t22, _2n$
|
|
7908
|
+
const b2 = y3 * y3 * y3 % P2;
|
|
7909
|
+
const b3 = b2 * b2 * y3 % P2;
|
|
7910
|
+
const b6 = pow2(b3, _3n2, P2) * b3 % P2;
|
|
7911
|
+
const b9 = pow2(b6, _3n2, P2) * b3 % P2;
|
|
7912
|
+
const b11 = pow2(b9, _2n$4, P2) * b2 % P2;
|
|
7913
|
+
const b22 = pow2(b11, _11n, P2) * b11 % P2;
|
|
7914
|
+
const b44 = pow2(b22, _22n, P2) * b22 % P2;
|
|
7915
|
+
const b88 = pow2(b44, _44n, P2) * b44 % P2;
|
|
7916
|
+
const b176 = pow2(b88, _88n, P2) * b88 % P2;
|
|
7917
|
+
const b220 = pow2(b176, _44n, P2) * b44 % P2;
|
|
7918
|
+
const b223 = pow2(b220, _3n2, P2) * b3 % P2;
|
|
7919
|
+
const t1 = pow2(b223, _23n, P2) * b22 % P2;
|
|
7920
|
+
const t22 = pow2(t1, _6n, P2) * b2 % P2;
|
|
7921
|
+
const root2 = pow2(t22, _2n$4, P2);
|
|
6913
7922
|
if (!Fpk1.eql(Fpk1.sqr(root2), y3))
|
|
6914
7923
|
throw new Error("Cannot find square root");
|
|
6915
7924
|
return root2;
|
|
@@ -6936,7 +7945,7 @@ const secp256k1 = createCurve({
|
|
|
6936
7945
|
splitScalar: (k2) => {
|
|
6937
7946
|
const n4 = secp256k1N;
|
|
6938
7947
|
const a1 = BigInt("0x3086d221a7d46bcde86c90e49284eb15");
|
|
6939
|
-
const b1 = -_1n$
|
|
7948
|
+
const b1 = -_1n$4 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3");
|
|
6940
7949
|
const a22 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");
|
|
6941
7950
|
const b2 = a1;
|
|
6942
7951
|
const POW_2_128 = BigInt("0x100000000000000000000000000000000");
|
|
@@ -6964,6 +7973,1108 @@ function delegationMessage(terms) {
|
|
|
6964
7973
|
const expires = BigInt(terms.deadline) === 0n ? "never" : BigInt(terms.deadline).toString(10);
|
|
6965
7974
|
return HEAD + terms.delegate.toLowerCase() + "\nContract: " + terms.contract.toLowerCase() + "\nChain ID: " + BigInt(terms.chainId).toString(10) + "\nExpires: " + expires;
|
|
6966
7975
|
}
|
|
7976
|
+
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
|
7977
|
+
const B256 = 2n ** 256n;
|
|
7978
|
+
const P$2 = B256 - 0x1000003d1n;
|
|
7979
|
+
const N$1 = B256 - 0x14551231950b75fc4402da1732fc9bebfn;
|
|
7980
|
+
const Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n;
|
|
7981
|
+
const Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;
|
|
7982
|
+
const CURVE = {
|
|
7983
|
+
a: 0n,
|
|
7984
|
+
b: 7n
|
|
7985
|
+
};
|
|
7986
|
+
const fLen = 32;
|
|
7987
|
+
const curve = (x2) => M$1(M$1(x2 * x2) * x2 + CURVE.b);
|
|
7988
|
+
const err = (m2 = "") => {
|
|
7989
|
+
throw new Error(m2);
|
|
7990
|
+
};
|
|
7991
|
+
const isB = (n4) => typeof n4 === "bigint";
|
|
7992
|
+
const isS = (s5) => typeof s5 === "string";
|
|
7993
|
+
const fe = (n4) => isB(n4) && 0n < n4 && n4 < P$2;
|
|
7994
|
+
const ge = (n4) => isB(n4) && 0n < n4 && n4 < N$1;
|
|
7995
|
+
const isu8 = (a5) => a5 instanceof Uint8Array || ArrayBuffer.isView(a5) && a5.constructor.name === "Uint8Array";
|
|
7996
|
+
const au8 = (a5, l3) => (
|
|
7997
|
+
// assert is Uint8Array (of specific length)
|
|
7998
|
+
!isu8(a5) || typeof l3 === "number" && l3 > 0 && a5.length !== l3 ? err("Uint8Array expected") : a5
|
|
7999
|
+
);
|
|
8000
|
+
const u8n = (data) => new Uint8Array(data);
|
|
8001
|
+
const toU8 = (a5, len) => au8(isS(a5) ? h2b(a5) : u8n(au8(a5)), len);
|
|
8002
|
+
const M$1 = (a5, b2 = P$2) => {
|
|
8003
|
+
const r7 = a5 % b2;
|
|
8004
|
+
return r7 >= 0n ? r7 : b2 + r7;
|
|
8005
|
+
};
|
|
8006
|
+
const aPoint = (p5) => p5 instanceof Point$1 ? p5 : err("Point expected");
|
|
8007
|
+
let Point$1 = class Point {
|
|
8008
|
+
constructor(px, py, pz) {
|
|
8009
|
+
this.px = px;
|
|
8010
|
+
this.py = py;
|
|
8011
|
+
this.pz = pz;
|
|
8012
|
+
Object.freeze(this);
|
|
8013
|
+
}
|
|
8014
|
+
/** Create 3d xyz point from 2d xy. (0, 0) => (0, 1, 0), not (0, 0, 1) */
|
|
8015
|
+
static fromAffine(p5) {
|
|
8016
|
+
return p5.x === 0n && p5.y === 0n ? I$1 : new Point(p5.x, p5.y, 1n);
|
|
8017
|
+
}
|
|
8018
|
+
/** Convert Uint8Array or hex string to Point. */
|
|
8019
|
+
static fromHex(hex) {
|
|
8020
|
+
hex = toU8(hex);
|
|
8021
|
+
let p5 = void 0;
|
|
8022
|
+
const head = hex[0], tail = hex.subarray(1);
|
|
8023
|
+
const x2 = slc(tail, 0, fLen), len = hex.length;
|
|
8024
|
+
if (len === 33 && [2, 3].includes(head)) {
|
|
8025
|
+
if (!fe(x2))
|
|
8026
|
+
err("Point hex invalid: x not FE");
|
|
8027
|
+
let y3 = sqrt(curve(x2));
|
|
8028
|
+
const isYOdd = (y3 & 1n) === 1n;
|
|
8029
|
+
const headOdd = (head & 1) === 1;
|
|
8030
|
+
if (headOdd !== isYOdd)
|
|
8031
|
+
y3 = M$1(-y3);
|
|
8032
|
+
p5 = new Point(x2, y3, 1n);
|
|
8033
|
+
}
|
|
8034
|
+
if (len === 65 && head === 4)
|
|
8035
|
+
p5 = new Point(x2, slc(tail, fLen, 2 * fLen), 1n);
|
|
8036
|
+
return p5 ? p5.ok() : err("Point invalid: not on curve");
|
|
8037
|
+
}
|
|
8038
|
+
/** Create point from a private key. */
|
|
8039
|
+
static fromPrivateKey(k2) {
|
|
8040
|
+
return G$1.mul(toPriv(k2));
|
|
8041
|
+
}
|
|
8042
|
+
get x() {
|
|
8043
|
+
return this.aff().x;
|
|
8044
|
+
}
|
|
8045
|
+
// .x, .y will call expensive toAffine:
|
|
8046
|
+
get y() {
|
|
8047
|
+
return this.aff().y;
|
|
8048
|
+
}
|
|
8049
|
+
// should be used with care.
|
|
8050
|
+
/** Equality check: compare points P&Q. */
|
|
8051
|
+
equals(other) {
|
|
8052
|
+
const { px: X1, py: Y1, pz: Z1 } = this;
|
|
8053
|
+
const { px: X2, py: Y2, pz: Z2 } = aPoint(other);
|
|
8054
|
+
const X1Z2 = M$1(X1 * Z2), X2Z1 = M$1(X2 * Z1);
|
|
8055
|
+
const Y1Z2 = M$1(Y1 * Z2), Y2Z1 = M$1(Y2 * Z1);
|
|
8056
|
+
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
8057
|
+
}
|
|
8058
|
+
/** Flip point over y coordinate. */
|
|
8059
|
+
negate() {
|
|
8060
|
+
return new Point(this.px, M$1(-this.py), this.pz);
|
|
8061
|
+
}
|
|
8062
|
+
/** Point doubling: P+P, complete formula. */
|
|
8063
|
+
double() {
|
|
8064
|
+
return this.add(this);
|
|
8065
|
+
}
|
|
8066
|
+
/**
|
|
8067
|
+
* Point addition: P+Q, complete, exception-free formula
|
|
8068
|
+
* (Renes-Costello-Batina, algo 1 of [2015/1060](https://eprint.iacr.org/2015/1060)).
|
|
8069
|
+
* Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
8070
|
+
*/
|
|
8071
|
+
add(other) {
|
|
8072
|
+
const { px: X1, py: Y1, pz: Z1 } = this;
|
|
8073
|
+
const { px: X2, py: Y2, pz: Z2 } = aPoint(other);
|
|
8074
|
+
const { a: a5, b: b2 } = CURVE;
|
|
8075
|
+
let X3 = 0n, Y3 = 0n, Z3 = 0n;
|
|
8076
|
+
const b3 = M$1(b2 * 3n);
|
|
8077
|
+
let t0 = M$1(X1 * X2), t1 = M$1(Y1 * Y2), t22 = M$1(Z1 * Z2), t32 = M$1(X1 + Y1);
|
|
8078
|
+
let t42 = M$1(X2 + Y2);
|
|
8079
|
+
t32 = M$1(t32 * t42);
|
|
8080
|
+
t42 = M$1(t0 + t1);
|
|
8081
|
+
t32 = M$1(t32 - t42);
|
|
8082
|
+
t42 = M$1(X1 + Z1);
|
|
8083
|
+
let t52 = M$1(X2 + Z2);
|
|
8084
|
+
t42 = M$1(t42 * t52);
|
|
8085
|
+
t52 = M$1(t0 + t22);
|
|
8086
|
+
t42 = M$1(t42 - t52);
|
|
8087
|
+
t52 = M$1(Y1 + Z1);
|
|
8088
|
+
X3 = M$1(Y2 + Z2);
|
|
8089
|
+
t52 = M$1(t52 * X3);
|
|
8090
|
+
X3 = M$1(t1 + t22);
|
|
8091
|
+
t52 = M$1(t52 - X3);
|
|
8092
|
+
Z3 = M$1(a5 * t42);
|
|
8093
|
+
X3 = M$1(b3 * t22);
|
|
8094
|
+
Z3 = M$1(X3 + Z3);
|
|
8095
|
+
X3 = M$1(t1 - Z3);
|
|
8096
|
+
Z3 = M$1(t1 + Z3);
|
|
8097
|
+
Y3 = M$1(X3 * Z3);
|
|
8098
|
+
t1 = M$1(t0 + t0);
|
|
8099
|
+
t1 = M$1(t1 + t0);
|
|
8100
|
+
t22 = M$1(a5 * t22);
|
|
8101
|
+
t42 = M$1(b3 * t42);
|
|
8102
|
+
t1 = M$1(t1 + t22);
|
|
8103
|
+
t22 = M$1(t0 - t22);
|
|
8104
|
+
t22 = M$1(a5 * t22);
|
|
8105
|
+
t42 = M$1(t42 + t22);
|
|
8106
|
+
t0 = M$1(t1 * t42);
|
|
8107
|
+
Y3 = M$1(Y3 + t0);
|
|
8108
|
+
t0 = M$1(t52 * t42);
|
|
8109
|
+
X3 = M$1(t32 * X3);
|
|
8110
|
+
X3 = M$1(X3 - t0);
|
|
8111
|
+
t0 = M$1(t32 * t1);
|
|
8112
|
+
Z3 = M$1(t52 * Z3);
|
|
8113
|
+
Z3 = M$1(Z3 + t0);
|
|
8114
|
+
return new Point(X3, Y3, Z3);
|
|
8115
|
+
}
|
|
8116
|
+
mul(n4, safe = true) {
|
|
8117
|
+
if (!safe && n4 === 0n)
|
|
8118
|
+
return I$1;
|
|
8119
|
+
if (!ge(n4))
|
|
8120
|
+
err("scalar invalid");
|
|
8121
|
+
if (this.equals(G$1))
|
|
8122
|
+
return wNAF2(n4).p;
|
|
8123
|
+
let p5 = I$1, f3 = G$1;
|
|
8124
|
+
for (let d2 = this; n4 > 0n; d2 = d2.double(), n4 >>= 1n) {
|
|
8125
|
+
if (n4 & 1n)
|
|
8126
|
+
p5 = p5.add(d2);
|
|
8127
|
+
else if (safe)
|
|
8128
|
+
f3 = f3.add(d2);
|
|
8129
|
+
}
|
|
8130
|
+
return p5;
|
|
8131
|
+
}
|
|
8132
|
+
mulAddQUns(R2, u1, u22) {
|
|
8133
|
+
return this.mul(u1, false).add(R2.mul(u22, false)).ok();
|
|
8134
|
+
}
|
|
8135
|
+
// to private keys. Doesn't use Shamir trick
|
|
8136
|
+
/** Convert point to 2d xy affine point. (x, y, z) ∋ (x=x/z, y=y/z) */
|
|
8137
|
+
toAffine() {
|
|
8138
|
+
const { px: x2, py: y3, pz: z2 } = this;
|
|
8139
|
+
if (this.equals(I$1))
|
|
8140
|
+
return { x: 0n, y: 0n };
|
|
8141
|
+
if (z2 === 1n)
|
|
8142
|
+
return { x: x2, y: y3 };
|
|
8143
|
+
const iz = inv(z2, P$2);
|
|
8144
|
+
if (M$1(z2 * iz) !== 1n)
|
|
8145
|
+
err("inverse invalid");
|
|
8146
|
+
return { x: M$1(x2 * iz), y: M$1(y3 * iz) };
|
|
8147
|
+
}
|
|
8148
|
+
/** Checks if the point is valid and on-curve. */
|
|
8149
|
+
assertValidity() {
|
|
8150
|
+
const { x: x2, y: y3 } = this.aff();
|
|
8151
|
+
if (!fe(x2) || !fe(y3))
|
|
8152
|
+
err("Point invalid: x or y");
|
|
8153
|
+
return M$1(y3 * y3) === curve(x2) ? (
|
|
8154
|
+
// y² = x³ + ax + b, must be equal
|
|
8155
|
+
this
|
|
8156
|
+
) : err("Point invalid: not on curve");
|
|
8157
|
+
}
|
|
8158
|
+
multiply(n4) {
|
|
8159
|
+
return this.mul(n4);
|
|
8160
|
+
}
|
|
8161
|
+
// Aliases to compress code
|
|
8162
|
+
aff() {
|
|
8163
|
+
return this.toAffine();
|
|
8164
|
+
}
|
|
8165
|
+
ok() {
|
|
8166
|
+
return this.assertValidity();
|
|
8167
|
+
}
|
|
8168
|
+
toHex(isCompressed = true) {
|
|
8169
|
+
const { x: x2, y: y3 } = this.aff();
|
|
8170
|
+
const head = isCompressed ? (y3 & 1n) === 0n ? "02" : "03" : "04";
|
|
8171
|
+
return head + n2h(x2) + (isCompressed ? "" : n2h(y3));
|
|
8172
|
+
}
|
|
8173
|
+
toRawBytes(isCompressed = true) {
|
|
8174
|
+
return h2b(this.toHex(isCompressed));
|
|
8175
|
+
}
|
|
8176
|
+
};
|
|
8177
|
+
Point$1.BASE = new Point$1(Gx, Gy, 1n);
|
|
8178
|
+
Point$1.ZERO = new Point$1(0n, 1n, 0n);
|
|
8179
|
+
const { BASE: G$1, ZERO: I$1 } = Point$1;
|
|
8180
|
+
const padh = (n4, pad) => n4.toString(16).padStart(pad, "0");
|
|
8181
|
+
const b2h = (b2) => Array.from(au8(b2)).map((e4) => padh(e4, 2)).join("");
|
|
8182
|
+
const C$3 = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
8183
|
+
const _ch = (ch) => {
|
|
8184
|
+
if (ch >= C$3._0 && ch <= C$3._9)
|
|
8185
|
+
return ch - C$3._0;
|
|
8186
|
+
if (ch >= C$3.A && ch <= C$3.F)
|
|
8187
|
+
return ch - (C$3.A - 10);
|
|
8188
|
+
if (ch >= C$3.a && ch <= C$3.f)
|
|
8189
|
+
return ch - (C$3.a - 10);
|
|
8190
|
+
return;
|
|
8191
|
+
};
|
|
8192
|
+
const h2b = (hex) => {
|
|
8193
|
+
const e4 = "hex invalid";
|
|
8194
|
+
if (!isS(hex))
|
|
8195
|
+
return err(e4);
|
|
8196
|
+
const hl = hex.length, al = hl / 2;
|
|
8197
|
+
if (hl % 2)
|
|
8198
|
+
return err(e4);
|
|
8199
|
+
const array = u8n(al);
|
|
8200
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
8201
|
+
const n1 = _ch(hex.charCodeAt(hi));
|
|
8202
|
+
const n22 = _ch(hex.charCodeAt(hi + 1));
|
|
8203
|
+
if (n1 === void 0 || n22 === void 0)
|
|
8204
|
+
return err(e4);
|
|
8205
|
+
array[ai] = n1 * 16 + n22;
|
|
8206
|
+
}
|
|
8207
|
+
return array;
|
|
8208
|
+
};
|
|
8209
|
+
const b2n = (b2) => BigInt("0x" + (b2h(b2) || "0"));
|
|
8210
|
+
const slc = (b2, from, to) => b2n(b2.slice(from, to));
|
|
8211
|
+
const n2b = (num) => {
|
|
8212
|
+
return isB(num) && num >= 0n && num < B256 ? h2b(padh(num, 2 * fLen)) : err("bigint expected");
|
|
8213
|
+
};
|
|
8214
|
+
const n2h = (num) => b2h(n2b(num));
|
|
8215
|
+
const inv = (num, md) => {
|
|
8216
|
+
if (num === 0n || md <= 0n)
|
|
8217
|
+
err("no inverse n=" + num + " mod=" + md);
|
|
8218
|
+
let a5 = M$1(num, md), b2 = md, x2 = 0n, u4 = 1n;
|
|
8219
|
+
while (a5 !== 0n) {
|
|
8220
|
+
const q2 = b2 / a5, r7 = b2 % a5;
|
|
8221
|
+
const m2 = x2 - u4 * q2;
|
|
8222
|
+
b2 = a5, a5 = r7, x2 = u4, u4 = m2;
|
|
8223
|
+
}
|
|
8224
|
+
return b2 === 1n ? M$1(x2, md) : err("no inverse");
|
|
8225
|
+
};
|
|
8226
|
+
const sqrt = (n4) => {
|
|
8227
|
+
let r7 = 1n;
|
|
8228
|
+
for (let num = n4, e4 = (P$2 + 1n) / 4n; e4 > 0n; e4 >>= 1n) {
|
|
8229
|
+
if (e4 & 1n)
|
|
8230
|
+
r7 = r7 * num % P$2;
|
|
8231
|
+
num = num * num % P$2;
|
|
8232
|
+
}
|
|
8233
|
+
return M$1(r7 * r7) === n4 ? r7 : err("sqrt invalid");
|
|
8234
|
+
};
|
|
8235
|
+
const toPriv = (p5) => {
|
|
8236
|
+
if (!isB(p5))
|
|
8237
|
+
p5 = b2n(toU8(p5, fLen));
|
|
8238
|
+
return ge(p5) ? p5 : err("private key invalid 3");
|
|
8239
|
+
};
|
|
8240
|
+
const getPublicKey = (privKey, isCompressed = true) => {
|
|
8241
|
+
return Point$1.fromPrivateKey(privKey).toRawBytes(isCompressed);
|
|
8242
|
+
};
|
|
8243
|
+
const W = 8;
|
|
8244
|
+
const precompute = () => {
|
|
8245
|
+
const points = [];
|
|
8246
|
+
const windows = 256 / W + 1;
|
|
8247
|
+
let p5 = G$1, b2 = p5;
|
|
8248
|
+
for (let w2 = 0; w2 < windows; w2++) {
|
|
8249
|
+
b2 = p5;
|
|
8250
|
+
points.push(b2);
|
|
8251
|
+
for (let i3 = 1; i3 < 2 ** (W - 1); i3++) {
|
|
8252
|
+
b2 = b2.add(p5);
|
|
8253
|
+
points.push(b2);
|
|
8254
|
+
}
|
|
8255
|
+
p5 = b2.double();
|
|
8256
|
+
}
|
|
8257
|
+
return points;
|
|
8258
|
+
};
|
|
8259
|
+
let Gpows = void 0;
|
|
8260
|
+
const wNAF2 = (n4) => {
|
|
8261
|
+
const comp = Gpows || (Gpows = precompute());
|
|
8262
|
+
const neg = (cnd, p6) => {
|
|
8263
|
+
let n5 = p6.negate();
|
|
8264
|
+
return cnd ? n5 : p6;
|
|
8265
|
+
};
|
|
8266
|
+
let p5 = I$1, f3 = G$1;
|
|
8267
|
+
const windows = 1 + 256 / W;
|
|
8268
|
+
const wsize = 2 ** (W - 1);
|
|
8269
|
+
const mask = BigInt(2 ** W - 1);
|
|
8270
|
+
const maxNum = 2 ** W;
|
|
8271
|
+
const shiftBy = BigInt(W);
|
|
8272
|
+
for (let w2 = 0; w2 < windows; w2++) {
|
|
8273
|
+
const off = w2 * wsize;
|
|
8274
|
+
let wbits = Number(n4 & mask);
|
|
8275
|
+
n4 >>= shiftBy;
|
|
8276
|
+
if (wbits > wsize) {
|
|
8277
|
+
wbits -= maxNum;
|
|
8278
|
+
n4 += 1n;
|
|
8279
|
+
}
|
|
8280
|
+
const off1 = off, off2 = off + Math.abs(wbits) - 1;
|
|
8281
|
+
const cnd1 = w2 % 2 !== 0, cnd2 = wbits < 0;
|
|
8282
|
+
if (wbits === 0) {
|
|
8283
|
+
f3 = f3.add(neg(cnd1, comp[off1]));
|
|
8284
|
+
} else {
|
|
8285
|
+
p5 = p5.add(neg(cnd2, comp[off2]));
|
|
8286
|
+
}
|
|
8287
|
+
}
|
|
8288
|
+
return { p: p5, f: f3 };
|
|
8289
|
+
};
|
|
8290
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
8291
|
+
const _0n$2 = BigInt(0), _1n$3 = BigInt(1), _2n$3 = BigInt(2), _8n$1 = BigInt(8);
|
|
8292
|
+
function isEdValidXY(Fp2, CURVE2, x2, y3) {
|
|
8293
|
+
const x22 = Fp2.sqr(x2);
|
|
8294
|
+
const y22 = Fp2.sqr(y3);
|
|
8295
|
+
const left = Fp2.add(Fp2.mul(CURVE2.a, x22), y22);
|
|
8296
|
+
const right = Fp2.add(Fp2.ONE, Fp2.mul(CURVE2.d, Fp2.mul(x22, y22)));
|
|
8297
|
+
return Fp2.eql(left, right);
|
|
8298
|
+
}
|
|
8299
|
+
function edwards(params, extraOpts = {}) {
|
|
8300
|
+
const validated = _createCurveFields("edwards", params, extraOpts, extraOpts.FpFnLE);
|
|
8301
|
+
const { Fp: Fp2, Fn } = validated;
|
|
8302
|
+
let CURVE2 = validated.CURVE;
|
|
8303
|
+
const { h: cofactor } = CURVE2;
|
|
8304
|
+
_validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
8305
|
+
const MASK = _2n$3 << BigInt(Fn.BYTES * 8) - _1n$3;
|
|
8306
|
+
const modP = (n4) => Fp2.create(n4);
|
|
8307
|
+
const uvRatio2 = extraOpts.uvRatio || ((u4, v2) => {
|
|
8308
|
+
try {
|
|
8309
|
+
return { isValid: true, value: Fp2.sqrt(Fp2.div(u4, v2)) };
|
|
8310
|
+
} catch (e4) {
|
|
8311
|
+
return { isValid: false, value: _0n$2 };
|
|
8312
|
+
}
|
|
8313
|
+
});
|
|
8314
|
+
if (!isEdValidXY(Fp2, CURVE2, CURVE2.Gx, CURVE2.Gy))
|
|
8315
|
+
throw new Error("bad curve params: generator point");
|
|
8316
|
+
function acoord(title, n4, banZero = false) {
|
|
8317
|
+
const min = banZero ? _1n$3 : _0n$2;
|
|
8318
|
+
aInRange$1("coordinate " + title, n4, min, MASK);
|
|
8319
|
+
return n4;
|
|
8320
|
+
}
|
|
8321
|
+
function aextpoint(other) {
|
|
8322
|
+
if (!(other instanceof Point3))
|
|
8323
|
+
throw new Error("ExtendedPoint expected");
|
|
8324
|
+
}
|
|
8325
|
+
const toAffineMemo = memoized$1((p5, iz) => {
|
|
8326
|
+
const { X, Y, Z } = p5;
|
|
8327
|
+
const is0 = p5.is0();
|
|
8328
|
+
if (iz == null)
|
|
8329
|
+
iz = is0 ? _8n$1 : Fp2.inv(Z);
|
|
8330
|
+
const x2 = modP(X * iz);
|
|
8331
|
+
const y3 = modP(Y * iz);
|
|
8332
|
+
const zz = Fp2.mul(Z, iz);
|
|
8333
|
+
if (is0)
|
|
8334
|
+
return { x: _0n$2, y: _1n$3 };
|
|
8335
|
+
if (zz !== _1n$3)
|
|
8336
|
+
throw new Error("invZ was invalid");
|
|
8337
|
+
return { x: x2, y: y3 };
|
|
8338
|
+
});
|
|
8339
|
+
const assertValidMemo = memoized$1((p5) => {
|
|
8340
|
+
const { a: a5, d: d2 } = CURVE2;
|
|
8341
|
+
if (p5.is0())
|
|
8342
|
+
throw new Error("bad point: ZERO");
|
|
8343
|
+
const { X, Y, Z, T: T3 } = p5;
|
|
8344
|
+
const X2 = modP(X * X);
|
|
8345
|
+
const Y2 = modP(Y * Y);
|
|
8346
|
+
const Z2 = modP(Z * Z);
|
|
8347
|
+
const Z4 = modP(Z2 * Z2);
|
|
8348
|
+
const aX2 = modP(X2 * a5);
|
|
8349
|
+
const left = modP(Z2 * modP(aX2 + Y2));
|
|
8350
|
+
const right = modP(Z4 + modP(d2 * modP(X2 * Y2)));
|
|
8351
|
+
if (left !== right)
|
|
8352
|
+
throw new Error("bad point: equation left != right (1)");
|
|
8353
|
+
const XY = modP(X * Y);
|
|
8354
|
+
const ZT = modP(Z * T3);
|
|
8355
|
+
if (XY !== ZT)
|
|
8356
|
+
throw new Error("bad point: equation left != right (2)");
|
|
8357
|
+
return true;
|
|
8358
|
+
});
|
|
8359
|
+
class Point3 {
|
|
8360
|
+
constructor(X, Y, Z, T3) {
|
|
8361
|
+
this.X = acoord("x", X);
|
|
8362
|
+
this.Y = acoord("y", Y);
|
|
8363
|
+
this.Z = acoord("z", Z, true);
|
|
8364
|
+
this.T = acoord("t", T3);
|
|
8365
|
+
Object.freeze(this);
|
|
8366
|
+
}
|
|
8367
|
+
static CURVE() {
|
|
8368
|
+
return CURVE2;
|
|
8369
|
+
}
|
|
8370
|
+
static fromAffine(p5) {
|
|
8371
|
+
if (p5 instanceof Point3)
|
|
8372
|
+
throw new Error("extended point not allowed");
|
|
8373
|
+
const { x: x2, y: y3 } = p5 || {};
|
|
8374
|
+
acoord("x", x2);
|
|
8375
|
+
acoord("y", y3);
|
|
8376
|
+
return new Point3(x2, y3, _1n$3, modP(x2 * y3));
|
|
8377
|
+
}
|
|
8378
|
+
// Uses algo from RFC8032 5.1.3.
|
|
8379
|
+
static fromBytes(bytes, zip215 = false) {
|
|
8380
|
+
const len = Fp2.BYTES;
|
|
8381
|
+
const { a: a5, d: d2 } = CURVE2;
|
|
8382
|
+
bytes = copyBytes(_abytes2(bytes, len, "point"));
|
|
8383
|
+
_abool2(zip215, "zip215");
|
|
8384
|
+
const normed = copyBytes(bytes);
|
|
8385
|
+
const lastByte = bytes[len - 1];
|
|
8386
|
+
normed[len - 1] = lastByte & -129;
|
|
8387
|
+
const y3 = bytesToNumberLE$1(normed);
|
|
8388
|
+
const max = zip215 ? MASK : Fp2.ORDER;
|
|
8389
|
+
aInRange$1("point.y", y3, _0n$2, max);
|
|
8390
|
+
const y22 = modP(y3 * y3);
|
|
8391
|
+
const u4 = modP(y22 - _1n$3);
|
|
8392
|
+
const v2 = modP(d2 * y22 - a5);
|
|
8393
|
+
let { isValid, value: x2 } = uvRatio2(u4, v2);
|
|
8394
|
+
if (!isValid)
|
|
8395
|
+
throw new Error("bad point: invalid y coordinate");
|
|
8396
|
+
const isXOdd = (x2 & _1n$3) === _1n$3;
|
|
8397
|
+
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
8398
|
+
if (!zip215 && x2 === _0n$2 && isLastByteOdd)
|
|
8399
|
+
throw new Error("bad point: x=0 and x_0=1");
|
|
8400
|
+
if (isLastByteOdd !== isXOdd)
|
|
8401
|
+
x2 = modP(-x2);
|
|
8402
|
+
return Point3.fromAffine({ x: x2, y: y3 });
|
|
8403
|
+
}
|
|
8404
|
+
static fromHex(bytes, zip215 = false) {
|
|
8405
|
+
return Point3.fromBytes(ensureBytes$1("point", bytes), zip215);
|
|
8406
|
+
}
|
|
8407
|
+
get x() {
|
|
8408
|
+
return this.toAffine().x;
|
|
8409
|
+
}
|
|
8410
|
+
get y() {
|
|
8411
|
+
return this.toAffine().y;
|
|
8412
|
+
}
|
|
8413
|
+
precompute(windowSize = 8, isLazy = true) {
|
|
8414
|
+
wnaf.createCache(this, windowSize);
|
|
8415
|
+
if (!isLazy)
|
|
8416
|
+
this.multiply(_2n$3);
|
|
8417
|
+
return this;
|
|
8418
|
+
}
|
|
8419
|
+
// Useful in fromAffine() - not for fromBytes(), which always created valid points.
|
|
8420
|
+
assertValidity() {
|
|
8421
|
+
assertValidMemo(this);
|
|
8422
|
+
}
|
|
8423
|
+
// Compare one point to another.
|
|
8424
|
+
equals(other) {
|
|
8425
|
+
aextpoint(other);
|
|
8426
|
+
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
8427
|
+
const { X: X2, Y: Y2, Z: Z2 } = other;
|
|
8428
|
+
const X1Z2 = modP(X1 * Z2);
|
|
8429
|
+
const X2Z1 = modP(X2 * Z1);
|
|
8430
|
+
const Y1Z2 = modP(Y1 * Z2);
|
|
8431
|
+
const Y2Z1 = modP(Y2 * Z1);
|
|
8432
|
+
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
8433
|
+
}
|
|
8434
|
+
is0() {
|
|
8435
|
+
return this.equals(Point3.ZERO);
|
|
8436
|
+
}
|
|
8437
|
+
negate() {
|
|
8438
|
+
return new Point3(modP(-this.X), this.Y, this.Z, modP(-this.T));
|
|
8439
|
+
}
|
|
8440
|
+
// Fast algo for doubling Extended Point.
|
|
8441
|
+
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd
|
|
8442
|
+
// Cost: 4M + 4S + 1*a + 6add + 1*2.
|
|
8443
|
+
double() {
|
|
8444
|
+
const { a: a5 } = CURVE2;
|
|
8445
|
+
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
8446
|
+
const A3 = modP(X1 * X1);
|
|
8447
|
+
const B = modP(Y1 * Y1);
|
|
8448
|
+
const C2 = modP(_2n$3 * modP(Z1 * Z1));
|
|
8449
|
+
const D2 = modP(a5 * A3);
|
|
8450
|
+
const x1y1 = X1 + Y1;
|
|
8451
|
+
const E2 = modP(modP(x1y1 * x1y1) - A3 - B);
|
|
8452
|
+
const G2 = D2 + B;
|
|
8453
|
+
const F = G2 - C2;
|
|
8454
|
+
const H = D2 - B;
|
|
8455
|
+
const X3 = modP(E2 * F);
|
|
8456
|
+
const Y3 = modP(G2 * H);
|
|
8457
|
+
const T3 = modP(E2 * H);
|
|
8458
|
+
const Z3 = modP(F * G2);
|
|
8459
|
+
return new Point3(X3, Y3, Z3, T3);
|
|
8460
|
+
}
|
|
8461
|
+
// Fast algo for adding 2 Extended Points.
|
|
8462
|
+
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
|
|
8463
|
+
// Cost: 9M + 1*a + 1*d + 7add.
|
|
8464
|
+
add(other) {
|
|
8465
|
+
aextpoint(other);
|
|
8466
|
+
const { a: a5, d: d2 } = CURVE2;
|
|
8467
|
+
const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
|
|
8468
|
+
const { X: X2, Y: Y2, Z: Z2, T: T22 } = other;
|
|
8469
|
+
const A3 = modP(X1 * X2);
|
|
8470
|
+
const B = modP(Y1 * Y2);
|
|
8471
|
+
const C2 = modP(T1 * d2 * T22);
|
|
8472
|
+
const D2 = modP(Z1 * Z2);
|
|
8473
|
+
const E2 = modP((X1 + Y1) * (X2 + Y2) - A3 - B);
|
|
8474
|
+
const F = D2 - C2;
|
|
8475
|
+
const G2 = D2 + C2;
|
|
8476
|
+
const H = modP(B - a5 * A3);
|
|
8477
|
+
const X3 = modP(E2 * F);
|
|
8478
|
+
const Y3 = modP(G2 * H);
|
|
8479
|
+
const T3 = modP(E2 * H);
|
|
8480
|
+
const Z3 = modP(F * G2);
|
|
8481
|
+
return new Point3(X3, Y3, Z3, T3);
|
|
8482
|
+
}
|
|
8483
|
+
subtract(other) {
|
|
8484
|
+
return this.add(other.negate());
|
|
8485
|
+
}
|
|
8486
|
+
// Constant-time multiplication.
|
|
8487
|
+
multiply(scalar) {
|
|
8488
|
+
if (!Fn.isValidNot0(scalar))
|
|
8489
|
+
throw new Error("invalid scalar: expected 1 <= sc < curve.n");
|
|
8490
|
+
const { p: p5, f: f3 } = wnaf.cached(this, scalar, (p6) => normalizeZ(Point3, p6));
|
|
8491
|
+
return normalizeZ(Point3, [p5, f3])[0];
|
|
8492
|
+
}
|
|
8493
|
+
// Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
8494
|
+
// It's faster, but should only be used when you don't care about
|
|
8495
|
+
// an exposed private key e.g. sig verification.
|
|
8496
|
+
// Does NOT allow scalars higher than CURVE.n.
|
|
8497
|
+
// Accepts optional accumulator to merge with multiply (important for sparse scalars)
|
|
8498
|
+
multiplyUnsafe(scalar, acc = Point3.ZERO) {
|
|
8499
|
+
if (!Fn.isValid(scalar))
|
|
8500
|
+
throw new Error("invalid scalar: expected 0 <= sc < curve.n");
|
|
8501
|
+
if (scalar === _0n$2)
|
|
8502
|
+
return Point3.ZERO;
|
|
8503
|
+
if (this.is0() || scalar === _1n$3)
|
|
8504
|
+
return this;
|
|
8505
|
+
return wnaf.unsafe(this, scalar, (p5) => normalizeZ(Point3, p5), acc);
|
|
8506
|
+
}
|
|
8507
|
+
// Checks if point is of small order.
|
|
8508
|
+
// If you add something to small order point, you will have "dirty"
|
|
8509
|
+
// point with torsion component.
|
|
8510
|
+
// Multiplies point by cofactor and checks if the result is 0.
|
|
8511
|
+
isSmallOrder() {
|
|
8512
|
+
return this.multiplyUnsafe(cofactor).is0();
|
|
8513
|
+
}
|
|
8514
|
+
// Multiplies point by curve order and checks if the result is 0.
|
|
8515
|
+
// Returns `false` is the point is dirty.
|
|
8516
|
+
isTorsionFree() {
|
|
8517
|
+
return wnaf.unsafe(this, CURVE2.n).is0();
|
|
8518
|
+
}
|
|
8519
|
+
// Converts Extended point to default (x, y) coordinates.
|
|
8520
|
+
// Can accept precomputed Z^-1 - for example, from invertBatch.
|
|
8521
|
+
toAffine(invertedZ) {
|
|
8522
|
+
return toAffineMemo(this, invertedZ);
|
|
8523
|
+
}
|
|
8524
|
+
clearCofactor() {
|
|
8525
|
+
if (cofactor === _1n$3)
|
|
8526
|
+
return this;
|
|
8527
|
+
return this.multiplyUnsafe(cofactor);
|
|
8528
|
+
}
|
|
8529
|
+
toBytes() {
|
|
8530
|
+
const { x: x2, y: y3 } = this.toAffine();
|
|
8531
|
+
const bytes = Fp2.toBytes(y3);
|
|
8532
|
+
bytes[bytes.length - 1] |= x2 & _1n$3 ? 128 : 0;
|
|
8533
|
+
return bytes;
|
|
8534
|
+
}
|
|
8535
|
+
toHex() {
|
|
8536
|
+
return bytesToHex$2(this.toBytes());
|
|
8537
|
+
}
|
|
8538
|
+
toString() {
|
|
8539
|
+
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
8540
|
+
}
|
|
8541
|
+
// TODO: remove
|
|
8542
|
+
get ex() {
|
|
8543
|
+
return this.X;
|
|
8544
|
+
}
|
|
8545
|
+
get ey() {
|
|
8546
|
+
return this.Y;
|
|
8547
|
+
}
|
|
8548
|
+
get ez() {
|
|
8549
|
+
return this.Z;
|
|
8550
|
+
}
|
|
8551
|
+
get et() {
|
|
8552
|
+
return this.T;
|
|
8553
|
+
}
|
|
8554
|
+
static normalizeZ(points) {
|
|
8555
|
+
return normalizeZ(Point3, points);
|
|
8556
|
+
}
|
|
8557
|
+
static msm(points, scalars) {
|
|
8558
|
+
return pippenger$1(Point3, Fn, points, scalars);
|
|
8559
|
+
}
|
|
8560
|
+
_setWindowSize(windowSize) {
|
|
8561
|
+
this.precompute(windowSize);
|
|
8562
|
+
}
|
|
8563
|
+
toRawBytes() {
|
|
8564
|
+
return this.toBytes();
|
|
8565
|
+
}
|
|
8566
|
+
}
|
|
8567
|
+
Point3.BASE = new Point3(CURVE2.Gx, CURVE2.Gy, _1n$3, modP(CURVE2.Gx * CURVE2.Gy));
|
|
8568
|
+
Point3.ZERO = new Point3(_0n$2, _1n$3, _1n$3, _0n$2);
|
|
8569
|
+
Point3.Fp = Fp2;
|
|
8570
|
+
Point3.Fn = Fn;
|
|
8571
|
+
const wnaf = new wNAF$2(Point3, Fn.BITS);
|
|
8572
|
+
Point3.BASE.precompute(8);
|
|
8573
|
+
return Point3;
|
|
8574
|
+
}
|
|
8575
|
+
function eddsa(Point3, cHash, eddsaOpts = {}) {
|
|
8576
|
+
if (typeof cHash !== "function")
|
|
8577
|
+
throw new Error('"hash" function param is required');
|
|
8578
|
+
_validateObject(eddsaOpts, {}, {
|
|
8579
|
+
adjustScalarBytes: "function",
|
|
8580
|
+
randomBytes: "function",
|
|
8581
|
+
domain: "function",
|
|
8582
|
+
prehash: "function",
|
|
8583
|
+
mapToCurve: "function"
|
|
8584
|
+
});
|
|
8585
|
+
const { prehash } = eddsaOpts;
|
|
8586
|
+
const { BASE, Fp: Fp2, Fn } = Point3;
|
|
8587
|
+
const randomBytes2 = eddsaOpts.randomBytes || randomBytes$1;
|
|
8588
|
+
const adjustScalarBytes2 = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
|
|
8589
|
+
const domain = eddsaOpts.domain || ((data, ctx, phflag) => {
|
|
8590
|
+
_abool2(phflag, "phflag");
|
|
8591
|
+
if (ctx.length || phflag)
|
|
8592
|
+
throw new Error("Contexts/pre-hash are not supported");
|
|
8593
|
+
return data;
|
|
8594
|
+
});
|
|
8595
|
+
function modN_LE(hash) {
|
|
8596
|
+
return Fn.create(bytesToNumberLE$1(hash));
|
|
8597
|
+
}
|
|
8598
|
+
function getPrivateScalar(key) {
|
|
8599
|
+
const len = lengths.secretKey;
|
|
8600
|
+
key = ensureBytes$1("private key", key, len);
|
|
8601
|
+
const hashed = ensureBytes$1("hashed private key", cHash(key), 2 * len);
|
|
8602
|
+
const head = adjustScalarBytes2(hashed.slice(0, len));
|
|
8603
|
+
const prefix = hashed.slice(len, 2 * len);
|
|
8604
|
+
const scalar = modN_LE(head);
|
|
8605
|
+
return { head, prefix, scalar };
|
|
8606
|
+
}
|
|
8607
|
+
function getExtendedPublicKey(secretKey) {
|
|
8608
|
+
const { head, prefix, scalar } = getPrivateScalar(secretKey);
|
|
8609
|
+
const point = BASE.multiply(scalar);
|
|
8610
|
+
const pointBytes = point.toBytes();
|
|
8611
|
+
return { head, prefix, scalar, point, pointBytes };
|
|
8612
|
+
}
|
|
8613
|
+
function getPublicKey2(secretKey) {
|
|
8614
|
+
return getExtendedPublicKey(secretKey).pointBytes;
|
|
8615
|
+
}
|
|
8616
|
+
function hashDomainToScalar(context = Uint8Array.of(), ...msgs) {
|
|
8617
|
+
const msg = concatBytes$2(...msgs);
|
|
8618
|
+
return modN_LE(cHash(domain(msg, ensureBytes$1("context", context), !!prehash)));
|
|
8619
|
+
}
|
|
8620
|
+
function sign(msg, secretKey, options = {}) {
|
|
8621
|
+
msg = ensureBytes$1("message", msg);
|
|
8622
|
+
if (prehash)
|
|
8623
|
+
msg = prehash(msg);
|
|
8624
|
+
const { prefix, scalar, pointBytes } = getExtendedPublicKey(secretKey);
|
|
8625
|
+
const r7 = hashDomainToScalar(options.context, prefix, msg);
|
|
8626
|
+
const R2 = BASE.multiply(r7).toBytes();
|
|
8627
|
+
const k2 = hashDomainToScalar(options.context, R2, pointBytes, msg);
|
|
8628
|
+
const s5 = Fn.create(r7 + k2 * scalar);
|
|
8629
|
+
if (!Fn.isValid(s5))
|
|
8630
|
+
throw new Error("sign failed: invalid s");
|
|
8631
|
+
const rs = concatBytes$2(R2, Fn.toBytes(s5));
|
|
8632
|
+
return _abytes2(rs, lengths.signature, "result");
|
|
8633
|
+
}
|
|
8634
|
+
const verifyOpts = { zip215: true };
|
|
8635
|
+
function verify(sig, msg, publicKey, options = verifyOpts) {
|
|
8636
|
+
const { context, zip215 } = options;
|
|
8637
|
+
const len = lengths.signature;
|
|
8638
|
+
sig = ensureBytes$1("signature", sig, len);
|
|
8639
|
+
msg = ensureBytes$1("message", msg);
|
|
8640
|
+
publicKey = ensureBytes$1("publicKey", publicKey, lengths.publicKey);
|
|
8641
|
+
if (zip215 !== void 0)
|
|
8642
|
+
_abool2(zip215, "zip215");
|
|
8643
|
+
if (prehash)
|
|
8644
|
+
msg = prehash(msg);
|
|
8645
|
+
const mid = len / 2;
|
|
8646
|
+
const r7 = sig.subarray(0, mid);
|
|
8647
|
+
const s5 = bytesToNumberLE$1(sig.subarray(mid, len));
|
|
8648
|
+
let A3, R2, SB;
|
|
8649
|
+
try {
|
|
8650
|
+
A3 = Point3.fromBytes(publicKey, zip215);
|
|
8651
|
+
R2 = Point3.fromBytes(r7, zip215);
|
|
8652
|
+
SB = BASE.multiplyUnsafe(s5);
|
|
8653
|
+
} catch (error) {
|
|
8654
|
+
return false;
|
|
8655
|
+
}
|
|
8656
|
+
if (!zip215 && A3.isSmallOrder())
|
|
8657
|
+
return false;
|
|
8658
|
+
const k2 = hashDomainToScalar(context, R2.toBytes(), A3.toBytes(), msg);
|
|
8659
|
+
const RkA = R2.add(A3.multiplyUnsafe(k2));
|
|
8660
|
+
return RkA.subtract(SB).clearCofactor().is0();
|
|
8661
|
+
}
|
|
8662
|
+
const _size = Fp2.BYTES;
|
|
8663
|
+
const lengths = {
|
|
8664
|
+
secretKey: _size,
|
|
8665
|
+
publicKey: _size,
|
|
8666
|
+
signature: 2 * _size,
|
|
8667
|
+
seed: _size
|
|
8668
|
+
};
|
|
8669
|
+
function randomSecretKey(seed = randomBytes2(lengths.seed)) {
|
|
8670
|
+
return _abytes2(seed, lengths.seed, "seed");
|
|
8671
|
+
}
|
|
8672
|
+
function keygen(seed) {
|
|
8673
|
+
const secretKey = utils2.randomSecretKey(seed);
|
|
8674
|
+
return { secretKey, publicKey: getPublicKey2(secretKey) };
|
|
8675
|
+
}
|
|
8676
|
+
function isValidSecretKey(key) {
|
|
8677
|
+
return isBytes$5(key) && key.length === Fn.BYTES;
|
|
8678
|
+
}
|
|
8679
|
+
function isValidPublicKey(key, zip215) {
|
|
8680
|
+
try {
|
|
8681
|
+
return !!Point3.fromBytes(key, zip215);
|
|
8682
|
+
} catch (error) {
|
|
8683
|
+
return false;
|
|
8684
|
+
}
|
|
8685
|
+
}
|
|
8686
|
+
const utils2 = {
|
|
8687
|
+
getExtendedPublicKey,
|
|
8688
|
+
randomSecretKey,
|
|
8689
|
+
isValidSecretKey,
|
|
8690
|
+
isValidPublicKey,
|
|
8691
|
+
/**
|
|
8692
|
+
* Converts ed public key to x public key. Uses formula:
|
|
8693
|
+
* - ed25519:
|
|
8694
|
+
* - `(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)`
|
|
8695
|
+
* - `(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))`
|
|
8696
|
+
* - ed448:
|
|
8697
|
+
* - `(u, v) = ((y-1)/(y+1), sqrt(156324)*u/x)`
|
|
8698
|
+
* - `(x, y) = (sqrt(156324)*u/v, (1+u)/(1-u))`
|
|
8699
|
+
*/
|
|
8700
|
+
toMontgomery(publicKey) {
|
|
8701
|
+
const { y: y3 } = Point3.fromBytes(publicKey);
|
|
8702
|
+
const size = lengths.publicKey;
|
|
8703
|
+
const is25519 = size === 32;
|
|
8704
|
+
if (!is25519 && size !== 57)
|
|
8705
|
+
throw new Error("only defined for 25519 and 448");
|
|
8706
|
+
const u4 = is25519 ? Fp2.div(_1n$3 + y3, _1n$3 - y3) : Fp2.div(y3 - _1n$3, y3 + _1n$3);
|
|
8707
|
+
return Fp2.toBytes(u4);
|
|
8708
|
+
},
|
|
8709
|
+
toMontgomerySecret(secretKey) {
|
|
8710
|
+
const size = lengths.secretKey;
|
|
8711
|
+
_abytes2(secretKey, size);
|
|
8712
|
+
const hashed = cHash(secretKey.subarray(0, size));
|
|
8713
|
+
return adjustScalarBytes2(hashed).subarray(0, size);
|
|
8714
|
+
},
|
|
8715
|
+
/** @deprecated */
|
|
8716
|
+
randomPrivateKey: randomSecretKey,
|
|
8717
|
+
/** @deprecated */
|
|
8718
|
+
precompute(windowSize = 8, point = Point3.BASE) {
|
|
8719
|
+
return point.precompute(windowSize, false);
|
|
8720
|
+
}
|
|
8721
|
+
};
|
|
8722
|
+
return Object.freeze({
|
|
8723
|
+
keygen,
|
|
8724
|
+
getPublicKey: getPublicKey2,
|
|
8725
|
+
sign,
|
|
8726
|
+
verify,
|
|
8727
|
+
utils: utils2,
|
|
8728
|
+
Point: Point3,
|
|
8729
|
+
lengths
|
|
8730
|
+
});
|
|
8731
|
+
}
|
|
8732
|
+
function _eddsa_legacy_opts_to_new(c3) {
|
|
8733
|
+
const CURVE2 = {
|
|
8734
|
+
a: c3.a,
|
|
8735
|
+
d: c3.d,
|
|
8736
|
+
p: c3.Fp.ORDER,
|
|
8737
|
+
n: c3.n,
|
|
8738
|
+
h: c3.h,
|
|
8739
|
+
Gx: c3.Gx,
|
|
8740
|
+
Gy: c3.Gy
|
|
8741
|
+
};
|
|
8742
|
+
const Fp2 = c3.Fp;
|
|
8743
|
+
const Fn = Field$1(CURVE2.n, c3.nBitLength, true);
|
|
8744
|
+
const curveOpts = { Fp: Fp2, Fn, uvRatio: c3.uvRatio };
|
|
8745
|
+
const eddsaOpts = {
|
|
8746
|
+
randomBytes: c3.randomBytes,
|
|
8747
|
+
adjustScalarBytes: c3.adjustScalarBytes,
|
|
8748
|
+
domain: c3.domain,
|
|
8749
|
+
prehash: c3.prehash,
|
|
8750
|
+
mapToCurve: c3.mapToCurve
|
|
8751
|
+
};
|
|
8752
|
+
return { CURVE: CURVE2, curveOpts, hash: c3.hash, eddsaOpts };
|
|
8753
|
+
}
|
|
8754
|
+
function _eddsa_new_output_to_legacy(c3, eddsa2) {
|
|
8755
|
+
const Point3 = eddsa2.Point;
|
|
8756
|
+
const legacy = Object.assign({}, eddsa2, {
|
|
8757
|
+
ExtendedPoint: Point3,
|
|
8758
|
+
CURVE: c3,
|
|
8759
|
+
nBitLength: Point3.Fn.BITS,
|
|
8760
|
+
nByteLength: Point3.Fn.BYTES
|
|
8761
|
+
});
|
|
8762
|
+
return legacy;
|
|
8763
|
+
}
|
|
8764
|
+
function twistedEdwards(c3) {
|
|
8765
|
+
const { CURVE: CURVE2, curveOpts, hash, eddsaOpts } = _eddsa_legacy_opts_to_new(c3);
|
|
8766
|
+
const Point3 = edwards(CURVE2, curveOpts);
|
|
8767
|
+
const EDDSA = eddsa(Point3, hash, eddsaOpts);
|
|
8768
|
+
return _eddsa_new_output_to_legacy(c3, EDDSA);
|
|
8769
|
+
}
|
|
8770
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
8771
|
+
const _0n$1 = BigInt(0);
|
|
8772
|
+
const _1n$2 = BigInt(1);
|
|
8773
|
+
const _2n$2 = BigInt(2);
|
|
8774
|
+
function validateOpts(curve2) {
|
|
8775
|
+
_validateObject(curve2, {
|
|
8776
|
+
adjustScalarBytes: "function",
|
|
8777
|
+
powPminus2: "function"
|
|
8778
|
+
});
|
|
8779
|
+
return Object.freeze({ ...curve2 });
|
|
8780
|
+
}
|
|
8781
|
+
function montgomery(curveDef) {
|
|
8782
|
+
const CURVE2 = validateOpts(curveDef);
|
|
8783
|
+
const { P: P2, type: type2, adjustScalarBytes: adjustScalarBytes2, powPminus2, randomBytes: rand } = CURVE2;
|
|
8784
|
+
const is25519 = type2 === "x25519";
|
|
8785
|
+
if (!is25519 && type2 !== "x448")
|
|
8786
|
+
throw new Error("invalid type");
|
|
8787
|
+
const randomBytes_ = rand || randomBytes$1;
|
|
8788
|
+
const montgomeryBits = is25519 ? 255 : 448;
|
|
8789
|
+
const fieldLen = is25519 ? 32 : 56;
|
|
8790
|
+
const Gu = is25519 ? BigInt(9) : BigInt(5);
|
|
8791
|
+
const a24 = is25519 ? BigInt(121665) : BigInt(39081);
|
|
8792
|
+
const minScalar = is25519 ? _2n$2 ** BigInt(254) : _2n$2 ** BigInt(447);
|
|
8793
|
+
const maxAdded = is25519 ? BigInt(8) * _2n$2 ** BigInt(251) - _1n$2 : BigInt(4) * _2n$2 ** BigInt(445) - _1n$2;
|
|
8794
|
+
const maxScalar = minScalar + maxAdded + _1n$2;
|
|
8795
|
+
const modP = (n4) => mod$1(n4, P2);
|
|
8796
|
+
const GuBytes = encodeU(Gu);
|
|
8797
|
+
function encodeU(u4) {
|
|
8798
|
+
return numberToBytesLE$1(modP(u4), fieldLen);
|
|
8799
|
+
}
|
|
8800
|
+
function decodeU(u4) {
|
|
8801
|
+
const _u = ensureBytes$1("u coordinate", u4, fieldLen);
|
|
8802
|
+
if (is25519)
|
|
8803
|
+
_u[31] &= 127;
|
|
8804
|
+
return modP(bytesToNumberLE$1(_u));
|
|
8805
|
+
}
|
|
8806
|
+
function decodeScalar(scalar) {
|
|
8807
|
+
return bytesToNumberLE$1(adjustScalarBytes2(ensureBytes$1("scalar", scalar, fieldLen)));
|
|
8808
|
+
}
|
|
8809
|
+
function scalarMult(scalar, u4) {
|
|
8810
|
+
const pu = montgomeryLadder(decodeU(u4), decodeScalar(scalar));
|
|
8811
|
+
if (pu === _0n$1)
|
|
8812
|
+
throw new Error("invalid private or public key received");
|
|
8813
|
+
return encodeU(pu);
|
|
8814
|
+
}
|
|
8815
|
+
function scalarMultBase(scalar) {
|
|
8816
|
+
return scalarMult(scalar, GuBytes);
|
|
8817
|
+
}
|
|
8818
|
+
function cswap(swap, x_2, x_3) {
|
|
8819
|
+
const dummy = modP(swap * (x_2 - x_3));
|
|
8820
|
+
x_2 = modP(x_2 - dummy);
|
|
8821
|
+
x_3 = modP(x_3 + dummy);
|
|
8822
|
+
return { x_2, x_3 };
|
|
8823
|
+
}
|
|
8824
|
+
function montgomeryLadder(u4, scalar) {
|
|
8825
|
+
aInRange$1("u", u4, _0n$1, P2);
|
|
8826
|
+
aInRange$1("scalar", scalar, minScalar, maxScalar);
|
|
8827
|
+
const k2 = scalar;
|
|
8828
|
+
const x_1 = u4;
|
|
8829
|
+
let x_2 = _1n$2;
|
|
8830
|
+
let z_2 = _0n$1;
|
|
8831
|
+
let x_3 = u4;
|
|
8832
|
+
let z_3 = _1n$2;
|
|
8833
|
+
let swap = _0n$1;
|
|
8834
|
+
for (let t6 = BigInt(montgomeryBits - 1); t6 >= _0n$1; t6--) {
|
|
8835
|
+
const k_t = k2 >> t6 & _1n$2;
|
|
8836
|
+
swap ^= k_t;
|
|
8837
|
+
({ x_2, x_3 } = cswap(swap, x_2, x_3));
|
|
8838
|
+
({ x_2: z_2, x_3: z_3 } = cswap(swap, z_2, z_3));
|
|
8839
|
+
swap = k_t;
|
|
8840
|
+
const A3 = x_2 + z_2;
|
|
8841
|
+
const AA = modP(A3 * A3);
|
|
8842
|
+
const B = x_2 - z_2;
|
|
8843
|
+
const BB = modP(B * B);
|
|
8844
|
+
const E2 = AA - BB;
|
|
8845
|
+
const C2 = x_3 + z_3;
|
|
8846
|
+
const D2 = x_3 - z_3;
|
|
8847
|
+
const DA = modP(D2 * A3);
|
|
8848
|
+
const CB = modP(C2 * B);
|
|
8849
|
+
const dacb = DA + CB;
|
|
8850
|
+
const da_cb = DA - CB;
|
|
8851
|
+
x_3 = modP(dacb * dacb);
|
|
8852
|
+
z_3 = modP(x_1 * modP(da_cb * da_cb));
|
|
8853
|
+
x_2 = modP(AA * BB);
|
|
8854
|
+
z_2 = modP(E2 * (AA + modP(a24 * E2)));
|
|
8855
|
+
}
|
|
8856
|
+
({ x_2, x_3 } = cswap(swap, x_2, x_3));
|
|
8857
|
+
({ x_2: z_2, x_3: z_3 } = cswap(swap, z_2, z_3));
|
|
8858
|
+
const z2 = powPminus2(z_2);
|
|
8859
|
+
return modP(x_2 * z2);
|
|
8860
|
+
}
|
|
8861
|
+
const lengths = {
|
|
8862
|
+
secretKey: fieldLen,
|
|
8863
|
+
publicKey: fieldLen,
|
|
8864
|
+
seed: fieldLen
|
|
8865
|
+
};
|
|
8866
|
+
const randomSecretKey = (seed = randomBytes_(fieldLen)) => {
|
|
8867
|
+
abytes$2(seed, lengths.seed);
|
|
8868
|
+
return seed;
|
|
8869
|
+
};
|
|
8870
|
+
function keygen(seed) {
|
|
8871
|
+
const secretKey = randomSecretKey(seed);
|
|
8872
|
+
return { secretKey, publicKey: scalarMultBase(secretKey) };
|
|
8873
|
+
}
|
|
8874
|
+
const utils2 = {
|
|
8875
|
+
randomSecretKey,
|
|
8876
|
+
randomPrivateKey: randomSecretKey
|
|
8877
|
+
};
|
|
8878
|
+
return {
|
|
8879
|
+
keygen,
|
|
8880
|
+
getSharedSecret: (secretKey, publicKey) => scalarMult(secretKey, publicKey),
|
|
8881
|
+
getPublicKey: (secretKey) => scalarMultBase(secretKey),
|
|
8882
|
+
scalarMult,
|
|
8883
|
+
scalarMultBase,
|
|
8884
|
+
utils: utils2,
|
|
8885
|
+
GuBytes: GuBytes.slice(),
|
|
8886
|
+
lengths
|
|
8887
|
+
};
|
|
8888
|
+
}
|
|
8889
|
+
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
8890
|
+
const _1n$1 = BigInt(1), _2n$1 = BigInt(2), _3n = BigInt(3);
|
|
8891
|
+
const _5n = BigInt(5), _8n = BigInt(8);
|
|
8892
|
+
const ed25519_CURVE_p = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");
|
|
8893
|
+
const ed25519_CURVE = /* @__PURE__ */ (() => ({
|
|
8894
|
+
p: ed25519_CURVE_p,
|
|
8895
|
+
n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
|
|
8896
|
+
h: _8n,
|
|
8897
|
+
a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
|
|
8898
|
+
d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
|
|
8899
|
+
Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
|
|
8900
|
+
Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
|
|
8901
|
+
}))();
|
|
8902
|
+
function ed25519_pow_2_252_3(x2) {
|
|
8903
|
+
const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);
|
|
8904
|
+
const P2 = ed25519_CURVE_p;
|
|
8905
|
+
const x22 = x2 * x2 % P2;
|
|
8906
|
+
const b2 = x22 * x2 % P2;
|
|
8907
|
+
const b4 = pow2$1(b2, _2n$1, P2) * b2 % P2;
|
|
8908
|
+
const b5 = pow2$1(b4, _1n$1, P2) * x2 % P2;
|
|
8909
|
+
const b10 = pow2$1(b5, _5n, P2) * b5 % P2;
|
|
8910
|
+
const b20 = pow2$1(b10, _10n, P2) * b10 % P2;
|
|
8911
|
+
const b40 = pow2$1(b20, _20n, P2) * b20 % P2;
|
|
8912
|
+
const b80 = pow2$1(b40, _40n, P2) * b40 % P2;
|
|
8913
|
+
const b160 = pow2$1(b80, _80n, P2) * b80 % P2;
|
|
8914
|
+
const b240 = pow2$1(b160, _80n, P2) * b80 % P2;
|
|
8915
|
+
const b250 = pow2$1(b240, _10n, P2) * b10 % P2;
|
|
8916
|
+
const pow_p_5_8 = pow2$1(b250, _2n$1, P2) * x2 % P2;
|
|
8917
|
+
return { pow_p_5_8, b2 };
|
|
8918
|
+
}
|
|
8919
|
+
function adjustScalarBytes(bytes) {
|
|
8920
|
+
bytes[0] &= 248;
|
|
8921
|
+
bytes[31] &= 127;
|
|
8922
|
+
bytes[31] |= 64;
|
|
8923
|
+
return bytes;
|
|
8924
|
+
}
|
|
8925
|
+
const ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
8926
|
+
function uvRatio(u4, v2) {
|
|
8927
|
+
const P2 = ed25519_CURVE_p;
|
|
8928
|
+
const v3 = mod$1(v2 * v2 * v2, P2);
|
|
8929
|
+
const v7 = mod$1(v3 * v3 * v2, P2);
|
|
8930
|
+
const pow3 = ed25519_pow_2_252_3(u4 * v7).pow_p_5_8;
|
|
8931
|
+
let x2 = mod$1(u4 * v3 * pow3, P2);
|
|
8932
|
+
const vx2 = mod$1(v2 * x2 * x2, P2);
|
|
8933
|
+
const root1 = x2;
|
|
8934
|
+
const root2 = mod$1(x2 * ED25519_SQRT_M1, P2);
|
|
8935
|
+
const useRoot1 = vx2 === u4;
|
|
8936
|
+
const useRoot2 = vx2 === mod$1(-u4, P2);
|
|
8937
|
+
const noRoot = vx2 === mod$1(-u4 * ED25519_SQRT_M1, P2);
|
|
8938
|
+
if (useRoot1)
|
|
8939
|
+
x2 = root1;
|
|
8940
|
+
if (useRoot2 || noRoot)
|
|
8941
|
+
x2 = root2;
|
|
8942
|
+
if (isNegativeLE(x2, P2))
|
|
8943
|
+
x2 = mod$1(-x2, P2);
|
|
8944
|
+
return { isValid: useRoot1 || useRoot2, value: x2 };
|
|
8945
|
+
}
|
|
8946
|
+
const Fp = /* @__PURE__ */ (() => Field$1(ed25519_CURVE.p, { isLE: true }))();
|
|
8947
|
+
const ed25519Defaults = /* @__PURE__ */ (() => ({
|
|
8948
|
+
...ed25519_CURVE,
|
|
8949
|
+
Fp,
|
|
8950
|
+
hash: sha512$1,
|
|
8951
|
+
adjustScalarBytes,
|
|
8952
|
+
// dom2
|
|
8953
|
+
// Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.
|
|
8954
|
+
// Constant-time, u/√v
|
|
8955
|
+
uvRatio
|
|
8956
|
+
}))();
|
|
8957
|
+
const ed25519 = /* @__PURE__ */ (() => twistedEdwards(ed25519Defaults))();
|
|
8958
|
+
const x25519 = /* @__PURE__ */ (() => {
|
|
8959
|
+
const P2 = Fp.ORDER;
|
|
8960
|
+
return montgomery({
|
|
8961
|
+
P: P2,
|
|
8962
|
+
type: "x25519",
|
|
8963
|
+
powPminus2: (x2) => {
|
|
8964
|
+
const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x2);
|
|
8965
|
+
return mod$1(pow2$1(pow_p_5_8, _3n, P2) * b2, P2);
|
|
8966
|
+
},
|
|
8967
|
+
adjustScalarBytes
|
|
8968
|
+
});
|
|
8969
|
+
})();
|
|
8970
|
+
function extract(hash, ikm, salt) {
|
|
8971
|
+
ahash$1(hash);
|
|
8972
|
+
if (salt === void 0)
|
|
8973
|
+
salt = new Uint8Array(hash.outputLen);
|
|
8974
|
+
return hmac$1(hash, toBytes$1(salt), toBytes$1(ikm));
|
|
8975
|
+
}
|
|
8976
|
+
const HKDF_COUNTER = /* @__PURE__ */ Uint8Array.from([0]);
|
|
8977
|
+
const EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
|
|
8978
|
+
function expand(hash, prk, info, length = 32) {
|
|
8979
|
+
ahash$1(hash);
|
|
8980
|
+
anumber$3(length);
|
|
8981
|
+
const olen = hash.outputLen;
|
|
8982
|
+
if (length > 255 * olen)
|
|
8983
|
+
throw new Error("Length should be <= 255*HashLen");
|
|
8984
|
+
const blocks = Math.ceil(length / olen);
|
|
8985
|
+
if (info === void 0)
|
|
8986
|
+
info = EMPTY_BUFFER;
|
|
8987
|
+
const okm = new Uint8Array(blocks * olen);
|
|
8988
|
+
const HMAC3 = hmac$1.create(hash, prk);
|
|
8989
|
+
const HMACTmp = HMAC3._cloneInto();
|
|
8990
|
+
const T3 = new Uint8Array(HMAC3.outputLen);
|
|
8991
|
+
for (let counter = 0; counter < blocks; counter++) {
|
|
8992
|
+
HKDF_COUNTER[0] = counter + 1;
|
|
8993
|
+
HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T3).update(info).update(HKDF_COUNTER).digestInto(T3);
|
|
8994
|
+
okm.set(T3, olen * counter);
|
|
8995
|
+
HMAC3._cloneInto(HMACTmp);
|
|
8996
|
+
}
|
|
8997
|
+
HMAC3.destroy();
|
|
8998
|
+
HMACTmp.destroy();
|
|
8999
|
+
clean(T3, HKDF_COUNTER);
|
|
9000
|
+
return okm.slice(0, length);
|
|
9001
|
+
}
|
|
9002
|
+
const hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
|
|
9003
|
+
function hkdfSha256(ikm, info, length) {
|
|
9004
|
+
return hkdf(sha256$1, ikm, new Uint8Array(0), info, length);
|
|
9005
|
+
}
|
|
9006
|
+
function ed25519PublicKey(seed) {
|
|
9007
|
+
return ed25519.getPublicKey(seed);
|
|
9008
|
+
}
|
|
9009
|
+
function x25519PublicKey(privateKey) {
|
|
9010
|
+
return x25519.getPublicKey(privateKey);
|
|
9011
|
+
}
|
|
9012
|
+
hexToBytes$2("302e020100300506032b657004220420");
|
|
9013
|
+
const P$1 = 2n ** 255n - 19n;
|
|
9014
|
+
function littleEndian(bytes) {
|
|
9015
|
+
let n4 = 0n;
|
|
9016
|
+
for (let i3 = bytes.length - 1; i3 >= 0; i3--) {
|
|
9017
|
+
n4 = n4 << 8n | BigInt(bytes[i3]);
|
|
9018
|
+
}
|
|
9019
|
+
return n4;
|
|
9020
|
+
}
|
|
9021
|
+
/* @__PURE__ */ new Set([
|
|
9022
|
+
0n,
|
|
9023
|
+
1n,
|
|
9024
|
+
P$1 - 1n,
|
|
9025
|
+
littleEndian(hexToBytes$2("26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05")),
|
|
9026
|
+
littleEndian(hexToBytes$2("c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a"))
|
|
9027
|
+
]);
|
|
9028
|
+
const SIGNING_KEY_LABEL = "delegated-identity ed25519 signing key";
|
|
9029
|
+
const ENCRYPTION_KEY_LABEL = "delegated-identity x25519 encryption key";
|
|
9030
|
+
function toHex$1(bytes) {
|
|
9031
|
+
return `0x${bytesToHex$2(bytes)}`;
|
|
9032
|
+
}
|
|
9033
|
+
function deriveKeySet(originPrivateKey) {
|
|
9034
|
+
const ikm = toPrivateKeyBytes(originPrivateKey);
|
|
9035
|
+
if (ikm.length !== 32) {
|
|
9036
|
+
throw new Error(`an origin private key is 32 bytes, got ${ikm.length}`);
|
|
9037
|
+
}
|
|
9038
|
+
const signing = hkdfSha256(ikm, SIGNING_KEY_LABEL, 32);
|
|
9039
|
+
const encryption = hkdfSha256(ikm, ENCRYPTION_KEY_LABEL, 32);
|
|
9040
|
+
return {
|
|
9041
|
+
signing: { publicKey: toHex$1(ed25519PublicKey(signing)), privateKey: toHex$1(signing) },
|
|
9042
|
+
encryption: { publicKey: toHex$1(x25519PublicKey(encryption)), privateKey: toHex$1(encryption) }
|
|
9043
|
+
};
|
|
9044
|
+
}
|
|
9045
|
+
const KEY_PATTERN = /^0x[0-9a-fA-F]{64}$/;
|
|
9046
|
+
function taggedKeys(keySet) {
|
|
9047
|
+
var _a4, _b2;
|
|
9048
|
+
const signing = (_a4 = keySet == null ? void 0 : keySet.signing) == null ? void 0 : _a4.publicKey;
|
|
9049
|
+
const encryption = (_b2 = keySet == null ? void 0 : keySet.encryption) == null ? void 0 : _b2.publicKey;
|
|
9050
|
+
if (typeof signing !== "string" || !KEY_PATTERN.test(signing)) {
|
|
9051
|
+
throw new Error("the signing key is not 32 bytes of 0x-prefixed hex");
|
|
9052
|
+
}
|
|
9053
|
+
if (typeof encryption !== "string" || !KEY_PATTERN.test(encryption)) {
|
|
9054
|
+
throw new Error("the encryption key is not 32 bytes of 0x-prefixed hex");
|
|
9055
|
+
}
|
|
9056
|
+
return { signing: `ed25519:${signing.toLowerCase()}`, encryption: `x25519:${encryption.toLowerCase()}` };
|
|
9057
|
+
}
|
|
9058
|
+
function originPublicKeyPublicationMessage(orig, keySet) {
|
|
9059
|
+
const keys = taggedKeys(keySet);
|
|
9060
|
+
return [
|
|
9061
|
+
`Origin: ${orig}`,
|
|
9062
|
+
"",
|
|
9063
|
+
"IMPORTANT: Only sign on trusted websites.",
|
|
9064
|
+
"",
|
|
9065
|
+
"This authorizes the following keys for your account:",
|
|
9066
|
+
"",
|
|
9067
|
+
"Signing key, to act for your account in this app:",
|
|
9068
|
+
keys.signing,
|
|
9069
|
+
"",
|
|
9070
|
+
"Encryption key, for others to send you encrypted messages:",
|
|
9071
|
+
keys.encryption
|
|
9072
|
+
].join("\n");
|
|
9073
|
+
}
|
|
9074
|
+
new TextEncoder();
|
|
9075
|
+
function toPrivateKeyBytes(privateKey) {
|
|
9076
|
+
return typeof privateKey === "string" ? hexToBytes$2(privateKey.slice(2)) : privateKey;
|
|
9077
|
+
}
|
|
6967
9078
|
const bufToB64 = (buf) => btoa(String.fromCharCode(...new Uint8Array(buf)));
|
|
6968
9079
|
async function generateEcdhKeyPair() {
|
|
6969
9080
|
return window.crypto.subtle.generateKey(
|
|
@@ -7320,17 +9431,6 @@ Verify before proceeding.`;
|
|
|
7320
9431
|
function localKeyMessage() {
|
|
7321
9432
|
return "DO NOT ACCEPT THIS SIGNATURE REQUEST! This used by Etherplay Wallet to generate your seed phrase.";
|
|
7322
9433
|
}
|
|
7323
|
-
function originPublicKeyPublicationMessage(orig, publicKey) {
|
|
7324
|
-
return `Origin: ${orig}
|
|
7325
|
-
|
|
7326
|
-
IMPORTANT: Only sign on trusted websites.
|
|
7327
|
-
|
|
7328
|
-
This authorizes the following Public Key to represent your account:
|
|
7329
|
-
|
|
7330
|
-
${publicKey}
|
|
7331
|
-
|
|
7332
|
-
Others can use this key to write encrypted messages to you securely.`;
|
|
7333
|
-
}
|
|
7334
9434
|
function fromEntropyKeyToMnemonic(entropyKey) {
|
|
7335
9435
|
return entropyToMnemonic(hexToBytes$2(entropyKey.slice(2)), wordlist);
|
|
7336
9436
|
}
|
|
@@ -7359,7 +9459,8 @@ async function deriveOriginAccount(origin2, account, accountGenerator2, granted)
|
|
|
7359
9459
|
const originKey = fromSignatureToKey(originKeySignature);
|
|
7360
9460
|
const originMnemonic = fromEntropyKeyToMnemonic(originKey);
|
|
7361
9461
|
const originAccount = accountGenerator2.fromMnemonicToAccount(originMnemonic, 0);
|
|
7362
|
-
const
|
|
9462
|
+
const keySet = deriveKeySet(originAccount.privateKey);
|
|
9463
|
+
const savedPublicKeyPublicationSignature = await accountGenerator2.signTextMessage(originPublicKeyPublicationMessage(origin2, keySet), accountObject.privateKey);
|
|
7363
9464
|
const savedDelegations = [];
|
|
7364
9465
|
for (const delegation of (granted == null ? void 0 : granted.delegations) || []) {
|
|
7365
9466
|
const signature = await accountGenerator2.signTextMessage(delegationMessage({
|
|
@@ -7384,6 +9485,7 @@ async function deriveOriginAccount(origin2, account, accountGenerator2, granted)
|
|
|
7384
9485
|
address: originAccount.address,
|
|
7385
9486
|
privateKey: originAccount.privateKey
|
|
7386
9487
|
},
|
|
9488
|
+
keySet,
|
|
7387
9489
|
metadata: {},
|
|
7388
9490
|
mechanismUsed: account.signer.mechanismUsed,
|
|
7389
9491
|
savedPublicKeyPublicationSignature,
|
|
@@ -7690,8 +9792,8 @@ function getGlobal() {
|
|
|
7690
9792
|
if (typeof global$1 !== "undefined") return global$1;
|
|
7691
9793
|
return {};
|
|
7692
9794
|
}
|
|
7693
|
-
const G
|
|
7694
|
-
const FormDataCtor = typeof G
|
|
9795
|
+
const G = getGlobal();
|
|
9796
|
+
const FormDataCtor = typeof G.FormData !== "undefined" ? G.FormData : void 0;
|
|
7695
9797
|
const isFormData = (thing) => {
|
|
7696
9798
|
if (!thing) return false;
|
|
7697
9799
|
if (FormDataCtor && thing instanceof FormDataCtor) return true;
|
|
@@ -9474,13 +11576,13 @@ ieee754.write = function(buffer2, value, offset, isLE2, mLen, nBytes) {
|
|
|
9474
11576
|
if (offset + ext > buf.length) throw new RangeError("Index out of range");
|
|
9475
11577
|
if (offset < 0) throw new RangeError("Index out of range");
|
|
9476
11578
|
}
|
|
9477
|
-
function writeFloat(buf, value, offset,
|
|
11579
|
+
function writeFloat(buf, value, offset, littleEndian2, noAssert) {
|
|
9478
11580
|
value = +value;
|
|
9479
11581
|
offset = offset >>> 0;
|
|
9480
11582
|
if (!noAssert) {
|
|
9481
11583
|
checkIEEE754(buf, value, offset, 4);
|
|
9482
11584
|
}
|
|
9483
|
-
ieee754$1.write(buf, value, offset,
|
|
11585
|
+
ieee754$1.write(buf, value, offset, littleEndian2, 23, 4);
|
|
9484
11586
|
return offset + 4;
|
|
9485
11587
|
}
|
|
9486
11588
|
Buffer3.prototype.writeFloatLE = function writeFloatLE(value, offset, noAssert) {
|
|
@@ -9489,13 +11591,13 @@ ieee754.write = function(buffer2, value, offset, isLE2, mLen, nBytes) {
|
|
|
9489
11591
|
Buffer3.prototype.writeFloatBE = function writeFloatBE(value, offset, noAssert) {
|
|
9490
11592
|
return writeFloat(this, value, offset, false, noAssert);
|
|
9491
11593
|
};
|
|
9492
|
-
function writeDouble(buf, value, offset,
|
|
11594
|
+
function writeDouble(buf, value, offset, littleEndian2, noAssert) {
|
|
9493
11595
|
value = +value;
|
|
9494
11596
|
offset = offset >>> 0;
|
|
9495
11597
|
if (!noAssert) {
|
|
9496
11598
|
checkIEEE754(buf, value, offset, 8);
|
|
9497
11599
|
}
|
|
9498
|
-
ieee754$1.write(buf, value, offset,
|
|
11600
|
+
ieee754$1.write(buf, value, offset, littleEndian2, 52, 8);
|
|
9499
11601
|
return offset + 8;
|
|
9500
11602
|
}
|
|
9501
11603
|
Buffer3.prototype.writeDoubleLE = function writeDoubleLE(value, offset, noAssert) {
|
|
@@ -12630,17 +14732,17 @@ const c$8 = function(e4, ...t6) {
|
|
|
12630
14732
|
const a5 = "/v1/accounts/{id}".replace("{id}", encodeURIComponent(String(t7))), h2 = new URL(a5, i$9);
|
|
12631
14733
|
let u4;
|
|
12632
14734
|
e4 && (u4 = e4.baseOptions);
|
|
12633
|
-
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {},
|
|
12634
|
-
await r$h(p5, e4), await r$h(p5, e4), s5 && (
|
|
14735
|
+
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {}, P2 = {};
|
|
14736
|
+
await r$h(p5, e4), await r$h(p5, e4), s5 && (P2.expand = s5), c$8(h2, P2);
|
|
12635
14737
|
let w2 = u4 && u4.headers ? u4.headers : {};
|
|
12636
14738
|
return l3.headers = { ...p5, ...w2, ...n5.headers }, { url: d$6(h2), options: l3 };
|
|
12637
14739
|
}, getAccounts: async (t7, s5, n5, a5, o5, h2, u4, l3 = {}) => {
|
|
12638
14740
|
const p5 = new URL("/v1/accounts", i$9);
|
|
12639
|
-
let
|
|
12640
|
-
e4 && (
|
|
12641
|
-
const w2 = { method: "GET", ...
|
|
14741
|
+
let P2;
|
|
14742
|
+
e4 && (P2 = e4.baseOptions);
|
|
14743
|
+
const w2 = { method: "GET", ...P2, ...l3 }, g2 = {}, m2 = {};
|
|
12642
14744
|
await r$h(g2, e4), await r$h(g2, e4), await r$h(g2, e4), await r$h(g2, e4), await r$h(g2, e4), void 0 !== t7 && (m2.limit = t7), void 0 !== s5 && (m2.skip = s5), void 0 !== n5 && (m2.order = n5), void 0 !== a5 && (m2.chainId = a5), void 0 !== o5 && (m2.player = o5), void 0 !== h2 && (m2.address = h2), u4 && (m2.expand = u4), c$8(p5, m2);
|
|
12643
|
-
let y3 =
|
|
14745
|
+
let y3 = P2 && P2.headers ? P2.headers : {};
|
|
12644
14746
|
return w2.headers = { ...g2, ...y3, ...l3.headers }, { url: d$6(p5), options: w2 };
|
|
12645
14747
|
} };
|
|
12646
14748
|
}(t6);
|
|
@@ -12658,7 +14760,7 @@ const c$8 = function(e4, ...t6) {
|
|
|
12658
14760
|
return l$4(p5, axios, s$c, t6);
|
|
12659
14761
|
} };
|
|
12660
14762
|
};
|
|
12661
|
-
|
|
14763
|
+
class P extends n$d {
|
|
12662
14764
|
createAccount(e4, t6) {
|
|
12663
14765
|
return p$6(this.configuration).createAccount(e4.createAccountRequest, t6).then((e5) => e5(this.axios, this.basePath));
|
|
12664
14766
|
}
|
|
@@ -12671,7 +14773,7 @@ let P$1 = class P extends n$d {
|
|
|
12671
14773
|
getAccounts(e4 = {}, t6) {
|
|
12672
14774
|
return p$6(this.configuration).getAccounts(e4.limit, e4.skip, e4.order, e4.chainId, e4.player, e4.address, e4.expand, t6).then((e5) => e5(this.axios, this.basePath));
|
|
12673
14775
|
}
|
|
12674
|
-
}
|
|
14776
|
+
}
|
|
12675
14777
|
const w = function(t6) {
|
|
12676
14778
|
const n4 = /* @__PURE__ */ function(e4) {
|
|
12677
14779
|
return { createAccountV2: async (t7, s5 = {}) => {
|
|
@@ -12701,14 +14803,14 @@ const w = function(t6) {
|
|
|
12701
14803
|
await r$h(l3, e4), await r$h(l3, e4), await r$h(l3, e4), await r$h(l3, e4), await r$h(l3, e4), c$8(a5, {});
|
|
12702
14804
|
let p5 = h2 && h2.headers ? h2.headers : {};
|
|
12703
14805
|
return u4.headers = { ...l3, ...p5, ...s5.headers }, { url: d$6(a5), options: u4 };
|
|
12704
|
-
}, getAccountsV2: async (t7, s5, n5, a5, o5, h2, u4, l3, p5,
|
|
14806
|
+
}, getAccountsV2: async (t7, s5, n5, a5, o5, h2, u4, l3, p5, P2 = {}) => {
|
|
12705
14807
|
const w2 = new URL("/v2/accounts", i$9);
|
|
12706
14808
|
let g2;
|
|
12707
14809
|
e4 && (g2 = e4.baseOptions);
|
|
12708
|
-
const m2 = { method: "GET", ...g2, ...
|
|
14810
|
+
const m2 = { method: "GET", ...g2, ...P2 }, y3 = {}, R2 = {};
|
|
12709
14811
|
await r$h(y3, e4), await r$h(y3, e4), await r$h(y3, e4), await r$h(y3, e4), await r$h(y3, e4), void 0 !== t7 && (R2.limit = t7), void 0 !== s5 && (R2.skip = s5), void 0 !== n5 && (R2.order = n5), void 0 !== a5 && (R2.chainId = a5), void 0 !== o5 && (R2.user = o5), void 0 !== h2 && (R2.chainType = h2), void 0 !== u4 && (R2.accountType = u4), void 0 !== l3 && (R2.custody = l3), void 0 !== p5 && (R2.address = p5), c$8(w2, R2);
|
|
12710
14812
|
let f3 = g2 && g2.headers ? g2.headers : {};
|
|
12711
|
-
return m2.headers = { ...y3, ...f3, ...
|
|
14813
|
+
return m2.headers = { ...y3, ...f3, ...P2.headers }, { url: d$6(w2), options: m2 };
|
|
12712
14814
|
}, getSignerIdByAddress: async (t7, s5 = {}) => {
|
|
12713
14815
|
o$f("getSignerIdByAddress", "address", t7);
|
|
12714
14816
|
const n5 = new URL("/v2/accounts/signer", i$9);
|
|
@@ -12747,8 +14849,8 @@ const w = function(t6) {
|
|
|
12747
14849
|
}, async getAccountV2(a5, i3) {
|
|
12748
14850
|
const o5 = await n4.getAccountV2(a5, i3);
|
|
12749
14851
|
return l$4(o5, axios, s$c, t6);
|
|
12750
|
-
}, async getAccountsV2(a5, i3, o5, r7, h2, c3, u4, d2, p5,
|
|
12751
|
-
const w2 = await n4.getAccountsV2(a5, i3, o5, r7, h2, c3, u4, d2, p5,
|
|
14852
|
+
}, async getAccountsV2(a5, i3, o5, r7, h2, c3, u4, d2, p5, P2) {
|
|
14853
|
+
const w2 = await n4.getAccountsV2(a5, i3, o5, r7, h2, c3, u4, d2, p5, P2);
|
|
12752
14854
|
return l$4(w2, axios, s$c, t6);
|
|
12753
14855
|
}, async getSignerIdByAddress(a5, i3) {
|
|
12754
14856
|
const o5 = await n4.getSignerIdByAddress(a5, i3);
|
|
@@ -12811,8 +14913,8 @@ const m$3 = function(t6) {
|
|
|
12811
14913
|
e4 && (h2 = e4.baseOptions);
|
|
12812
14914
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12813
14915
|
await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12814
|
-
let
|
|
12815
|
-
return l3.headers = { ...p5, ...
|
|
14916
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
14917
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12816
14918
|
}, initSIWE: async (t7, s5, n5 = {}) => {
|
|
12817
14919
|
o$f("initSIWE", "sIWERequest", t7);
|
|
12818
14920
|
const a5 = new URL("/iam/v1/siwe/init", i$9);
|
|
@@ -12820,8 +14922,8 @@ const m$3 = function(t6) {
|
|
|
12820
14922
|
e4 && (h2 = e4.baseOptions);
|
|
12821
14923
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12822
14924
|
await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12823
|
-
let
|
|
12824
|
-
return l3.headers = { ...p5, ...
|
|
14925
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
14926
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12825
14927
|
}, linkEmail: async (t7, s5, n5 = {}) => {
|
|
12826
14928
|
o$f("linkEmail", "loginRequest", t7);
|
|
12827
14929
|
const a5 = new URL("/iam/v1/password/link", i$9);
|
|
@@ -12829,8 +14931,8 @@ const m$3 = function(t6) {
|
|
|
12829
14931
|
e4 && (h2 = e4.baseOptions);
|
|
12830
14932
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12831
14933
|
await r$h(p5, e4), await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12832
|
-
let
|
|
12833
|
-
return l3.headers = { ...p5, ...
|
|
14934
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
14935
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12834
14936
|
}, linkOAuth: async (t7, s5, n5 = {}) => {
|
|
12835
14937
|
o$f("linkOAuth", "oAuthInitRequest", t7);
|
|
12836
14938
|
const a5 = new URL("/iam/v1/oauth/init_link", i$9);
|
|
@@ -12838,8 +14940,8 @@ const m$3 = function(t6) {
|
|
|
12838
14940
|
e4 && (h2 = e4.baseOptions);
|
|
12839
14941
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12840
14942
|
await r$h(p5, e4), await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12841
|
-
let
|
|
12842
|
-
return l3.headers = { ...p5, ...
|
|
14943
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
14944
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12843
14945
|
}, linkSIWE: async (t7, s5 = {}) => {
|
|
12844
14946
|
o$f("linkSIWE", "sIWEAuthenticateRequest", t7);
|
|
12845
14947
|
const n5 = new URL("/iam/v1/siwe/link", i$9);
|
|
@@ -12856,8 +14958,8 @@ const m$3 = function(t6) {
|
|
|
12856
14958
|
e4 && (h2 = e4.baseOptions);
|
|
12857
14959
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12858
14960
|
await r$h(p5, e4), await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12859
|
-
let
|
|
12860
|
-
return l3.headers = { ...p5, ...
|
|
14961
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
14962
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12861
14963
|
}, loginEmailPassword: async (t7, s5, n5 = {}) => {
|
|
12862
14964
|
o$f("loginEmailPassword", "loginRequest", t7);
|
|
12863
14965
|
const a5 = new URL("/iam/v1/password/login", i$9);
|
|
@@ -12865,8 +14967,8 @@ const m$3 = function(t6) {
|
|
|
12865
14967
|
e4 && (h2 = e4.baseOptions);
|
|
12866
14968
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12867
14969
|
await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12868
|
-
let
|
|
12869
|
-
return l3.headers = { ...p5, ...
|
|
14970
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
14971
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12870
14972
|
}, loginWithIdToken: async (t7, s5 = {}) => {
|
|
12871
14973
|
o$f("loginWithIdToken", "loginWithIdTokenRequest", t7);
|
|
12872
14974
|
const n5 = new URL("/iam/v1/oauth/login_id_token", i$9);
|
|
@@ -12953,8 +15055,8 @@ const m$3 = function(t6) {
|
|
|
12953
15055
|
e4 && (h2 = e4.baseOptions);
|
|
12954
15056
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12955
15057
|
await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12956
|
-
let
|
|
12957
|
-
return l3.headers = { ...p5, ...
|
|
15058
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
15059
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12958
15060
|
}, thirdParty: async (t7, s5, n5 = {}) => {
|
|
12959
15061
|
o$f("thirdParty", "thirdPartyOAuthRequest", t7);
|
|
12960
15062
|
const a5 = new URL("/iam/v1/oauth/third_party", i$9);
|
|
@@ -12962,8 +15064,8 @@ const m$3 = function(t6) {
|
|
|
12962
15064
|
e4 && (h2 = e4.baseOptions);
|
|
12963
15065
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
12964
15066
|
await r$h(p5, e4), await r$h(p5, e4), null != s5 && (p5["x-game"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
12965
|
-
let
|
|
12966
|
-
return l3.headers = { ...p5, ...
|
|
15067
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
15068
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
12967
15069
|
}, unlinkEmail: async (t7, s5 = {}) => {
|
|
12968
15070
|
o$f("unlinkEmail", "unlinkEmailRequest", t7);
|
|
12969
15071
|
const n5 = new URL("/iam/v1/password/unlink", i$9);
|
|
@@ -13402,8 +15504,8 @@ const R$1 = function(t6) {
|
|
|
13402
15504
|
const a5 = "/reset-password/{token}".replace("{token}", encodeURIComponent(String(t7))), h2 = new URL(a5, i$9);
|
|
13403
15505
|
let u4;
|
|
13404
15506
|
e4 && (u4 = e4.baseOptions);
|
|
13405
|
-
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {},
|
|
13406
|
-
await r$h(p5, e4), void 0 !== s5 && (
|
|
15507
|
+
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {}, P2 = {};
|
|
15508
|
+
await r$h(p5, e4), void 0 !== s5 && (P2.callbackURL = s5), c$8(h2, P2);
|
|
13407
15509
|
let w2 = u4 && u4.headers ? u4.headers : {};
|
|
13408
15510
|
return l3.headers = { ...p5, ...w2, ...n5.headers }, { url: d$6(h2), options: l3 };
|
|
13409
15511
|
}, revokeOtherSessionsPost: async (t7, s5 = {}) => {
|
|
@@ -13532,8 +15634,8 @@ const R$1 = function(t6) {
|
|
|
13532
15634
|
e4 && (h2 = e4.baseOptions);
|
|
13533
15635
|
const u4 = { method: "GET", ...h2, ...n5 }, l3 = {}, p5 = {};
|
|
13534
15636
|
await r$h(l3, e4), void 0 !== t7 && (p5.token = t7), void 0 !== s5 && (p5.callbackURL = s5), c$8(a5, p5);
|
|
13535
|
-
let
|
|
13536
|
-
return u4.headers = { ...l3, ...
|
|
15637
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
15638
|
+
return u4.headers = { ...l3, ...P2, ...n5.headers }, { url: d$6(a5), options: u4 };
|
|
13537
15639
|
} };
|
|
13538
15640
|
}(t6);
|
|
13539
15641
|
return { async accountInfoPost(a5, i3) {
|
|
@@ -13799,10 +15901,10 @@ const b = function(t6) {
|
|
|
13799
15901
|
const a5 = "/rpc/{chainId}".replace("{chainId}", encodeURIComponent(String(t7))), h2 = new URL(a5, i$9);
|
|
13800
15902
|
let l3;
|
|
13801
15903
|
e4 && (l3 = e4.baseOptions);
|
|
13802
|
-
const p5 = { method: "POST", ...l3, ...n5 },
|
|
13803
|
-
await r$h(
|
|
15904
|
+
const p5 = { method: "POST", ...l3, ...n5 }, P2 = {};
|
|
15905
|
+
await r$h(P2, e4), P2["Content-Type"] = "application/json", c$8(h2, {});
|
|
13804
15906
|
let w2 = l3 && l3.headers ? l3.headers : {};
|
|
13805
|
-
return p5.headers = { ...
|
|
15907
|
+
return p5.headers = { ...P2, ...w2, ...n5.headers }, p5.data = u$4(s5, p5, e4), { url: d$6(h2), options: p5 };
|
|
13806
15908
|
}, handleRpcRequest: async (t7, s5 = {}) => {
|
|
13807
15909
|
o$f("handleRpcRequest", "jsonRpcRequest", t7);
|
|
13808
15910
|
const n5 = new URL("/rpc", i$9);
|
|
@@ -13839,24 +15941,24 @@ const S = function(t6) {
|
|
|
13839
15941
|
e4 && (h2 = e4.baseOptions);
|
|
13840
15942
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
13841
15943
|
await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), null != s5 && (p5["X-Behalf-Of-Project"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
13842
|
-
let
|
|
13843
|
-
return l3.headers = { ...p5, ...
|
|
15944
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
15945
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
13844
15946
|
}, getPlayerSessions: async (t7, s5, n5, a5, h2, u4 = {}) => {
|
|
13845
15947
|
o$f("getPlayerSessions", "player", t7);
|
|
13846
15948
|
const l3 = new URL("/v1/sessions", i$9);
|
|
13847
15949
|
let p5;
|
|
13848
15950
|
e4 && (p5 = e4.baseOptions);
|
|
13849
|
-
const
|
|
15951
|
+
const P2 = { method: "GET", ...p5, ...u4 }, w2 = {}, g2 = {};
|
|
13850
15952
|
await r$h(w2, e4), await r$h(w2, e4), void 0 !== s5 && (g2.limit = s5), void 0 !== n5 && (g2.skip = n5), void 0 !== a5 && (g2.order = a5), void 0 !== t7 && (g2.player = t7), h2 && (g2.expand = h2), c$8(l3, g2);
|
|
13851
15953
|
let m2 = p5 && p5.headers ? p5.headers : {};
|
|
13852
|
-
return
|
|
15954
|
+
return P2.headers = { ...w2, ...m2, ...u4.headers }, { url: d$6(l3), options: P2 };
|
|
13853
15955
|
}, getSession: async (t7, s5, n5 = {}) => {
|
|
13854
15956
|
o$f("getSession", "id", t7);
|
|
13855
15957
|
const a5 = "/v1/sessions/{id}".replace("{id}", encodeURIComponent(String(t7))), h2 = new URL(a5, i$9);
|
|
13856
15958
|
let u4;
|
|
13857
15959
|
e4 && (u4 = e4.baseOptions);
|
|
13858
|
-
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {},
|
|
13859
|
-
await r$h(p5, e4), await r$h(p5, e4), s5 && (
|
|
15960
|
+
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {}, P2 = {};
|
|
15961
|
+
await r$h(p5, e4), await r$h(p5, e4), s5 && (P2.expand = s5), c$8(h2, P2);
|
|
13860
15962
|
let w2 = u4 && u4.headers ? u4.headers : {};
|
|
13861
15963
|
return l3.headers = { ...p5, ...w2, ...n5.headers }, { url: d$6(h2), options: l3 };
|
|
13862
15964
|
}, revokeSession: async (t7, s5, n5 = {}) => {
|
|
@@ -13866,17 +15968,17 @@ const S = function(t6) {
|
|
|
13866
15968
|
e4 && (h2 = e4.baseOptions);
|
|
13867
15969
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
13868
15970
|
await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), null != s5 && (p5["X-Behalf-Of-Project"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
13869
|
-
let
|
|
13870
|
-
return l3.headers = { ...p5, ...
|
|
15971
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
15972
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
13871
15973
|
}, signatureSession: async (t7, s5, n5 = {}) => {
|
|
13872
15974
|
o$f("signatureSession", "id", t7), o$f("signatureSession", "signatureRequest", s5);
|
|
13873
15975
|
const a5 = "/v1/sessions/{id}/signature".replace("{id}", encodeURIComponent(String(t7))), h2 = new URL(a5, i$9);
|
|
13874
15976
|
let l3;
|
|
13875
15977
|
e4 && (l3 = e4.baseOptions);
|
|
13876
|
-
const p5 = { method: "POST", ...l3, ...n5 },
|
|
13877
|
-
await r$h(
|
|
15978
|
+
const p5 = { method: "POST", ...l3, ...n5 }, P2 = {};
|
|
15979
|
+
await r$h(P2, e4), await r$h(P2, e4), await r$h(P2, e4), P2["Content-Type"] = "application/json", c$8(h2, {});
|
|
13878
15980
|
let w2 = l3 && l3.headers ? l3.headers : {};
|
|
13879
|
-
return p5.headers = { ...
|
|
15981
|
+
return p5.headers = { ...P2, ...w2, ...n5.headers }, p5.data = u$4(s5, p5, e4), { url: d$6(h2), options: p5 };
|
|
13880
15982
|
} };
|
|
13881
15983
|
}(t6);
|
|
13882
15984
|
return { async createSession(a5, i3, o5) {
|
|
@@ -13922,8 +16024,8 @@ const k$1 = function(t6) {
|
|
|
13922
16024
|
e4 && (h2 = e4.baseOptions);
|
|
13923
16025
|
const l3 = { method: "POST", ...h2, ...n5 }, p5 = {};
|
|
13924
16026
|
await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), null != s5 && (p5["X-Behalf-Of-Project"] = String(s5)), p5["Content-Type"] = "application/json", c$8(a5, {});
|
|
13925
|
-
let
|
|
13926
|
-
return l3.headers = { ...p5, ...
|
|
16027
|
+
let P2 = h2 && h2.headers ? h2.headers : {};
|
|
16028
|
+
return l3.headers = { ...p5, ...P2, ...n5.headers }, l3.data = u$4(t7, l3, e4), { url: d$6(a5), options: l3 };
|
|
13927
16029
|
}, estimateTransactionIntentCost: async (t7, s5 = {}) => {
|
|
13928
16030
|
o$f("estimateTransactionIntentCost", "createTransactionIntentRequest", t7);
|
|
13929
16031
|
const n5 = new URL("/v1/transaction_intents/estimate_gas_cost", i$9);
|
|
@@ -13938,27 +16040,27 @@ const k$1 = function(t6) {
|
|
|
13938
16040
|
const a5 = "/v1/transaction_intents/{id}".replace("{id}", encodeURIComponent(String(t7))), h2 = new URL(a5, i$9);
|
|
13939
16041
|
let u4;
|
|
13940
16042
|
e4 && (u4 = e4.baseOptions);
|
|
13941
|
-
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {},
|
|
13942
|
-
await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), s5 && (
|
|
16043
|
+
const l3 = { method: "GET", ...u4, ...n5 }, p5 = {}, P2 = {};
|
|
16044
|
+
await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), await r$h(p5, e4), s5 && (P2.expand = s5), c$8(h2, P2);
|
|
13943
16045
|
let w2 = u4 && u4.headers ? u4.headers : {};
|
|
13944
16046
|
return l3.headers = { ...p5, ...w2, ...n5.headers }, { url: d$6(h2), options: l3 };
|
|
13945
|
-
}, getTransactionIntents: async (t7, s5, n5, a5, o5, h2, u4, l3, p5,
|
|
16047
|
+
}, getTransactionIntents: async (t7, s5, n5, a5, o5, h2, u4, l3, p5, P2 = {}) => {
|
|
13946
16048
|
const w2 = new URL("/v1/transaction_intents", i$9);
|
|
13947
16049
|
let g2;
|
|
13948
16050
|
e4 && (g2 = e4.baseOptions);
|
|
13949
|
-
const m2 = { method: "GET", ...g2, ...
|
|
16051
|
+
const m2 = { method: "GET", ...g2, ...P2 }, y3 = {}, R2 = {};
|
|
13950
16052
|
await r$h(y3, e4), await r$h(y3, e4), void 0 !== t7 && (R2.limit = t7), void 0 !== s5 && (R2.skip = s5), void 0 !== n5 && (R2.order = n5), a5 && (R2.expand = a5), void 0 !== o5 && (R2.chainId = o5), h2 && (R2.account = h2), u4 && (R2.player = u4), void 0 !== l3 && (R2.status = l3), p5 && (R2.policy = p5), c$8(w2, R2);
|
|
13951
16053
|
let f3 = g2 && g2.headers ? g2.headers : {};
|
|
13952
|
-
return m2.headers = { ...y3, ...f3, ...
|
|
16054
|
+
return m2.headers = { ...y3, ...f3, ...P2.headers }, { url: d$6(w2), options: m2 };
|
|
13953
16055
|
}, signature: async (t7, s5, n5 = {}) => {
|
|
13954
16056
|
o$f("signature", "id", t7), o$f("signature", "signatureRequest", s5);
|
|
13955
16057
|
const a5 = "/v1/transaction_intents/{id}/signature".replace("{id}", encodeURIComponent(String(t7))), h2 = new URL(a5, i$9);
|
|
13956
16058
|
let l3;
|
|
13957
16059
|
e4 && (l3 = e4.baseOptions);
|
|
13958
|
-
const p5 = { method: "POST", ...l3, ...n5 },
|
|
13959
|
-
await r$h(
|
|
16060
|
+
const p5 = { method: "POST", ...l3, ...n5 }, P2 = {};
|
|
16061
|
+
await r$h(P2, e4), await r$h(P2, e4), P2["Content-Type"] = "application/json", c$8(h2, {});
|
|
13960
16062
|
let w2 = l3 && l3.headers ? l3.headers : {};
|
|
13961
|
-
return p5.headers = { ...
|
|
16063
|
+
return p5.headers = { ...P2, ...w2, ...n5.headers }, p5.data = u$4(s5, p5, e4), { url: d$6(h2), options: p5 };
|
|
13962
16064
|
} };
|
|
13963
16065
|
}(t6);
|
|
13964
16066
|
return { async createTransactionIntent(a5, i3, o5) {
|
|
@@ -13970,8 +16072,8 @@ const k$1 = function(t6) {
|
|
|
13970
16072
|
}, async getTransactionIntent(a5, i3, o5) {
|
|
13971
16073
|
const r7 = await n4.getTransactionIntent(a5, i3, o5);
|
|
13972
16074
|
return l$4(r7, axios, s$c, t6);
|
|
13973
|
-
}, async getTransactionIntents(a5, i3, o5, r7, h2, c3, u4, d2, p5,
|
|
13974
|
-
const w2 = await n4.getTransactionIntents(a5, i3, o5, r7, h2, c3, u4, d2, p5,
|
|
16075
|
+
}, async getTransactionIntents(a5, i3, o5, r7, h2, c3, u4, d2, p5, P2) {
|
|
16076
|
+
const w2 = await n4.getTransactionIntents(a5, i3, o5, r7, h2, c3, u4, d2, p5, P2);
|
|
13975
16077
|
return l$4(w2, axios, s$c, t6);
|
|
13976
16078
|
}, async signature(a5, i3, o5) {
|
|
13977
16079
|
const r7 = await n4.signature(a5, i3, o5);
|
|
@@ -14015,14 +16117,14 @@ const q = function(t6) {
|
|
|
14015
16117
|
await r$h(l3, e4), await r$h(l3, e4), c$8(a5, {});
|
|
14016
16118
|
let p5 = h2 && h2.headers ? h2.headers : {};
|
|
14017
16119
|
return u4.headers = { ...l3, ...p5, ...s5.headers }, { url: d$6(a5), options: u4 };
|
|
14018
|
-
}, getAuthUsers: async (t7, s5, n5, a5, o5, h2, u4, l3, p5,
|
|
16120
|
+
}, getAuthUsers: async (t7, s5, n5, a5, o5, h2, u4, l3, p5, P2 = {}) => {
|
|
14019
16121
|
const w2 = new URL("/v2/users", i$9);
|
|
14020
16122
|
let g2;
|
|
14021
16123
|
e4 && (g2 = e4.baseOptions);
|
|
14022
|
-
const m2 = { method: "GET", ...g2, ...
|
|
16124
|
+
const m2 = { method: "GET", ...g2, ...P2 }, y3 = {}, R2 = {};
|
|
14023
16125
|
await r$h(y3, e4), await r$h(y3, e4), void 0 !== t7 && (R2.limit = t7), void 0 !== s5 && (R2.skip = s5), void 0 !== n5 && (R2.order = n5), void 0 !== a5 && (R2.name = a5), void 0 !== o5 && (R2.externalUserId = o5), void 0 !== h2 && (R2.email = h2), void 0 !== u4 && (R2.phoneNumber = u4), void 0 !== l3 && (R2.authProviderId = l3), void 0 !== p5 && (R2.walletClientType = p5), c$8(w2, R2);
|
|
14024
16126
|
let f3 = g2 && g2.headers ? g2.headers : {};
|
|
14025
|
-
return m2.headers = { ...y3, ...f3, ...
|
|
16127
|
+
return m2.headers = { ...y3, ...f3, ...P2.headers }, { url: d$6(w2), options: m2 };
|
|
14026
16128
|
}, getUserWallet: async (t7, s5 = {}) => {
|
|
14027
16129
|
o$f("getUserWallet", "id", t7);
|
|
14028
16130
|
const n5 = "/v2/users/{id}/wallet".replace("{id}", encodeURIComponent(String(t7))), a5 = new URL(n5, i$9);
|
|
@@ -14066,8 +16168,8 @@ const q = function(t6) {
|
|
|
14066
16168
|
}, async getAuthUser(a5, i3) {
|
|
14067
16169
|
const o5 = await n4.getAuthUser(a5, i3);
|
|
14068
16170
|
return l$4(o5, axios, s$c, t6);
|
|
14069
|
-
}, async getAuthUsers(a5, i3, o5, r7, h2, c3, u4, d2, p5,
|
|
14070
|
-
const w2 = await n4.getAuthUsers(a5, i3, o5, r7, h2, c3, u4, d2, p5,
|
|
16171
|
+
}, async getAuthUsers(a5, i3, o5, r7, h2, c3, u4, d2, p5, P2) {
|
|
16172
|
+
const w2 = await n4.getAuthUsers(a5, i3, o5, r7, h2, c3, u4, d2, p5, P2);
|
|
14071
16173
|
return l$4(w2, axios, s$c, t6);
|
|
14072
16174
|
}, async getUserWallet(a5, i3) {
|
|
14073
16175
|
const o5 = await n4.getUserWallet(a5, i3);
|
|
@@ -14083,7 +16185,7 @@ const q = function(t6) {
|
|
|
14083
16185
|
return l$4(o5, axios, s$c, t6);
|
|
14084
16186
|
} };
|
|
14085
16187
|
};
|
|
14086
|
-
|
|
16188
|
+
class I extends n$d {
|
|
14087
16189
|
deleteUser(e4, t6) {
|
|
14088
16190
|
return q(this.configuration).deleteUser(e4.id, t6).then((e5) => e5(this.axios, this.basePath));
|
|
14089
16191
|
}
|
|
@@ -14105,7 +16207,7 @@ let I$1 = class I extends n$d {
|
|
|
14105
16207
|
thirdPartyV2(e4, t6) {
|
|
14106
16208
|
return q(this.configuration).thirdPartyV2(e4.thirdPartyOAuthRequest, t6).then((e5) => e5(this.axios, this.basePath));
|
|
14107
16209
|
}
|
|
14108
|
-
}
|
|
16210
|
+
}
|
|
14109
16211
|
class x {
|
|
14110
16212
|
constructor(e4 = {}) {
|
|
14111
16213
|
__publicField(this, "apiKey");
|
|
@@ -14145,7 +16247,7 @@ let U$1 = class U {
|
|
|
14145
16247
|
const n4 = { basePath: s5.basePath, accessToken: s5.accessToken, nativeAppIdentifier: s5.nativeAppIdentifier };
|
|
14146
16248
|
this.config = { backend: A$3(n4) };
|
|
14147
16249
|
const a5 = { basePath: `${s5.basePath}/iam/v2/auth`, accessToken: "", nativeAppIdentifier: s5.nativeAppIdentifier }, i3 = A$3(a5);
|
|
14148
|
-
this.authenticationApi = new y$3(this.config.backend, void 0, this.axiosInstance), this.authApi = new f$2(i3, void 0, this.axiosInstance), this.userApi = new I
|
|
16250
|
+
this.authenticationApi = new y$3(this.config.backend, void 0, this.axiosInstance), this.authApi = new f$2(i3, void 0, this.axiosInstance), this.userApi = new I(this.config.backend, void 0, this.axiosInstance), this.transactionIntentsApi = new v(this.config.backend, void 0, this.axiosInstance), this.accountsApi = new P(this.config.backend, void 0, this.axiosInstance), this.accountsV2Api = new g(this.config.backend, void 0, this.axiosInstance), this.sessionsApi = new T$2(this.config.backend, void 0, this.axiosInstance), this.rpcApi = new O$3(this.config.backend, void 0, this.axiosInstance);
|
|
14149
16251
|
}
|
|
14150
16252
|
setupInterceptors() {
|
|
14151
16253
|
this.axiosInstance.interceptors.response.use((e4) => e4, async (e4) => {
|
|
@@ -14281,7 +16383,7 @@ let a$c = class a2 extends t$i {
|
|
|
14281
16383
|
this.statusCode = r7, this.name = "RequestError", Object.setPrototypeOf(this, a2.prototype);
|
|
14282
16384
|
}
|
|
14283
16385
|
};
|
|
14284
|
-
var E$3, A$2, e$9, T$1, t$h, n$b, o$c, O$1, _, C$
|
|
16386
|
+
var E$3, A$2, e$9, T$1, t$h, n$b, o$c, O$1, _, C$2, N, c$6, a$b;
|
|
14285
16387
|
!function(E2) {
|
|
14286
16388
|
E2[E2.NONE = 0] = "NONE", E2[E2.UNAUTHENTICATED = 1] = "UNAUTHENTICATED", E2[E2.EMBEDDED_SIGNER_NOT_CONFIGURED = 2] = "EMBEDDED_SIGNER_NOT_CONFIGURED", E2[E2.CREATING_ACCOUNT = 3] = "CREATING_ACCOUNT", E2[E2.READY = 4] = "READY";
|
|
14287
16389
|
}(E$3 || (E$3 = {})), function(E2) {
|
|
@@ -14302,9 +16404,9 @@ var E$3, A$2, e$9, T$1, t$h, n$b, o$c, O$1, _, C$3, N$1, c$6, a$b;
|
|
|
14302
16404
|
E2.GOOGLE = "google", E2.TWITTER = "twitter", E2.APPLE = "apple", E2.FACEBOOK = "facebook", E2.DISCORD = "discord", E2.EPIC_GAMES = "epic_games", E2.LINE = "line";
|
|
14303
16405
|
}(_ || (_ = {})), function(E2) {
|
|
14304
16406
|
E2.ACTION_VERIFY_EMAIL = "verify_email";
|
|
14305
|
-
}(C$
|
|
16407
|
+
}(C$2 || (C$2 = {})), function(E2) {
|
|
14306
16408
|
E2.EOA = "Externally Owned Account", E2.SMART_ACCOUNT = "Smart Account", E2.DELEGATED_ACCOUNT = "Delegated Account";
|
|
14307
|
-
}(N
|
|
16409
|
+
}(N || (N = {})), function(E2) {
|
|
14308
16410
|
E2.EVM = "EVM", E2.SVM = "SVM";
|
|
14309
16411
|
}(c$6 || (c$6 = {})), function(E2) {
|
|
14310
16412
|
E2.ASC = "asc", E2.DESC = "desc";
|
|
@@ -15117,7 +17219,7 @@ let n$9 = (_e = class {
|
|
|
15117
17219
|
}
|
|
15118
17220
|
static async init({ sentry: e4, configuration: o5 }) {
|
|
15119
17221
|
if (e4) return void (_e.sentry = e4);
|
|
15120
|
-
const a5 = await __vitePreload(() => import("./index-
|
|
17222
|
+
const a5 = await __vitePreload(() => import("./index-BSfEJRCZ.js"), true ? __vite__mapDeps([0,1,2,3]) : void 0);
|
|
15121
17223
|
_e.sentry = new a5.BrowserClient({ dsn: r$a, integrations: [], stackParser: a5.defaultStackParser, transport: a5.makeFetchTransport }), _e.baseTags = { projectId: (o5 == null ? void 0 : o5.baseConfiguration.publishableKey) ?? "", sdk: t$d, sdkVersion: o$9 }, _e.processQueuedCalls();
|
|
15122
17224
|
}
|
|
15123
17225
|
static processQueuedCalls() {
|
|
@@ -15224,7 +17326,7 @@ let p$3 = class p3 {
|
|
|
15224
17326
|
}
|
|
15225
17327
|
async switchChain({ chainId: e4 }) {
|
|
15226
17328
|
const t6 = await s$9.fromStorage(this.storage);
|
|
15227
|
-
if ((t6 == null ? void 0 : t6.accountType) === N
|
|
17329
|
+
if ((t6 == null ? void 0 : t6.accountType) === N.EOA) new s$9({ ...t6, chainId: e4 }).save(this.storage);
|
|
15228
17330
|
else {
|
|
15229
17331
|
const a5 = await this.iframeManager.switchChain(e4);
|
|
15230
17332
|
new s$9({ ...t6, id: a5.account, chainId: e4 }).save(this.storage);
|
|
@@ -15510,23 +17612,23 @@ const t$8 = async (t6) => {
|
|
|
15510
17612
|
let g2 = a5;
|
|
15511
17613
|
if ([T$1.UPGRADEABLE_V5, T$1.UPGRADEABLE_V6].includes(d2)) {
|
|
15512
17614
|
const e4 = { name: "Openfort", version: "0.5", chainId: Number(o5), verifyingContract: c3 }, t7 = { OpenfortMessage: [{ name: "hashedMessage", type: "bytes32" }] }, a6 = { hashedMessage: g2 }, { _TypedDataEncoder: s6 } = await __vitePreload(async () => {
|
|
15513
|
-
const { _TypedDataEncoder: s7 } = await import("./index-
|
|
17615
|
+
const { _TypedDataEncoder: s7 } = await import("./index-IIDV-e6n.js");
|
|
15514
17616
|
return { _TypedDataEncoder: s7 };
|
|
15515
17617
|
}, true ? __vite__mapDeps([4,5,6,7,1,2,3]) : void 0);
|
|
15516
17618
|
g2 = s6.hash(e4, t7, a6);
|
|
15517
17619
|
}
|
|
15518
|
-
const
|
|
17620
|
+
const P2 = await s5.sign(g2, false, false);
|
|
15519
17621
|
if (i3 && n4 && [T$1.UPGRADEABLE_V5, T$1.UPGRADEABLE_V6].includes(d2)) {
|
|
15520
|
-
const { id: e4 } = await __vitePreload(() => import("./index-
|
|
15521
|
-
const { defaultAbiCoder: t8 } = await import("./index-
|
|
17622
|
+
const { id: e4 } = await __vitePreload(() => import("./index-IIDV-e6n.js"), true ? __vite__mapDeps([4,5,6,7,1,2,3]) : void 0), { defaultAbiCoder: t7 } = await __vitePreload(async () => {
|
|
17623
|
+
const { defaultAbiCoder: t8 } = await import("./index-LN4UBwKA.js");
|
|
15522
17624
|
return { defaultAbiCoder: t8 };
|
|
15523
17625
|
}, true ? __vite__mapDeps([8,7,9,6,1,2,3]) : void 0), { hexConcat: a6 } = await __vitePreload(async () => {
|
|
15524
17626
|
const { hexConcat: a7 } = await Promise.resolve().then(() => index$1);
|
|
15525
17627
|
return { hexConcat: a7 };
|
|
15526
17628
|
}, true ? void 0 : void 0), s6 = a6([e4("createAccountWithNonce(address,bytes32,bool)").slice(0, 10), t7.encode(["address", "bytes32", "bool"], [r7, n4, false])]);
|
|
15527
|
-
return a6([t7.encode(["address", "bytes", "bytes"], [i3, s6,
|
|
17629
|
+
return a6([t7.encode(["address", "bytes", "bytes"], [i3, s6, P2]), "0x6492649264926492649264926492649264926492649264926492649264926492"]);
|
|
15528
17630
|
}
|
|
15529
|
-
return
|
|
17631
|
+
return P2;
|
|
15530
17632
|
};
|
|
15531
17633
|
async function a$7(e4, t6, a5) {
|
|
15532
17634
|
const s5 = { ...e4 };
|
|
@@ -15564,7 +17666,7 @@ const t$7 = async ({ params: t6, signer: o5, account: n4 }) => {
|
|
|
15564
17666
|
const i3 = t6[0], d2 = t6[1];
|
|
15565
17667
|
if (!d2 || !i3) throw new A$1(E$2.INVALID_PARAMS, "personal_sign requires an address and a message");
|
|
15566
17668
|
if (d2.toLowerCase() !== n4.address.toLowerCase()) throw new A$1(E$2.INVALID_PARAMS, "personal_sign requires the signer to be the from address");
|
|
15567
|
-
const { hashMessage: p5 } = await __vitePreload(() => import("./index-
|
|
17669
|
+
const { hashMessage: p5 } = await __vitePreload(() => import("./index-IIDV-e6n.js"), true ? __vite__mapDeps([4,5,6,7,1,2,3]) : void 0);
|
|
15568
17670
|
return await t$8({ hash: p5(n$a(i3)), implementationType: n4.implementationType || n4.type, chainId: Number(n4.chainId), signer: o5, address: d2, salt: n4.salt, factoryAddress: n4.factoryAddress, ownerAddress: n4.ownerAddress });
|
|
15569
17671
|
};
|
|
15570
17672
|
function a$6(t6) {
|
|
@@ -17001,7 +19103,7 @@ const d$5 = async ({ params: d2, signer: p5, account: l3, authentication: u4, ba
|
|
|
17001
19103
|
var _a4, _b2, _c4, _d4, _e4, _f2, _g3, _h4, _i3, _j;
|
|
17002
19104
|
const A3 = ((_c4 = (_b2 = (_a4 = d2[0]) == null ? void 0 : _a4.capabilities) == null ? void 0 : _b2.paymasterService) == null ? void 0 : _c4.policy) ?? T3;
|
|
17003
19105
|
let m2;
|
|
17004
|
-
if (l3.accountType === N
|
|
19106
|
+
if (l3.accountType === N.DELEGATED_ACCOUNT) {
|
|
17005
19107
|
const [e4, t6] = await Promise.all([c$4(g2, l3.address), g2.getTransactionCount(l3.address)]);
|
|
17006
19108
|
if (!e4) {
|
|
17007
19109
|
const e5 = await i$5({ signer: p5, accountAddress: l3.address, contractAddress: l3.implementationAddress, chainId: l3.chainId, nonce: t6 });
|
|
@@ -17052,15 +19154,15 @@ const r$5 = ["types", "domain", "primaryType", "message"], n$5 = (a5, n4) => {
|
|
|
17052
19154
|
}, s$6 = async ({ params: r7, method: s5, signer: d2, implementationType: i3, rpcProvider: o5, account: p5 }) => {
|
|
17053
19155
|
const c3 = r7[0], h2 = r7[1];
|
|
17054
19156
|
if (!c3 || !h2) throw new A$1(E$2.INVALID_PARAMS, `${s5} requires an address and a typed data JSON`);
|
|
17055
|
-
const { chainId: m2 } = await o5.detectNetwork(),
|
|
19157
|
+
const { chainId: m2 } = await o5.detectNetwork(), I2 = n$5(h2, m2), y3 = { ...I2.types };
|
|
17056
19158
|
delete y3.EIP712Domain;
|
|
17057
|
-
const { _TypedDataEncoder: A3 } = await __vitePreload(() => import("./index-
|
|
19159
|
+
const { _TypedDataEncoder: A3 } = await __vitePreload(() => import("./index-IIDV-e6n.js"), true ? __vite__mapDeps([4,5,6,7,1,2,3]) : void 0), w2 = A3.hash(I2.domain, y3, I2.message);
|
|
17058
19160
|
return await t$8({ hash: w2, implementationType: i3, chainId: m2, signer: d2, address: c3, ownerAddress: p5.ownerAddress, factoryAddress: p5.factoryAddress, salt: p5.salt });
|
|
17059
19161
|
};
|
|
17060
|
-
var C$
|
|
17061
|
-
!function(
|
|
17062
|
-
|
|
17063
|
-
}(C$
|
|
19162
|
+
var C$1;
|
|
19163
|
+
!function(C2) {
|
|
19164
|
+
C2.ACCOUNTS_CHANGED = "accountsChanged", C2.CHAIN_CHANGED = "chainChanged", C2.ACCOUNTS_CONNECT = "connect", C2.DISCONNECT = "disconnect";
|
|
19165
|
+
}(C$1 || (C$1 = {}));
|
|
17064
19166
|
let E$1 = (_f = class {
|
|
17065
19167
|
constructor({ storage: t6, backendApiClients: e4, openfortEventEmitter: a5, feeSponsorshipId: i3, ensureSigner: r7, chains: n4, validateAndRefreshSession: h2 }) {
|
|
17066
19168
|
__privateAdd(this, _E_instances);
|
|
@@ -17076,10 +19178,10 @@ let E$1 = (_f = class {
|
|
|
17076
19178
|
__privateAdd(this, _h);
|
|
17077
19179
|
__privateAdd(this, _d2, async () => (__privateGet(this, _a2) || __privateSet(this, _a2, await __privateGet(this, _h).call(this)), __privateGet(this, _a2)));
|
|
17078
19180
|
__privateAdd(this, _c2, async () => {
|
|
17079
|
-
__privateSet(this, _a2, void 0), __privateGet(this, _r).emit(C$
|
|
19181
|
+
__privateSet(this, _a2, void 0), __privateGet(this, _r).emit(C$1.DISCONNECT, { code: 4900, message: "Disconnected" }), __privateGet(this, _r).emit(C$1.ACCOUNTS_CHANGED, []);
|
|
17080
19182
|
});
|
|
17081
19183
|
__privateAdd(this, _p, async (t6) => {
|
|
17082
|
-
__privateGet(this, _r).emit(C$
|
|
19184
|
+
__privateGet(this, _r).emit(C$1.ACCOUNTS_CHANGED, [t6]);
|
|
17083
19185
|
});
|
|
17084
19186
|
__privateSet(this, _h, r7), __privateSet(this, _t, t6), __privateSet(this, _s, n4), __privateSet(this, _e2, i3), __privateSet(this, _i, h2), __privateSet(this, _n, e4), __privateSet(this, _r, new t$9()), a5.on(A$2.ON_LOGOUT, __privateGet(this, _c2)), a5.on(A$2.ON_SWITCH_ACCOUNT, __privateGet(this, _p));
|
|
17085
19187
|
}
|
|
@@ -17089,7 +19191,7 @@ let E$1 = (_f = class {
|
|
|
17089
19191
|
async getRpcProvider() {
|
|
17090
19192
|
if (!__privateGet(this, _o)) {
|
|
17091
19193
|
const e4 = await s$9.fromStorage(__privateGet(this, _t)), s5 = (e4 == null ? void 0 : e4.chainId) || (__privateGet(this, _s) ? Number(Object.keys(__privateGet(this, _s))[0]) : void 0) || 8453;
|
|
17092
|
-
await __vitePreload(() => import("./index-
|
|
19194
|
+
await __vitePreload(() => import("./index-B_E-HnzD.js"), true ? __vite__mapDeps([10,7,5,6,11,9,1,2,3]) : void 0).then((t6) => {
|
|
17093
19195
|
const e5 = __privateGet(this, _s) ? __privateGet(this, _s)[s5] : void 0;
|
|
17094
19196
|
__privateSet(this, _o, new t6.StaticJsonRpcProvider(e5 ?? t$a[s5]));
|
|
17095
19197
|
});
|
|
@@ -17123,7 +19225,7 @@ let E$1 = (_f = class {
|
|
|
17123
19225
|
const e4 = await s$9.fromStorage(__privateGet(this, _t));
|
|
17124
19226
|
if (e4) {
|
|
17125
19227
|
const t6 = await this.getRpcProvider(), { chainId: s6 } = await t6.detectNetwork();
|
|
17126
|
-
return __privateGet(this, _r).emit(C$
|
|
19228
|
+
return __privateGet(this, _r).emit(C$1.ACCOUNTS_CONNECT, { chainId: r$b(s6) }), [e4.address];
|
|
17127
19229
|
}
|
|
17128
19230
|
throw new A$1(R.UNAUTHORIZED, "Unauthorized - must be authenticated and configured with a signer.");
|
|
17129
19231
|
}
|
|
@@ -17133,7 +19235,7 @@ let E$1 = (_f = class {
|
|
|
17133
19235
|
const o5 = await this.getRpcProvider(), { chainId: n4 } = await o5.detectNetwork(), [h2] = s5.params || [];
|
|
17134
19236
|
h2.chainId || (h2.chainId = n4.toString());
|
|
17135
19237
|
const c3 = s$8(h2), { serialize: p5 } = await __vitePreload(async () => {
|
|
17136
|
-
const { serialize: p6 } = await import("./index-
|
|
19238
|
+
const { serialize: p6 } = await import("./index-Bz0M5Gj5.js").then((n5) => n5.i);
|
|
17137
19239
|
return { serialize: p6 };
|
|
17138
19240
|
}, true ? __vite__mapDeps([11,7,9]) : void 0), w2 = (t6) => ({ legacy: 0, eip2930: 1, eip1559: 2 })[t6], { gas: u4, ...l3 } = c3, g2 = { ...l3, gasLimit: u4, to: c3.to ?? void 0, type: w2(c3.type) }, f3 = p5(g2), { keccak256: S2 } = await __vitePreload(async () => {
|
|
17139
19241
|
const { keccak256: S3 } = await Promise.resolve().then(() => index);
|
|
@@ -17149,7 +19251,7 @@ let E$1 = (_f = class {
|
|
|
17149
19251
|
case "eth_sendTransaction": {
|
|
17150
19252
|
const [i3, r7, o5] = await Promise.all([s$9.fromStorage(__privateGet(this, _t)), __privateGet(this, _d2).call(this), r$g.fromStorage(__privateGet(this, _t))]);
|
|
17151
19253
|
if (!i3 || !o5) throw new A$1(R.UNAUTHORIZED, "Unauthorized - call eth_requestAccounts first");
|
|
17152
|
-
if (await __privateGet(this, _i).call(this), (i3 == null ? void 0 : i3.accountType) === N
|
|
19254
|
+
if (await __privateGet(this, _i).call(this), (i3 == null ? void 0 : i3.accountType) === N.EOA) {
|
|
17153
19255
|
const [t6] = s5.params || [], e4 = await this.getRpcProvider(), a5 = await a$7(t6, e4, i3.address), r8 = await __privateMethod(this, _E_instances, m_fn).call(this, { method: "eth_signTransaction", params: [a5] });
|
|
17154
19256
|
return __privateMethod(this, _E_instances, m_fn).call(this, { method: "eth_sendRawTransaction", params: [r8] });
|
|
17155
19257
|
}
|
|
@@ -17158,7 +19260,7 @@ let E$1 = (_f = class {
|
|
|
17158
19260
|
case "eth_sendRawTransactionSync": {
|
|
17159
19261
|
const [i3, r7, o5] = await Promise.all([s$9.fromStorage(__privateGet(this, _t)), __privateGet(this, _d2).call(this), r$g.fromStorage(__privateGet(this, _t))]);
|
|
17160
19262
|
if (!i3 || !o5) throw new A$1(R.UNAUTHORIZED, "Unauthorized - call eth_requestAccounts first");
|
|
17161
|
-
if ((i3 == null ? void 0 : i3.accountType) === N
|
|
19263
|
+
if ((i3 == null ? void 0 : i3.accountType) === N.EOA) throw new A$1(R.UNSUPPORTED_METHOD, `${s5.method}: Method not supported`);
|
|
17162
19264
|
return await __privateGet(this, _i).call(this), await d$5({ params: s5.params || [], signer: r7, account: i3, authentication: o5, backendClient: __privateGet(this, _n), rpcProvider: await this.getRpcProvider(), feeSponsorshipId: __privateGet(this, _e2) });
|
|
17163
19265
|
}
|
|
17164
19266
|
case "eth_estimateGas": {
|
|
@@ -17190,10 +19292,10 @@ let E$1 = (_f = class {
|
|
|
17190
19292
|
await __privateGet(this, _i).call(this);
|
|
17191
19293
|
try {
|
|
17192
19294
|
const e4 = parseInt(s5.params[0].chainId, 16);
|
|
17193
|
-
await t6.switchChain({ chainId: e4 }), await __vitePreload(() => import("./index-
|
|
19295
|
+
await t6.switchChain({ chainId: e4 }), await __vitePreload(() => import("./index-B_E-HnzD.js"), true ? __vite__mapDeps([10,7,5,6,11,9,1,2,3]) : void 0).then((t7) => {
|
|
17194
19296
|
const s6 = __privateGet(this, _s) ? __privateGet(this, _s)[e4] : void 0;
|
|
17195
19297
|
__privateSet(this, _o, new t7.StaticJsonRpcProvider(s6 ?? t$a[e4]));
|
|
17196
|
-
}), __privateGet(this, _r).emit(C$
|
|
19298
|
+
}), __privateGet(this, _r).emit(C$1.CHAIN_CHANGED, r$b(e4));
|
|
17197
19299
|
} catch (t7) {
|
|
17198
19300
|
const e4 = t7;
|
|
17199
19301
|
throw new A$1(E$2.INTERNAL_ERROR, `Failed to switch chain: ${e4.message}`);
|
|
@@ -17209,21 +19311,21 @@ let E$1 = (_f = class {
|
|
|
17209
19311
|
return null;
|
|
17210
19312
|
case "wallet_getCallsStatus": {
|
|
17211
19313
|
const i3 = await s$9.fromStorage(__privateGet(this, _t));
|
|
17212
|
-
if ((i3 == null ? void 0 : i3.accountType) === N
|
|
19314
|
+
if ((i3 == null ? void 0 : i3.accountType) === N.EOA) throw new A$1(R.UNSUPPORTED_METHOD, `${s5.method}: Method not supported`);
|
|
17213
19315
|
const r7 = await r$g.fromStorage(__privateGet(this, _t));
|
|
17214
19316
|
if (!i3 || !r7) throw new A$1(R.UNAUTHORIZED, "Unauthorized - call eth_requestAccounts first");
|
|
17215
19317
|
return await __privateGet(this, _i).call(this), await r$8({ params: s5.params || {}, authentication: r7, backendClient: __privateGet(this, _n) });
|
|
17216
19318
|
}
|
|
17217
19319
|
case "wallet_sendCalls": {
|
|
17218
19320
|
const [i3, r7, o5] = await Promise.all([s$9.fromStorage(__privateGet(this, _t)), __privateGet(this, _d2).call(this), r$g.fromStorage(__privateGet(this, _t))]);
|
|
17219
|
-
if ((i3 == null ? void 0 : i3.accountType) === N
|
|
19321
|
+
if ((i3 == null ? void 0 : i3.accountType) === N.EOA) throw new A$1(R.UNSUPPORTED_METHOD, `${s5.method}: Method not supported`);
|
|
17220
19322
|
if (!i3 || !o5) throw new A$1(R.UNAUTHORIZED, "Unauthorized - call eth_requestAccounts first");
|
|
17221
19323
|
await __privateGet(this, _i).call(this);
|
|
17222
19324
|
return await a$5({ params: s5.params ? s5.params[0].calls : [], signer: r7, account: i3, authentication: o5, backendClient: __privateGet(this, _n), rpcProvider: await this.getRpcProvider(), feeSponsorshipId: __privateGet(this, _e2) });
|
|
17223
19325
|
}
|
|
17224
19326
|
case "wallet_grantPermissions": {
|
|
17225
19327
|
const i3 = await s$9.fromStorage(__privateGet(this, _t));
|
|
17226
|
-
if ((i3 == null ? void 0 : i3.accountType) === N
|
|
19328
|
+
if ((i3 == null ? void 0 : i3.accountType) === N.EOA) throw new A$1(R.UNSUPPORTED_METHOD, `${s5.method}: Method not supported`);
|
|
17227
19329
|
const r7 = await __privateGet(this, _d2).call(this), o5 = await r$g.fromStorage(__privateGet(this, _t));
|
|
17228
19330
|
if (!i3 || !o5) throw new A$1(R.UNAUTHORIZED, "Unauthorized - call eth_requestAccounts first");
|
|
17229
19331
|
return await __privateGet(this, _i).call(this), await r$7({ params: s5.params || [], signer: r7, account: i3, authentication: o5, backendClient: __privateGet(this, _n), feeSponsorshipId: __privateGet(this, _e2) });
|
|
@@ -17235,7 +19337,7 @@ let E$1 = (_f = class {
|
|
|
17235
19337
|
}
|
|
17236
19338
|
case "wallet_getCapabilities": {
|
|
17237
19339
|
const e4 = await s$9.fromStorage(__privateGet(this, _t));
|
|
17238
|
-
if ((e4 == null ? void 0 : e4.accountType) === N
|
|
19340
|
+
if ((e4 == null ? void 0 : e4.accountType) === N.EOA) throw new A$1(R.UNSUPPORTED_METHOD, `${s5.method}: Method not supported`);
|
|
17239
19341
|
const i3 = await this.getRpcProvider(), { chainId: o5 } = await i3.detectNetwork();
|
|
17240
19342
|
return { [r$b(o5)]: { permissions: { supported: true, signerTypes: ["account", "key"], keyTypes: ["secp256k1"], permissionTypes: ["contract-calls"] }, paymasterService: { supported: true }, atomicBatch: { supported: true } } };
|
|
17241
19343
|
}
|
|
@@ -17540,17 +19642,17 @@ const e$2 = () => {
|
|
|
17540
19642
|
const p4 = ({ messenger: p5, methods: h2, timeout: l3, channel: f3, log: S2 }) => {
|
|
17541
19643
|
const g2 = t$f();
|
|
17542
19644
|
let u4;
|
|
17543
|
-
const
|
|
19645
|
+
const I2 = [];
|
|
17544
19646
|
let y3 = false;
|
|
17545
|
-
const A3 = s$3(h2), { promise: N2, resolve:
|
|
19647
|
+
const A3 = s$3(h2), { promise: N2, resolve: C2, reject: j } = e$2(), M2 = setTimeout(() => {
|
|
17546
19648
|
j(new r$4("CONNECTION_TIMEOUT", `Connection timed out after ${l3}ms`));
|
|
17547
19649
|
}, l3), R2 = () => {
|
|
17548
|
-
for (const e4 of
|
|
19650
|
+
for (const e4 of I2) e4();
|
|
17549
19651
|
}, T3 = () => {
|
|
17550
19652
|
if (y3) return;
|
|
17551
|
-
|
|
19653
|
+
I2.push(l$2(p5, h2, f3, S2));
|
|
17552
19654
|
const { remoteProxy: e4, destroy: t6 } = d$3(p5, f3, S2);
|
|
17553
|
-
|
|
19655
|
+
I2.push(t6), clearTimeout(M2), y3 = true, C2({ remoteProxy: e4, destroy: R2 });
|
|
17554
19656
|
}, k2 = () => {
|
|
17555
19657
|
const e4 = { namespace: a$4, type: "SYN", channel: f3, participantId: g2 };
|
|
17556
19658
|
S2 == null ? void 0 : S2("Sending handshake SYN", e4);
|
|
@@ -17584,7 +19686,7 @@ const p4 = ({ messenger: p5, methods: h2, timeout: l3, channel: f3, log: S2 }) =
|
|
|
17584
19686
|
S2 == null ? void 0 : S2("Received handshake ACK2", e5), T3();
|
|
17585
19687
|
})(e4);
|
|
17586
19688
|
};
|
|
17587
|
-
return p5.addMessageHandler(v2),
|
|
19689
|
+
return p5.addMessageHandler(v2), I2.push(() => p5.removeMessageHandler(v2)), k2(), N2;
|
|
17588
19690
|
};
|
|
17589
19691
|
const a$1 = /* @__PURE__ */ new WeakSet(), m = ({ messenger: m2, methods: c3 = {}, timeout: i3, channel: d2, log: h2 }) => {
|
|
17590
19692
|
if (!m2) throw new r$4("INVALID_ARGUMENT", "messenger must be defined");
|
|
@@ -17673,7 +19775,7 @@ class T2 {
|
|
|
17673
19775
|
function d$2(r7) {
|
|
17674
19776
|
return "error" in r7;
|
|
17675
19777
|
}
|
|
17676
|
-
|
|
19778
|
+
class C {
|
|
17677
19779
|
constructor(r7, e4, i3) {
|
|
17678
19780
|
__publicField(this, "uuid");
|
|
17679
19781
|
__publicField(this, "action", r$3.UPDATE_AUTHENTICATION);
|
|
@@ -17681,7 +19783,7 @@ let C$1 = class C {
|
|
|
17681
19783
|
__publicField(this, "recovery");
|
|
17682
19784
|
this.uuid = r7, this.accessToken = e4, this.recovery = i3;
|
|
17683
19785
|
}
|
|
17684
|
-
}
|
|
19786
|
+
}
|
|
17685
19787
|
var y$1;
|
|
17686
19788
|
!function(r7) {
|
|
17687
19789
|
r7.OPENFORT = "openfort";
|
|
@@ -17711,11 +19813,11 @@ class D extends s$b {
|
|
|
17711
19813
|
super(E$4.NOT_CONFIGURED, "Signer is not configured");
|
|
17712
19814
|
}
|
|
17713
19815
|
}
|
|
17714
|
-
|
|
19816
|
+
class M extends t$i {
|
|
17715
19817
|
constructor() {
|
|
17716
19818
|
super(E$4.OTP_REQUIRED, "OTP verification required");
|
|
17717
19819
|
}
|
|
17718
|
-
}
|
|
19820
|
+
}
|
|
17719
19821
|
class K {
|
|
17720
19822
|
constructor(e4, i3, t6) {
|
|
17721
19823
|
__publicField(this, "messenger");
|
|
@@ -17776,7 +19878,7 @@ class K {
|
|
|
17776
19878
|
if (e4.error === s$1) throw new z();
|
|
17777
19879
|
if (e4.error === n3) throw this.storage.remove(o$e.ACCOUNT), new A2();
|
|
17778
19880
|
if (e4.error === o$2) throw new O2();
|
|
17779
|
-
if (e4.error === c2) throw new M
|
|
19881
|
+
if (e4.error === c2) throw new M();
|
|
17780
19882
|
throw this.storage.remove(o$e.ACCOUNT), new t$i(E$4.INTERNAL_ERROR, `Unknown error: ${e4.error}`);
|
|
17781
19883
|
}
|
|
17782
19884
|
throw e4;
|
|
@@ -17843,7 +19945,7 @@ class K {
|
|
|
17843
19945
|
if (!this.isLoaded() || !this.remote) return void t$c("IframeManager not loaded, skipping authentication update");
|
|
17844
19946
|
const e4 = await r$g.fromStorage(this.storage);
|
|
17845
19947
|
if (!e4) return void t$c("No authentication found, skipping update");
|
|
17846
|
-
const t6 = new C
|
|
19948
|
+
const t6 = new C(t$f(), e4.token);
|
|
17847
19949
|
t$c("Updating authentication in iframe with token");
|
|
17848
19950
|
const n4 = await this.remote.updateAuthentication(t6);
|
|
17849
19951
|
d$2(n4) && this.handleError(n4);
|
|
@@ -18023,7 +20125,7 @@ class k {
|
|
|
18023
20125
|
}
|
|
18024
20126
|
async configure(e4) {
|
|
18025
20127
|
await this.validateAndRefreshToken();
|
|
18026
|
-
const r7 = e4.recoveryParams ?? { recoveryMethod: e$9.AUTOMATIC }, [t6, s5] = await Promise.all([this.ensureSigner(), this.getEntropy(r7)]), a5 = { chainId: e4.chainId, entropy: s5, accountType: e4.accountType ?? N
|
|
20128
|
+
const r7 = e4.recoveryParams ?? { recoveryMethod: e$9.AUTOMATIC }, [t6, s5] = await Promise.all([this.ensureSigner(), this.getEntropy(r7)]), a5 = { chainId: e4.chainId, entropy: s5, accountType: e4.accountType ?? N.SMART_ACCOUNT, chainType: e4.chainType ?? c$6.EVM, getPasskeyKeyFn: async (e5) => this.getPasskeyKey(e5) }, i3 = await t6.configure(a5);
|
|
18027
20129
|
return { id: i3.id, chainId: i3.chainId, address: i3.address, ownerAddress: i3.ownerAddress, chainType: i3.chainType, accountType: i3.accountType, implementationType: i3.implementationType, factoryAddress: i3.factoryAddress, salt: i3.salt, createdAt: i3.createdAt, implementationAddress: i3.implementationAddress, recoveryMethod: s$9.parseRecoveryMethod(i3.recoveryMethod), recoveryMethodDetails: i3.recoveryMethodDetails };
|
|
18028
20130
|
}
|
|
18029
20131
|
async create(e4) {
|
|
@@ -18061,7 +20163,7 @@ class k {
|
|
|
18061
20163
|
if (!i3) throw new s$b(E$4.MISSING_SIGNER, "No account found");
|
|
18062
20164
|
const n4 = { ...r7 };
|
|
18063
20165
|
delete n4.EIP712Domain;
|
|
18064
|
-
const { _TypedDataEncoder: d2 } = await __vitePreload(() => import("./index-
|
|
20166
|
+
const { _TypedDataEncoder: d2 } = await __vitePreload(() => import("./index-IIDV-e6n.js"), true ? __vite__mapDeps([4,5,6,7,1,2,3]) : void 0), h2 = d2.hash(e4, n4, t6);
|
|
18065
20167
|
return await t$8({ hash: h2, implementationType: i3.implementationType || i3.type, chainId: Number(i3.chainId), signer: s5, address: i3.address, ownerAddress: i3.ownerAddress, factoryAddress: i3.factoryAddress, salt: i3.salt });
|
|
18066
20168
|
}
|
|
18067
20169
|
async exportPrivateKey() {
|
|
@@ -18332,7 +20434,7 @@ class d {
|
|
|
18332
20434
|
async signupEmailPassword(e4, t6, i3, a5, o5) {
|
|
18333
20435
|
return c$5(async () => {
|
|
18334
20436
|
const s5 = (await this.backendApiClients.authApi.signUpEmailPost({ signUpEmailPostRequest: { email: e4, password: t6, name: i3, callbackURL: a5 } }, { headers: this.buildAuthHeaders(o5) })).data;
|
|
18335
|
-
return null === s5.token ? { action: C$
|
|
20437
|
+
return null === s5.token ? { action: C$2.ACTION_VERIFY_EMAIL } : { token: s5.token, user: r$1(s5.user) };
|
|
18336
20438
|
}, { context: "signupEmailPassword" });
|
|
18337
20439
|
}
|
|
18338
20440
|
async validateCredentials(t6, i3) {
|
|
@@ -18838,7 +20940,7 @@ function createOpenfortProvider(settings) {
|
|
|
18838
20940
|
} else {
|
|
18839
20941
|
const account = await openfortInstance.embeddedWallet.create({
|
|
18840
20942
|
chainType,
|
|
18841
|
-
accountType: N
|
|
20943
|
+
accountType: N.EOA,
|
|
18842
20944
|
recoveryParams: {
|
|
18843
20945
|
recoveryMethod: e$9.AUTOMATIC,
|
|
18844
20946
|
encryptionSession
|
|
@@ -19204,7 +21306,7 @@ const [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => u64.split([
|
|
|
19204
21306
|
].map((n4) => BigInt(n4))))();
|
|
19205
21307
|
const SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
19206
21308
|
const SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
19207
|
-
class
|
|
21309
|
+
class SHA5122 extends HashMD2 {
|
|
19208
21310
|
constructor() {
|
|
19209
21311
|
super(128, 64, 16, false);
|
|
19210
21312
|
this.Ah = 1779033703 | 0;
|
|
@@ -19316,7 +21418,7 @@ class SHA512 extends HashMD2 {
|
|
|
19316
21418
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
19317
21419
|
}
|
|
19318
21420
|
}
|
|
19319
|
-
const sha512 = /* @__PURE__ */ wrapConstructor(() => new
|
|
21421
|
+
const sha512 = /* @__PURE__ */ wrapConstructor(() => new SHA5122());
|
|
19320
21422
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
19321
21423
|
function isBytes(a5) {
|
|
19322
21424
|
return a5 instanceof Uint8Array || ArrayBuffer.isView(a5) && a5.constructor.name === "Uint8Array";
|
|
@@ -19501,7 +21603,7 @@ const genBase58 = /* @__NO_SIDE_EFFECTS__ */ (abc) => /* @__PURE__ */ chain(/* @
|
|
|
19501
21603
|
const base58 = /* @__PURE__ */ genBase58("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
19502
21604
|
const createBase58check = (sha2562) => /* @__PURE__ */ chain(checksum(4, (data) => sha2562(sha2562(data))), base58);
|
|
19503
21605
|
/*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */
|
|
19504
|
-
const
|
|
21606
|
+
const Point2 = secp256k1.ProjectivePoint;
|
|
19505
21607
|
const base58check = createBase58check(sha256);
|
|
19506
21608
|
function bytesToNumber(bytes) {
|
|
19507
21609
|
abytes$1(bytes);
|
|
@@ -19563,11 +21665,11 @@ class HDKey {
|
|
|
19563
21665
|
if (8 * seed.length < 128 || 8 * seed.length > 512) {
|
|
19564
21666
|
throw new Error("HDKey: seed length must be between 128 and 512 bits; 256 bits is advised, got " + seed.length);
|
|
19565
21667
|
}
|
|
19566
|
-
const
|
|
21668
|
+
const I2 = hmac(sha512, MASTER_SECRET, seed);
|
|
19567
21669
|
return new HDKey({
|
|
19568
21670
|
versions,
|
|
19569
|
-
chainCode:
|
|
19570
|
-
privateKey:
|
|
21671
|
+
chainCode: I2.slice(32),
|
|
21672
|
+
privateKey: I2.slice(0, 32)
|
|
19571
21673
|
});
|
|
19572
21674
|
}
|
|
19573
21675
|
static fromExtendedKey(base58key, versions = BITCOIN_VERSIONS) {
|
|
@@ -19624,7 +21726,7 @@ class HDKey {
|
|
|
19624
21726
|
this.privKeyBytes = numberToBytes(this.privKey);
|
|
19625
21727
|
this.pubKey = secp256k1.getPublicKey(opt.privateKey, true);
|
|
19626
21728
|
} else if (opt.publicKey) {
|
|
19627
|
-
this.pubKey =
|
|
21729
|
+
this.pubKey = Point2.fromHex(opt.publicKey).toRawBytes(true);
|
|
19628
21730
|
} else {
|
|
19629
21731
|
throw new Error("HDKey: no public or private key provided");
|
|
19630
21732
|
}
|
|
@@ -19669,9 +21771,9 @@ class HDKey {
|
|
|
19669
21771
|
} else {
|
|
19670
21772
|
data = concatBytes$1(this.pubKey, data);
|
|
19671
21773
|
}
|
|
19672
|
-
const
|
|
19673
|
-
const childTweak = bytesToNumber(
|
|
19674
|
-
const chainCode =
|
|
21774
|
+
const I2 = hmac(sha512, this.chainCode, data);
|
|
21775
|
+
const childTweak = bytesToNumber(I2.slice(0, 32));
|
|
21776
|
+
const chainCode = I2.slice(32);
|
|
19675
21777
|
if (!secp256k1.utils.isValidPrivateKey(childTweak)) {
|
|
19676
21778
|
throw new Error("Tweak bigger than curve order");
|
|
19677
21779
|
}
|
|
@@ -19690,8 +21792,8 @@ class HDKey {
|
|
|
19690
21792
|
}
|
|
19691
21793
|
opt.privateKey = added;
|
|
19692
21794
|
} else {
|
|
19693
|
-
const added =
|
|
19694
|
-
if (added.equals(
|
|
21795
|
+
const added = Point2.fromHex(this.pubKey).add(Point2.fromPrivateKey(childTweak));
|
|
21796
|
+
if (added.equals(Point2.ZERO)) {
|
|
19695
21797
|
throw new Error("The tweak was equal to negative P, which made the result key invalid");
|
|
19696
21798
|
}
|
|
19697
21799
|
opt.publicKey = added.toRawBytes(true);
|
|
@@ -19978,320 +22080,6 @@ class Keccak2 extends Hash2 {
|
|
|
19978
22080
|
}
|
|
19979
22081
|
const gen = (suffix, blockLen, outputLen) => wrapConstructor(() => new Keccak2(blockLen, suffix, outputLen));
|
|
19980
22082
|
const keccak_256 = /* @__PURE__ */ gen(1, 136, 256 / 8);
|
|
19981
|
-
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
|
19982
|
-
const B256 = 2n ** 256n;
|
|
19983
|
-
const P2 = B256 - 0x1000003d1n;
|
|
19984
|
-
const N = B256 - 0x14551231950b75fc4402da1732fc9bebfn;
|
|
19985
|
-
const Gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n;
|
|
19986
|
-
const Gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;
|
|
19987
|
-
const CURVE = {
|
|
19988
|
-
a: 0n,
|
|
19989
|
-
b: 7n
|
|
19990
|
-
};
|
|
19991
|
-
const fLen = 32;
|
|
19992
|
-
const curve = (x2) => M2(M2(x2 * x2) * x2 + CURVE.b);
|
|
19993
|
-
const err = (m2 = "") => {
|
|
19994
|
-
throw new Error(m2);
|
|
19995
|
-
};
|
|
19996
|
-
const isB = (n4) => typeof n4 === "bigint";
|
|
19997
|
-
const isS = (s5) => typeof s5 === "string";
|
|
19998
|
-
const fe = (n4) => isB(n4) && 0n < n4 && n4 < P2;
|
|
19999
|
-
const ge = (n4) => isB(n4) && 0n < n4 && n4 < N;
|
|
20000
|
-
const isu8 = (a5) => a5 instanceof Uint8Array || ArrayBuffer.isView(a5) && a5.constructor.name === "Uint8Array";
|
|
20001
|
-
const au8 = (a5, l3) => (
|
|
20002
|
-
// assert is Uint8Array (of specific length)
|
|
20003
|
-
!isu8(a5) || typeof l3 === "number" && l3 > 0 && a5.length !== l3 ? err("Uint8Array expected") : a5
|
|
20004
|
-
);
|
|
20005
|
-
const u8n = (data) => new Uint8Array(data);
|
|
20006
|
-
const toU8 = (a5, len) => au8(isS(a5) ? h2b(a5) : u8n(au8(a5)), len);
|
|
20007
|
-
const M2 = (a5, b2 = P2) => {
|
|
20008
|
-
const r7 = a5 % b2;
|
|
20009
|
-
return r7 >= 0n ? r7 : b2 + r7;
|
|
20010
|
-
};
|
|
20011
|
-
const aPoint = (p5) => p5 instanceof Point ? p5 : err("Point expected");
|
|
20012
|
-
class Point {
|
|
20013
|
-
constructor(px, py, pz) {
|
|
20014
|
-
this.px = px;
|
|
20015
|
-
this.py = py;
|
|
20016
|
-
this.pz = pz;
|
|
20017
|
-
Object.freeze(this);
|
|
20018
|
-
}
|
|
20019
|
-
/** Create 3d xyz point from 2d xy. (0, 0) => (0, 1, 0), not (0, 0, 1) */
|
|
20020
|
-
static fromAffine(p5) {
|
|
20021
|
-
return p5.x === 0n && p5.y === 0n ? I2 : new Point(p5.x, p5.y, 1n);
|
|
20022
|
-
}
|
|
20023
|
-
/** Convert Uint8Array or hex string to Point. */
|
|
20024
|
-
static fromHex(hex) {
|
|
20025
|
-
hex = toU8(hex);
|
|
20026
|
-
let p5 = void 0;
|
|
20027
|
-
const head = hex[0], tail = hex.subarray(1);
|
|
20028
|
-
const x2 = slc(tail, 0, fLen), len = hex.length;
|
|
20029
|
-
if (len === 33 && [2, 3].includes(head)) {
|
|
20030
|
-
if (!fe(x2))
|
|
20031
|
-
err("Point hex invalid: x not FE");
|
|
20032
|
-
let y3 = sqrt(curve(x2));
|
|
20033
|
-
const isYOdd = (y3 & 1n) === 1n;
|
|
20034
|
-
const headOdd = (head & 1) === 1;
|
|
20035
|
-
if (headOdd !== isYOdd)
|
|
20036
|
-
y3 = M2(-y3);
|
|
20037
|
-
p5 = new Point(x2, y3, 1n);
|
|
20038
|
-
}
|
|
20039
|
-
if (len === 65 && head === 4)
|
|
20040
|
-
p5 = new Point(x2, slc(tail, fLen, 2 * fLen), 1n);
|
|
20041
|
-
return p5 ? p5.ok() : err("Point invalid: not on curve");
|
|
20042
|
-
}
|
|
20043
|
-
/** Create point from a private key. */
|
|
20044
|
-
static fromPrivateKey(k2) {
|
|
20045
|
-
return G.mul(toPriv(k2));
|
|
20046
|
-
}
|
|
20047
|
-
get x() {
|
|
20048
|
-
return this.aff().x;
|
|
20049
|
-
}
|
|
20050
|
-
// .x, .y will call expensive toAffine:
|
|
20051
|
-
get y() {
|
|
20052
|
-
return this.aff().y;
|
|
20053
|
-
}
|
|
20054
|
-
// should be used with care.
|
|
20055
|
-
/** Equality check: compare points P&Q. */
|
|
20056
|
-
equals(other) {
|
|
20057
|
-
const { px: X1, py: Y1, pz: Z1 } = this;
|
|
20058
|
-
const { px: X2, py: Y2, pz: Z2 } = aPoint(other);
|
|
20059
|
-
const X1Z2 = M2(X1 * Z2), X2Z1 = M2(X2 * Z1);
|
|
20060
|
-
const Y1Z2 = M2(Y1 * Z2), Y2Z1 = M2(Y2 * Z1);
|
|
20061
|
-
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
20062
|
-
}
|
|
20063
|
-
/** Flip point over y coordinate. */
|
|
20064
|
-
negate() {
|
|
20065
|
-
return new Point(this.px, M2(-this.py), this.pz);
|
|
20066
|
-
}
|
|
20067
|
-
/** Point doubling: P+P, complete formula. */
|
|
20068
|
-
double() {
|
|
20069
|
-
return this.add(this);
|
|
20070
|
-
}
|
|
20071
|
-
/**
|
|
20072
|
-
* Point addition: P+Q, complete, exception-free formula
|
|
20073
|
-
* (Renes-Costello-Batina, algo 1 of [2015/1060](https://eprint.iacr.org/2015/1060)).
|
|
20074
|
-
* Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
20075
|
-
*/
|
|
20076
|
-
add(other) {
|
|
20077
|
-
const { px: X1, py: Y1, pz: Z1 } = this;
|
|
20078
|
-
const { px: X2, py: Y2, pz: Z2 } = aPoint(other);
|
|
20079
|
-
const { a: a5, b: b2 } = CURVE;
|
|
20080
|
-
let X3 = 0n, Y3 = 0n, Z3 = 0n;
|
|
20081
|
-
const b3 = M2(b2 * 3n);
|
|
20082
|
-
let t0 = M2(X1 * X2), t1 = M2(Y1 * Y2), t22 = M2(Z1 * Z2), t32 = M2(X1 + Y1);
|
|
20083
|
-
let t42 = M2(X2 + Y2);
|
|
20084
|
-
t32 = M2(t32 * t42);
|
|
20085
|
-
t42 = M2(t0 + t1);
|
|
20086
|
-
t32 = M2(t32 - t42);
|
|
20087
|
-
t42 = M2(X1 + Z1);
|
|
20088
|
-
let t52 = M2(X2 + Z2);
|
|
20089
|
-
t42 = M2(t42 * t52);
|
|
20090
|
-
t52 = M2(t0 + t22);
|
|
20091
|
-
t42 = M2(t42 - t52);
|
|
20092
|
-
t52 = M2(Y1 + Z1);
|
|
20093
|
-
X3 = M2(Y2 + Z2);
|
|
20094
|
-
t52 = M2(t52 * X3);
|
|
20095
|
-
X3 = M2(t1 + t22);
|
|
20096
|
-
t52 = M2(t52 - X3);
|
|
20097
|
-
Z3 = M2(a5 * t42);
|
|
20098
|
-
X3 = M2(b3 * t22);
|
|
20099
|
-
Z3 = M2(X3 + Z3);
|
|
20100
|
-
X3 = M2(t1 - Z3);
|
|
20101
|
-
Z3 = M2(t1 + Z3);
|
|
20102
|
-
Y3 = M2(X3 * Z3);
|
|
20103
|
-
t1 = M2(t0 + t0);
|
|
20104
|
-
t1 = M2(t1 + t0);
|
|
20105
|
-
t22 = M2(a5 * t22);
|
|
20106
|
-
t42 = M2(b3 * t42);
|
|
20107
|
-
t1 = M2(t1 + t22);
|
|
20108
|
-
t22 = M2(t0 - t22);
|
|
20109
|
-
t22 = M2(a5 * t22);
|
|
20110
|
-
t42 = M2(t42 + t22);
|
|
20111
|
-
t0 = M2(t1 * t42);
|
|
20112
|
-
Y3 = M2(Y3 + t0);
|
|
20113
|
-
t0 = M2(t52 * t42);
|
|
20114
|
-
X3 = M2(t32 * X3);
|
|
20115
|
-
X3 = M2(X3 - t0);
|
|
20116
|
-
t0 = M2(t32 * t1);
|
|
20117
|
-
Z3 = M2(t52 * Z3);
|
|
20118
|
-
Z3 = M2(Z3 + t0);
|
|
20119
|
-
return new Point(X3, Y3, Z3);
|
|
20120
|
-
}
|
|
20121
|
-
mul(n4, safe = true) {
|
|
20122
|
-
if (!safe && n4 === 0n)
|
|
20123
|
-
return I2;
|
|
20124
|
-
if (!ge(n4))
|
|
20125
|
-
err("scalar invalid");
|
|
20126
|
-
if (this.equals(G))
|
|
20127
|
-
return wNAF(n4).p;
|
|
20128
|
-
let p5 = I2, f3 = G;
|
|
20129
|
-
for (let d2 = this; n4 > 0n; d2 = d2.double(), n4 >>= 1n) {
|
|
20130
|
-
if (n4 & 1n)
|
|
20131
|
-
p5 = p5.add(d2);
|
|
20132
|
-
else if (safe)
|
|
20133
|
-
f3 = f3.add(d2);
|
|
20134
|
-
}
|
|
20135
|
-
return p5;
|
|
20136
|
-
}
|
|
20137
|
-
mulAddQUns(R2, u1, u22) {
|
|
20138
|
-
return this.mul(u1, false).add(R2.mul(u22, false)).ok();
|
|
20139
|
-
}
|
|
20140
|
-
// to private keys. Doesn't use Shamir trick
|
|
20141
|
-
/** Convert point to 2d xy affine point. (x, y, z) ∋ (x=x/z, y=y/z) */
|
|
20142
|
-
toAffine() {
|
|
20143
|
-
const { px: x2, py: y3, pz: z2 } = this;
|
|
20144
|
-
if (this.equals(I2))
|
|
20145
|
-
return { x: 0n, y: 0n };
|
|
20146
|
-
if (z2 === 1n)
|
|
20147
|
-
return { x: x2, y: y3 };
|
|
20148
|
-
const iz = inv(z2, P2);
|
|
20149
|
-
if (M2(z2 * iz) !== 1n)
|
|
20150
|
-
err("inverse invalid");
|
|
20151
|
-
return { x: M2(x2 * iz), y: M2(y3 * iz) };
|
|
20152
|
-
}
|
|
20153
|
-
/** Checks if the point is valid and on-curve. */
|
|
20154
|
-
assertValidity() {
|
|
20155
|
-
const { x: x2, y: y3 } = this.aff();
|
|
20156
|
-
if (!fe(x2) || !fe(y3))
|
|
20157
|
-
err("Point invalid: x or y");
|
|
20158
|
-
return M2(y3 * y3) === curve(x2) ? (
|
|
20159
|
-
// y² = x³ + ax + b, must be equal
|
|
20160
|
-
this
|
|
20161
|
-
) : err("Point invalid: not on curve");
|
|
20162
|
-
}
|
|
20163
|
-
multiply(n4) {
|
|
20164
|
-
return this.mul(n4);
|
|
20165
|
-
}
|
|
20166
|
-
// Aliases to compress code
|
|
20167
|
-
aff() {
|
|
20168
|
-
return this.toAffine();
|
|
20169
|
-
}
|
|
20170
|
-
ok() {
|
|
20171
|
-
return this.assertValidity();
|
|
20172
|
-
}
|
|
20173
|
-
toHex(isCompressed = true) {
|
|
20174
|
-
const { x: x2, y: y3 } = this.aff();
|
|
20175
|
-
const head = isCompressed ? (y3 & 1n) === 0n ? "02" : "03" : "04";
|
|
20176
|
-
return head + n2h(x2) + (isCompressed ? "" : n2h(y3));
|
|
20177
|
-
}
|
|
20178
|
-
toRawBytes(isCompressed = true) {
|
|
20179
|
-
return h2b(this.toHex(isCompressed));
|
|
20180
|
-
}
|
|
20181
|
-
}
|
|
20182
|
-
Point.BASE = new Point(Gx, Gy, 1n);
|
|
20183
|
-
Point.ZERO = new Point(0n, 1n, 0n);
|
|
20184
|
-
const { BASE: G, ZERO: I2 } = Point;
|
|
20185
|
-
const padh = (n4, pad) => n4.toString(16).padStart(pad, "0");
|
|
20186
|
-
const b2h = (b2) => Array.from(au8(b2)).map((e4) => padh(e4, 2)).join("");
|
|
20187
|
-
const C2 = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
20188
|
-
const _ch = (ch) => {
|
|
20189
|
-
if (ch >= C2._0 && ch <= C2._9)
|
|
20190
|
-
return ch - C2._0;
|
|
20191
|
-
if (ch >= C2.A && ch <= C2.F)
|
|
20192
|
-
return ch - (C2.A - 10);
|
|
20193
|
-
if (ch >= C2.a && ch <= C2.f)
|
|
20194
|
-
return ch - (C2.a - 10);
|
|
20195
|
-
return;
|
|
20196
|
-
};
|
|
20197
|
-
const h2b = (hex) => {
|
|
20198
|
-
const e4 = "hex invalid";
|
|
20199
|
-
if (!isS(hex))
|
|
20200
|
-
return err(e4);
|
|
20201
|
-
const hl = hex.length, al = hl / 2;
|
|
20202
|
-
if (hl % 2)
|
|
20203
|
-
return err(e4);
|
|
20204
|
-
const array = u8n(al);
|
|
20205
|
-
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
20206
|
-
const n1 = _ch(hex.charCodeAt(hi));
|
|
20207
|
-
const n22 = _ch(hex.charCodeAt(hi + 1));
|
|
20208
|
-
if (n1 === void 0 || n22 === void 0)
|
|
20209
|
-
return err(e4);
|
|
20210
|
-
array[ai] = n1 * 16 + n22;
|
|
20211
|
-
}
|
|
20212
|
-
return array;
|
|
20213
|
-
};
|
|
20214
|
-
const b2n = (b2) => BigInt("0x" + (b2h(b2) || "0"));
|
|
20215
|
-
const slc = (b2, from, to) => b2n(b2.slice(from, to));
|
|
20216
|
-
const n2b = (num) => {
|
|
20217
|
-
return isB(num) && num >= 0n && num < B256 ? h2b(padh(num, 2 * fLen)) : err("bigint expected");
|
|
20218
|
-
};
|
|
20219
|
-
const n2h = (num) => b2h(n2b(num));
|
|
20220
|
-
const inv = (num, md) => {
|
|
20221
|
-
if (num === 0n || md <= 0n)
|
|
20222
|
-
err("no inverse n=" + num + " mod=" + md);
|
|
20223
|
-
let a5 = M2(num, md), b2 = md, x2 = 0n, u4 = 1n;
|
|
20224
|
-
while (a5 !== 0n) {
|
|
20225
|
-
const q2 = b2 / a5, r7 = b2 % a5;
|
|
20226
|
-
const m2 = x2 - u4 * q2;
|
|
20227
|
-
b2 = a5, a5 = r7, x2 = u4, u4 = m2;
|
|
20228
|
-
}
|
|
20229
|
-
return b2 === 1n ? M2(x2, md) : err("no inverse");
|
|
20230
|
-
};
|
|
20231
|
-
const sqrt = (n4) => {
|
|
20232
|
-
let r7 = 1n;
|
|
20233
|
-
for (let num = n4, e4 = (P2 + 1n) / 4n; e4 > 0n; e4 >>= 1n) {
|
|
20234
|
-
if (e4 & 1n)
|
|
20235
|
-
r7 = r7 * num % P2;
|
|
20236
|
-
num = num * num % P2;
|
|
20237
|
-
}
|
|
20238
|
-
return M2(r7 * r7) === n4 ? r7 : err("sqrt invalid");
|
|
20239
|
-
};
|
|
20240
|
-
const toPriv = (p5) => {
|
|
20241
|
-
if (!isB(p5))
|
|
20242
|
-
p5 = b2n(toU8(p5, fLen));
|
|
20243
|
-
return ge(p5) ? p5 : err("private key invalid 3");
|
|
20244
|
-
};
|
|
20245
|
-
const getPublicKey = (privKey, isCompressed = true) => {
|
|
20246
|
-
return Point.fromPrivateKey(privKey).toRawBytes(isCompressed);
|
|
20247
|
-
};
|
|
20248
|
-
const W = 8;
|
|
20249
|
-
const precompute = () => {
|
|
20250
|
-
const points = [];
|
|
20251
|
-
const windows = 256 / W + 1;
|
|
20252
|
-
let p5 = G, b2 = p5;
|
|
20253
|
-
for (let w2 = 0; w2 < windows; w2++) {
|
|
20254
|
-
b2 = p5;
|
|
20255
|
-
points.push(b2);
|
|
20256
|
-
for (let i3 = 1; i3 < 2 ** (W - 1); i3++) {
|
|
20257
|
-
b2 = b2.add(p5);
|
|
20258
|
-
points.push(b2);
|
|
20259
|
-
}
|
|
20260
|
-
p5 = b2.double();
|
|
20261
|
-
}
|
|
20262
|
-
return points;
|
|
20263
|
-
};
|
|
20264
|
-
let Gpows = void 0;
|
|
20265
|
-
const wNAF = (n4) => {
|
|
20266
|
-
const comp = Gpows || (Gpows = precompute());
|
|
20267
|
-
const neg = (cnd, p6) => {
|
|
20268
|
-
let n5 = p6.negate();
|
|
20269
|
-
return cnd ? n5 : p6;
|
|
20270
|
-
};
|
|
20271
|
-
let p5 = I2, f3 = G;
|
|
20272
|
-
const windows = 1 + 256 / W;
|
|
20273
|
-
const wsize = 2 ** (W - 1);
|
|
20274
|
-
const mask = BigInt(2 ** W - 1);
|
|
20275
|
-
const maxNum = 2 ** W;
|
|
20276
|
-
const shiftBy = BigInt(W);
|
|
20277
|
-
for (let w2 = 0; w2 < windows; w2++) {
|
|
20278
|
-
const off = w2 * wsize;
|
|
20279
|
-
let wbits = Number(n4 & mask);
|
|
20280
|
-
n4 >>= shiftBy;
|
|
20281
|
-
if (wbits > wsize) {
|
|
20282
|
-
wbits -= maxNum;
|
|
20283
|
-
n4 += 1n;
|
|
20284
|
-
}
|
|
20285
|
-
const off1 = off, off2 = off + Math.abs(wbits) - 1;
|
|
20286
|
-
const cnd1 = w2 % 2 !== 0, cnd2 = wbits < 0;
|
|
20287
|
-
if (wbits === 0) {
|
|
20288
|
-
f3 = f3.add(neg(cnd1, comp[off1]));
|
|
20289
|
-
} else {
|
|
20290
|
-
p5 = p5.add(neg(cnd2, comp[off2]));
|
|
20291
|
-
}
|
|
20292
|
-
}
|
|
20293
|
-
return { p: p5, f: f3 };
|
|
20294
|
-
};
|
|
20295
22083
|
const ethHexStartRe = /^0[xX]/;
|
|
20296
22084
|
function strip0x(hex) {
|
|
20297
22085
|
return hex.replace(ethHexStartRe, "");
|
|
@@ -21252,4 +23040,4 @@ export {
|
|
|
21252
23040
|
process$1 as p,
|
|
21253
23041
|
splitSignature as s
|
|
21254
23042
|
};
|
|
21255
|
-
//# sourceMappingURL=App-
|
|
23043
|
+
//# sourceMappingURL=App-xSBx5ak5.js.map
|