@prosopo/procaptcha-bundle 3.0.9 → 3.0.10
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/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.d.ts +1 -0
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -0
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.d.ts +1 -0
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaType.d.ts +2 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaType.d.ts.map +1 -1
- package/CHANGELOG.md +31 -0
- package/dist/bundle/ProcaptchaWidget-48FxVPQd.js +187 -0
- package/dist/bundle/ProcaptchaWidget-B2BzhXLv.js +992 -0
- package/dist/bundle/builder-DNHtDoNG.js +44 -0
- package/dist/bundle/{captchaComponentProvider-CZppE3Vb.js → captchaComponentProvider-B7Vxx339.js} +256 -99
- package/dist/bundle/{captchaRenderer-CY8KuZK-.js → captchaRenderer-DdOlOCKw.js} +3 -3
- package/dist/bundle/{commonChunk-24zMb_mF.js → commonChunk-HCVkoCqn.js} +9 -12
- package/dist/bundle/{emotion-element-5486c51c.browser.esm-PRDDgd_k.js → emotion-element-5486c51c.browser.esm-D7qvHZDV.js} +1 -1
- package/dist/bundle/{fp.esm-BADUiinQ.js → fp.esm-DYWeNGcH.js} +648 -548
- package/dist/bundle/index-7Xh-Mf8v.js +1318 -0
- package/dist/bundle/{index-BiwZ4wVT.js → index-C00_J7av.js} +48 -12
- package/dist/bundle/{index-BzOMq-ud.js → index-DyYmvHVN.js} +1 -1
- package/dist/bundle/locales/ar/translation.json +12 -11
- package/dist/bundle/locales/az/translation.json +12 -11
- package/dist/bundle/locales/cs/translation.json +12 -11
- package/dist/bundle/locales/de/translation.json +12 -11
- package/dist/bundle/locales/el/translation.json +12 -11
- package/dist/bundle/locales/en/translation.json +4 -3
- package/dist/bundle/locales/es/translation.json +12 -11
- package/dist/bundle/locales/fi/translation.json +29 -28
- package/dist/bundle/locales/fr/translation.json +12 -11
- package/dist/bundle/locales/hi/translation.json +41 -40
- package/dist/bundle/locales/hu/translation.json +12 -11
- package/dist/bundle/locales/id/translation.json +12 -11
- package/dist/bundle/locales/it/translation.json +12 -11
- package/dist/bundle/locales/ja/translation.json +12 -11
- package/dist/bundle/locales/jv/translation.json +12 -11
- package/dist/bundle/locales/ko/translation.json +7 -6
- package/dist/bundle/locales/ml/translation.json +12 -11
- package/dist/bundle/locales/ms/translation.json +12 -11
- package/dist/bundle/locales/nl/translation.json +12 -11
- package/dist/bundle/locales/no/translation.json +12 -11
- package/dist/bundle/locales/pl/translation.json +12 -11
- package/dist/bundle/locales/pt/translation.json +12 -11
- package/dist/bundle/locales/pt-BR/translation.json +12 -11
- package/dist/bundle/locales/ro/translation.json +12 -11
- package/dist/bundle/locales/ru/translation.json +12 -11
- package/dist/bundle/locales/sr/translation.json +12 -11
- package/dist/bundle/locales/sv/translation.json +12 -11
- package/dist/bundle/locales/th/translation.json +12 -11
- package/dist/bundle/locales/tr/translation.json +7 -6
- package/dist/bundle/locales/uk/translation.json +12 -11
- package/dist/bundle/locales/vi/translation.json +12 -11
- package/dist/bundle/locales/zh-CN/translation.json +12 -11
- package/dist/bundle/nobleChunk-Qozzkbsq.js +3648 -0
- package/dist/bundle/procaptcha.bundle.js +2 -2
- package/dist/bundle/util/captcha/captchaComponentProvider.d.ts +1 -0
- package/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
- package/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -0
- package/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
- package/dist/bundle/util/captcha/captchaRenderer.d.ts +1 -0
- package/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
- package/dist/bundle/util/captcha/captchaType.d.ts +2 -1
- package/dist/bundle/util/captcha/captchaType.d.ts.map +1 -1
- package/dist/bundle/{utilCryptoChunk-CIPUtfoO.js → utilCryptoChunk-qm-BM2eT.js} +618 -647
- package/dist/bundle/{web2Chunk-7Vd8yt2r.js → web2Chunk-DCsWA5PR.js} +1150 -994
- package/dist/bundle/{web3Chunk-DrUvbVNW.js → web3Chunk-B8txCqUJ.js} +3 -3
- package/dist/index.js +142 -108
- package/dist/util/captcha/captchaComponentProvider.js +18 -10
- package/dist/util/captcha/captchaComponentsList.js +6 -5
- package/dist/util/captcha/captchaRenderer.js +58 -40
- package/dist/util/captcha/captchaType.js +9 -5
- package/dist/util/captcha/components/frictionlessCaptcha.js +19 -9
- package/dist/util/captcha/components/imageCaptcha.js +13 -5
- package/dist/util/captcha/components/powCaptcha.js +13 -5
- package/dist/util/config.js +15 -12
- package/dist/util/configCreator.js +21 -22
- package/dist/util/language.js +14 -13
- package/dist/util/timeout.js +13 -8
- package/dist/util/widgetFactory.js +77 -55
- package/dist/util/widgetThemeResolver.js +14 -17
- package/package.json +23 -20
- package/stats.html +1 -1
- package/vite.cjs.config.ts +2 -3
- package/vite.esm.config.ts +20 -0
- package/vite.test.config.ts +9 -5
- package/dist/bundle/ProcaptchaWidget-D_kzGjgO.js +0 -612
- package/dist/bundle/ProcaptchaWidget-DlrcrISF.js +0 -148
- package/dist/bundle/builder-CQlqPNRd.js +0 -37
- package/dist/bundle/index-BRg_gWPo.js +0 -1328
- package/dist/bundle/nobleChunk-Xl5XLrx3.js +0 -3635
- package/dist/components.d.ts +0 -5
- package/dist/components.d.ts.map +0 -1
- package/dist/components.js +0 -5
- package/dist/components.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tests/util/captchaType.test.d.ts +0 -2
- package/dist/tests/util/captchaType.test.d.ts.map +0 -1
- package/dist/tests/util/captchaType.test.js +0 -36
- package/dist/tests/util/captchaType.test.js.map +0 -1
- package/dist/tests/util/config.test.d.ts +0 -2
- package/dist/tests/util/config.test.d.ts.map +0 -1
- package/dist/tests/util/config.test.js +0 -69
- package/dist/tests/util/config.test.js.map +0 -1
- package/dist/tests/util/renderLogic.test.d.ts +0 -2
- package/dist/tests/util/renderLogic.test.d.ts.map +0 -1
- package/dist/tests/util/renderLogic.test.js +0 -126
- package/dist/tests/util/renderLogic.test.js.map +0 -1
- package/dist/util/captcha/captchaComponentProvider.d.ts +0 -8
- package/dist/util/captcha/captchaComponentProvider.d.ts.map +0 -1
- package/dist/util/captcha/captchaComponentProvider.js.map +0 -1
- package/dist/util/captcha/captchaComponentsList.d.ts +0 -6
- package/dist/util/captcha/captchaComponentsList.d.ts.map +0 -1
- package/dist/util/captcha/captchaComponentsList.js.map +0 -1
- package/dist/util/captcha/captchaProps.d.ts +0 -9
- package/dist/util/captcha/captchaProps.d.ts.map +0 -1
- package/dist/util/captcha/captchaProps.js +0 -2
- package/dist/util/captcha/captchaProps.js.map +0 -1
- package/dist/util/captcha/captchaRenderer.d.ts +0 -24
- package/dist/util/captcha/captchaRenderer.d.ts.map +0 -1
- package/dist/util/captcha/captchaRenderer.js.map +0 -1
- package/dist/util/captcha/captchaType.d.ts +0 -3
- package/dist/util/captcha/captchaType.d.ts.map +0 -1
- package/dist/util/captcha/captchaType.js.map +0 -1
- package/dist/util/captcha/components/frictionlessCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/frictionlessCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/frictionlessCaptcha.js.map +0 -1
- package/dist/util/captcha/components/imageCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/imageCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/imageCaptcha.js.map +0 -1
- package/dist/util/captcha/components/powCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/powCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/powCaptcha.js.map +0 -1
- package/dist/util/config.d.ts +0 -6
- package/dist/util/config.d.ts.map +0 -1
- package/dist/util/config.js.map +0 -1
- package/dist/util/configCreator.d.ts +0 -5
- package/dist/util/configCreator.d.ts.map +0 -1
- package/dist/util/configCreator.js.map +0 -1
- package/dist/util/language.d.ts +0 -3
- package/dist/util/language.d.ts.map +0 -1
- package/dist/util/language.js.map +0 -1
- package/dist/util/timeout.d.ts +0 -3
- package/dist/util/timeout.d.ts.map +0 -1
- package/dist/util/timeout.js.map +0 -1
- package/dist/util/widgetFactory.d.ts +0 -18
- package/dist/util/widgetFactory.d.ts.map +0 -1
- package/dist/util/widgetFactory.js.map +0 -1
- package/dist/util/widgetThemeResolver.d.ts +0 -9
- package/dist/util/widgetThemeResolver.d.ts.map +0 -1
- package/dist/util/widgetThemeResolver.js.map +0 -1
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var Ee = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
|
+
};
|
|
4
|
+
var xe = (r, e, t) => e.has(r) || Ee("Cannot " + t);
|
|
5
|
+
var k = (r, e, t) => (xe(r, e, "read from private field"), t ? t.call(r) : e.get(r)), W = (r, e, t) => e.has(r) ? Ee("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), J = (r, e, t, n) => (xe(r, e, "write to private field"), n ? n.call(r, t) : e.set(r, t), t);
|
|
6
|
+
import { b as Ae, s as jr, r as U, a as Tr, n as y, c as D, R as g, u as he, i as Te, d as S, e as _e, m as _r, f as zr, g as Cr, k as Lr, h as Hr, p as Or, j as Fr, l as Mr, o as qr } from "./nobleChunk-Qozzkbsq.js";
|
|
7
|
+
import { u as h, a as Vr, b as I, s as V, i as ze, c as Ce, x as Kr, o as Yr, d as Z, e as C, f as Wr, g as Jr, h as Zr, j as Gr, k as Xr, l as Qr, m as et, n as Ue, p as rt, q as tt } from "./utilChunk-sqstc6C5.js";
|
|
8
|
+
import { B as nt } from "./bnChunk-DRlDxTFg.js";
|
|
9
|
+
function fe(r) {
|
|
5
10
|
return r instanceof Uint8Array || ArrayBuffer.isView(r) && r.constructor.name === "Uint8Array";
|
|
6
11
|
}
|
|
7
|
-
function
|
|
8
|
-
if (!
|
|
12
|
+
function ot(r, ...e) {
|
|
13
|
+
if (!fe(r))
|
|
9
14
|
throw new Error("Uint8Array expected");
|
|
10
15
|
if (e.length > 0 && !e.includes(r.length))
|
|
11
16
|
throw new Error("Uint8Array expected of length " + e + ", got length=" + r.length);
|
|
12
17
|
}
|
|
13
|
-
function
|
|
18
|
+
function Le(r, e) {
|
|
14
19
|
return Array.isArray(e) ? e.length === 0 ? !0 : r ? e.every((t) => typeof t == "string") : e.every((t) => Number.isSafeInteger(t)) : !1;
|
|
15
20
|
}
|
|
16
|
-
function
|
|
21
|
+
function P(r, e) {
|
|
17
22
|
if (typeof e != "string")
|
|
18
23
|
throw new Error(`${r}: string expected`);
|
|
19
24
|
return !0;
|
|
@@ -22,60 +27,60 @@ function T(r) {
|
|
|
22
27
|
if (!Number.isSafeInteger(r))
|
|
23
28
|
throw new Error(`invalid integer: ${r}`);
|
|
24
29
|
}
|
|
25
|
-
function
|
|
30
|
+
function O(r) {
|
|
26
31
|
if (!Array.isArray(r))
|
|
27
32
|
throw new Error("array expected");
|
|
28
33
|
}
|
|
29
|
-
function
|
|
30
|
-
if (!
|
|
34
|
+
function F(r, e) {
|
|
35
|
+
if (!Le(!0, e))
|
|
31
36
|
throw new Error(`${r}: array of strings expected`);
|
|
32
37
|
}
|
|
33
|
-
function
|
|
34
|
-
if (!
|
|
38
|
+
function He(r, e) {
|
|
39
|
+
if (!Le(!1, e))
|
|
35
40
|
throw new Error(`${r}: array of numbers expected`);
|
|
36
41
|
}
|
|
37
42
|
// @__NO_SIDE_EFFECTS__
|
|
38
|
-
function
|
|
39
|
-
const e = (
|
|
43
|
+
function Oe(...r) {
|
|
44
|
+
const e = (s) => s, t = (s, i) => (a) => s(i(a)), n = r.map((s) => s.encode).reduceRight(t, e), o = r.map((s) => s.decode).reduce(t, e);
|
|
40
45
|
return { encode: n, decode: o };
|
|
41
46
|
}
|
|
42
47
|
// @__NO_SIDE_EFFECTS__
|
|
43
|
-
function
|
|
48
|
+
function Fe(r) {
|
|
44
49
|
const e = typeof r == "string" ? r.split("") : r, t = e.length;
|
|
45
|
-
|
|
46
|
-
const n = new Map(e.map((o,
|
|
50
|
+
F("alphabet", e);
|
|
51
|
+
const n = new Map(e.map((o, s) => [o, s]));
|
|
47
52
|
return {
|
|
48
|
-
encode: (o) => (
|
|
49
|
-
if (!Number.isSafeInteger(
|
|
50
|
-
throw new Error(`alphabet.encode: digit index outside alphabet "${
|
|
51
|
-
return e[
|
|
53
|
+
encode: (o) => (O(o), o.map((s) => {
|
|
54
|
+
if (!Number.isSafeInteger(s) || s < 0 || s >= t)
|
|
55
|
+
throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${r}`);
|
|
56
|
+
return e[s];
|
|
52
57
|
})),
|
|
53
|
-
decode: (o) => (
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
throw new Error(`Unknown letter: "${
|
|
58
|
-
return
|
|
58
|
+
decode: (o) => (O(o), o.map((s) => {
|
|
59
|
+
P("alphabet.decode", s);
|
|
60
|
+
const i = n.get(s);
|
|
61
|
+
if (i === void 0)
|
|
62
|
+
throw new Error(`Unknown letter: "${s}". Allowed: ${r}`);
|
|
63
|
+
return i;
|
|
59
64
|
}))
|
|
60
65
|
};
|
|
61
66
|
}
|
|
62
67
|
// @__NO_SIDE_EFFECTS__
|
|
63
|
-
function
|
|
64
|
-
return
|
|
65
|
-
encode: (e) => (
|
|
66
|
-
decode: (e) => (
|
|
68
|
+
function Me(r = "") {
|
|
69
|
+
return P("join", r), {
|
|
70
|
+
encode: (e) => (F("join.decode", e), e.join(r)),
|
|
71
|
+
decode: (e) => (P("join.decode", e), e.split(r))
|
|
67
72
|
};
|
|
68
73
|
}
|
|
69
74
|
// @__NO_SIDE_EFFECTS__
|
|
70
|
-
function
|
|
71
|
-
return T(r),
|
|
75
|
+
function st(r, e = "=") {
|
|
76
|
+
return T(r), P("padding", e), {
|
|
72
77
|
encode(t) {
|
|
73
|
-
for (
|
|
78
|
+
for (F("padding.encode", t); t.length * r % 8; )
|
|
74
79
|
t.push(e);
|
|
75
80
|
return t;
|
|
76
81
|
},
|
|
77
82
|
decode(t) {
|
|
78
|
-
|
|
83
|
+
F("padding.decode", t);
|
|
79
84
|
let n = t.length;
|
|
80
85
|
if (n * r % 8)
|
|
81
86
|
throw new Error("padding: invalid, string should have whole number of bytes");
|
|
@@ -86,258 +91,277 @@ function zr(r, e = "=") {
|
|
|
86
91
|
}
|
|
87
92
|
};
|
|
88
93
|
}
|
|
89
|
-
function
|
|
94
|
+
function Se(r, e, t) {
|
|
90
95
|
if (e < 2)
|
|
91
96
|
throw new Error(`convertRadix: invalid from=${e}, base cannot be less than 2`);
|
|
92
97
|
if (t < 2)
|
|
93
98
|
throw new Error(`convertRadix: invalid to=${t}, base cannot be less than 2`);
|
|
94
|
-
if (
|
|
99
|
+
if (O(r), !r.length)
|
|
95
100
|
return [];
|
|
96
101
|
let n = 0;
|
|
97
|
-
const o = [],
|
|
98
|
-
if (T(
|
|
99
|
-
throw new Error(`invalid integer: ${
|
|
100
|
-
return
|
|
101
|
-
}),
|
|
102
|
+
const o = [], s = Array.from(r, (a) => {
|
|
103
|
+
if (T(a), a < 0 || a >= e)
|
|
104
|
+
throw new Error(`invalid integer: ${a}`);
|
|
105
|
+
return a;
|
|
106
|
+
}), i = s.length;
|
|
102
107
|
for (; ; ) {
|
|
103
|
-
let
|
|
104
|
-
for (let c = n; c <
|
|
105
|
-
const u =
|
|
106
|
-
if (!Number.isSafeInteger(p) || d / e !==
|
|
108
|
+
let a = 0, l = !0;
|
|
109
|
+
for (let c = n; c < i; c++) {
|
|
110
|
+
const u = s[c], d = e * a, p = d + u;
|
|
111
|
+
if (!Number.isSafeInteger(p) || d / e !== a || p - u !== d)
|
|
107
112
|
throw new Error("convertRadix: carry overflow");
|
|
108
113
|
const b = p / t;
|
|
109
|
-
|
|
114
|
+
a = p % t;
|
|
110
115
|
const w = Math.floor(b);
|
|
111
|
-
if (
|
|
116
|
+
if (s[c] = w, !Number.isSafeInteger(w) || w * t + a !== p)
|
|
112
117
|
throw new Error("convertRadix: carry overflow");
|
|
113
118
|
if (l)
|
|
114
119
|
w ? l = !1 : n = c;
|
|
115
120
|
else continue;
|
|
116
121
|
}
|
|
117
|
-
if (o.push(
|
|
122
|
+
if (o.push(a), l)
|
|
118
123
|
break;
|
|
119
124
|
}
|
|
120
|
-
for (let
|
|
125
|
+
for (let a = 0; a < r.length - 1 && r[a] === 0; a++)
|
|
121
126
|
o.push(0);
|
|
122
127
|
return o.reverse();
|
|
123
128
|
}
|
|
124
|
-
const
|
|
129
|
+
const qe = (r, e) => e === 0 ? r : qe(e, r % e), M = /* @__NO_SIDE_EFFECTS__ */ (r, e) => r + (e - qe(r, e)), G = /* @__PURE__ */ (() => {
|
|
125
130
|
let r = [];
|
|
126
131
|
for (let e = 0; e < 40; e++)
|
|
127
132
|
r.push(2 ** e);
|
|
128
133
|
return r;
|
|
129
134
|
})();
|
|
130
|
-
function
|
|
131
|
-
if (
|
|
135
|
+
function Be(r, e, t, n) {
|
|
136
|
+
if (O(r), e <= 0 || e > 32)
|
|
132
137
|
throw new Error(`convertRadix2: wrong from=${e}`);
|
|
133
138
|
if (t <= 0 || t > 32)
|
|
134
139
|
throw new Error(`convertRadix2: wrong to=${t}`);
|
|
135
|
-
if (/* @__PURE__ */
|
|
136
|
-
throw new Error(`convertRadix2: carry overflow from=${e} to=${t} carryBits=${/* @__PURE__ */
|
|
137
|
-
let o = 0,
|
|
138
|
-
const
|
|
140
|
+
if (/* @__PURE__ */ M(e, t) > 32)
|
|
141
|
+
throw new Error(`convertRadix2: carry overflow from=${e} to=${t} carryBits=${/* @__PURE__ */ M(e, t)}`);
|
|
142
|
+
let o = 0, s = 0;
|
|
143
|
+
const i = G[e], a = G[t] - 1, l = [];
|
|
139
144
|
for (const c of r) {
|
|
140
|
-
if (T(c), c >=
|
|
145
|
+
if (T(c), c >= i)
|
|
141
146
|
throw new Error(`convertRadix2: invalid data word=${c} from=${e}`);
|
|
142
|
-
if (o = o << e | c,
|
|
143
|
-
throw new Error(`convertRadix2: carry overflow pos=${
|
|
144
|
-
for (
|
|
145
|
-
l.push((o >>
|
|
146
|
-
const u =
|
|
147
|
+
if (o = o << e | c, s + e > 32)
|
|
148
|
+
throw new Error(`convertRadix2: carry overflow pos=${s} from=${e}`);
|
|
149
|
+
for (s += e; s >= t; s -= t)
|
|
150
|
+
l.push((o >> s - t & a) >>> 0);
|
|
151
|
+
const u = G[s];
|
|
147
152
|
if (u === void 0)
|
|
148
153
|
throw new Error("invalid carry");
|
|
149
154
|
o &= u - 1;
|
|
150
155
|
}
|
|
151
|
-
if (o = o << t -
|
|
156
|
+
if (o = o << t - s & a, !n && s >= e)
|
|
152
157
|
throw new Error("Excess padding");
|
|
153
158
|
if (!n && o > 0)
|
|
154
159
|
throw new Error(`Non-zero padding: ${o}`);
|
|
155
|
-
return n &&
|
|
160
|
+
return n && s > 0 && l.push(o >>> 0), l;
|
|
156
161
|
}
|
|
157
162
|
// @__NO_SIDE_EFFECTS__
|
|
158
|
-
function
|
|
163
|
+
function at(r) {
|
|
159
164
|
T(r);
|
|
160
165
|
const e = 2 ** 8;
|
|
161
166
|
return {
|
|
162
167
|
encode: (t) => {
|
|
163
|
-
if (!
|
|
168
|
+
if (!fe(t))
|
|
164
169
|
throw new Error("radix.encode input should be Uint8Array");
|
|
165
|
-
return
|
|
170
|
+
return Se(Array.from(t), e, r);
|
|
166
171
|
},
|
|
167
|
-
decode: (t) => (
|
|
172
|
+
decode: (t) => (He("radix.decode", t), Uint8Array.from(Se(t, r, e)))
|
|
168
173
|
};
|
|
169
174
|
}
|
|
170
175
|
// @__NO_SIDE_EFFECTS__
|
|
171
|
-
function
|
|
176
|
+
function it(r, e = !1) {
|
|
172
177
|
if (T(r), r <= 0 || r > 32)
|
|
173
178
|
throw new Error("radix2: bits should be in (0..32]");
|
|
174
|
-
if (/* @__PURE__ */
|
|
179
|
+
if (/* @__PURE__ */ M(8, r) > 32 || /* @__PURE__ */ M(r, 8) > 32)
|
|
175
180
|
throw new Error("radix2: carry overflow");
|
|
176
181
|
return {
|
|
177
182
|
encode: (t) => {
|
|
178
|
-
if (!
|
|
183
|
+
if (!fe(t))
|
|
179
184
|
throw new Error("radix2.encode input should be Uint8Array");
|
|
180
|
-
return
|
|
185
|
+
return Be(Array.from(t), 8, r, !e);
|
|
181
186
|
},
|
|
182
|
-
decode: (t) => (
|
|
187
|
+
decode: (t) => (He("radix2.decode", t), Uint8Array.from(Be(t, r, 8, e)))
|
|
183
188
|
};
|
|
184
189
|
}
|
|
185
|
-
const
|
|
186
|
-
|
|
190
|
+
const ct = typeof Uint8Array.from([]).toBase64 == "function" && typeof Uint8Array.fromBase64 == "function", lt = (r, e) => {
|
|
191
|
+
P("base64", r);
|
|
187
192
|
const t = /^[A-Za-z0-9=+/]+$/, n = "base64";
|
|
188
193
|
if (r.length > 0 && !t.test(r))
|
|
189
194
|
throw new Error("invalid base64");
|
|
190
195
|
return Uint8Array.fromBase64(r, { alphabet: n, lastChunkHandling: "strict" });
|
|
191
|
-
},
|
|
196
|
+
}, ut = ct ? {
|
|
192
197
|
encode(r) {
|
|
193
|
-
return
|
|
198
|
+
return ot(r), r.toBase64();
|
|
194
199
|
},
|
|
195
200
|
decode(r) {
|
|
196
|
-
return
|
|
201
|
+
return lt(r);
|
|
197
202
|
}
|
|
198
|
-
} : /* @__PURE__ */
|
|
199
|
-
function
|
|
203
|
+
} : /* @__PURE__ */ Oe(/* @__PURE__ */ it(6), /* @__PURE__ */ Fe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), /* @__PURE__ */ st(6), /* @__PURE__ */ Me("")), dt = /* @__NO_SIDE_EFFECTS__ */ (r) => /* @__PURE__ */ Oe(/* @__PURE__ */ at(58), /* @__PURE__ */ Fe(r), /* @__PURE__ */ Me("")), ht = /* @__PURE__ */ dt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
204
|
+
function Ve({ coder: r, ipfs: e }, t) {
|
|
200
205
|
return (n, o) => (t(n, o), r.decode(e && o ? n.substring(1) : n));
|
|
201
206
|
}
|
|
202
|
-
function
|
|
207
|
+
function Ke({ coder: r, ipfs: e }) {
|
|
203
208
|
return (t, n) => {
|
|
204
209
|
const o = r.encode(h(t));
|
|
205
210
|
return e && n ? `${e}${o}` : o;
|
|
206
211
|
};
|
|
207
212
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
213
|
+
function Ye({
|
|
214
|
+
chars: r,
|
|
215
|
+
ipfs: e,
|
|
216
|
+
type: t,
|
|
217
|
+
withPadding: n
|
|
218
|
+
}) {
|
|
219
|
+
return (o, s) => {
|
|
210
220
|
if (typeof o != "string")
|
|
211
221
|
throw new Error(`Expected ${t} string input`);
|
|
212
|
-
if (e &&
|
|
213
|
-
throw new Error(
|
|
214
|
-
|
|
215
|
-
|
|
222
|
+
if (e && s && !o.startsWith(e))
|
|
223
|
+
throw new Error(
|
|
224
|
+
`Expected ipfs-compatible ${t} to start with '${e}'`
|
|
225
|
+
);
|
|
226
|
+
for (let i = s ? 1 : 0, a = o.length; i < a; i++) {
|
|
227
|
+
const l = o[i];
|
|
216
228
|
if (l === void 0)
|
|
217
|
-
throw new Error(`Invalid undefined value at index ${
|
|
218
|
-
if (!r.includes(l)) if (n && o[
|
|
219
|
-
if (
|
|
220
|
-
if (o[
|
|
229
|
+
throw new Error(`Invalid undefined value at index ${i}`);
|
|
230
|
+
if (!r.includes(l)) if (n && o[i] === "=") {
|
|
231
|
+
if (i !== a - 1) {
|
|
232
|
+
if (o[i + 1] !== "=") throw new Error(
|
|
233
|
+
`Invalid ${t} padding sequence "${o[i]}${o[i + 1]}" at index ${i}`
|
|
234
|
+
);
|
|
221
235
|
}
|
|
222
236
|
} else
|
|
223
|
-
throw new Error(
|
|
237
|
+
throw new Error(
|
|
238
|
+
`Invalid ${t} character "${o[i]}" (0x${o.charCodeAt(i).toString(16)}) at index ${i}`
|
|
239
|
+
);
|
|
224
240
|
}
|
|
225
241
|
return !0;
|
|
226
242
|
};
|
|
227
243
|
}
|
|
228
|
-
const
|
|
244
|
+
const pe = {
|
|
229
245
|
chars: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
|
|
230
|
-
coder:
|
|
246
|
+
coder: ht,
|
|
231
247
|
ipfs: "z",
|
|
232
248
|
type: "base58"
|
|
233
|
-
},
|
|
234
|
-
function
|
|
235
|
-
return (...e) =>
|
|
249
|
+
}, We = /* @__PURE__ */ Ye(pe), Je = /* @__PURE__ */ Ve(pe, We), Ze = /* @__PURE__ */ Ke(pe);
|
|
250
|
+
function Ge(r) {
|
|
251
|
+
return (...e) => Vr(r(...e));
|
|
236
252
|
}
|
|
237
|
-
function
|
|
238
|
-
const o = Math.ceil(e / 8),
|
|
239
|
-
return t ?
|
|
253
|
+
function K(r, e = 256, t, n) {
|
|
254
|
+
const o = Math.ceil(e / 8), s = h(r);
|
|
255
|
+
return t ? Ae(s, { dkLen: o, key: t }) : Ae(s, { dkLen: o });
|
|
240
256
|
}
|
|
241
|
-
const
|
|
242
|
-
function
|
|
243
|
-
return
|
|
257
|
+
const ft = /* @__PURE__ */ Ge(K), pt = V("SS58PRE");
|
|
258
|
+
function Xe(r) {
|
|
259
|
+
return K(I(pt, r), 512);
|
|
244
260
|
}
|
|
245
|
-
function
|
|
261
|
+
function gt(r) {
|
|
246
262
|
if (r[0] === void 0)
|
|
247
263
|
throw new Error("Invalid address: first byte cannot be undefined");
|
|
248
264
|
if (r[1] === void 0)
|
|
249
265
|
throw new Error("Invalid address: second byte cannot be undefined");
|
|
250
|
-
const e = r[0] & 64 ? 2 : 1, t = e === 1 ? r[0] : (r[0] & 63) << 2 | r[1] >> 6 | (r[1] & 63) << 8, n = [34 + e, 35 + e].includes(
|
|
251
|
-
|
|
266
|
+
const e = r[0] & 64 ? 2 : 1, t = e === 1 ? r[0] : (r[0] & 63) << 2 | r[1] >> 6 | (r[1] & 63) << 8, n = [34 + e, 35 + e].includes(
|
|
267
|
+
r.length
|
|
268
|
+
), o = r.length - (n ? 2 : 1), s = Xe(r.subarray(0, o));
|
|
269
|
+
return [(r[0] & 128) === 0 && ![46, 47].includes(r[0]) && (n ? r[r.length - 2] === s[0] && r[r.length - 1] === s[1] : r[r.length - 1] === s[0]), o, e, t];
|
|
252
270
|
}
|
|
253
|
-
const
|
|
271
|
+
const L = {
|
|
254
272
|
allowedDecodedLengths: [1, 2, 4, 8, 32, 33],
|
|
273
|
+
// publicKey has prefix + 2 checksum bytes, short only prefix + 1 checksum byte
|
|
255
274
|
allowedEncodedLengths: [3, 4, 6, 10, 35, 36, 37, 38],
|
|
256
275
|
prefix: 42
|
|
257
276
|
};
|
|
258
|
-
function
|
|
277
|
+
function ge(r, e, t = -1) {
|
|
259
278
|
if (!r)
|
|
260
279
|
throw new Error("Invalid empty address passed");
|
|
261
|
-
if (
|
|
280
|
+
if (ze(r) || Ce(r))
|
|
262
281
|
return h(r);
|
|
263
282
|
try {
|
|
264
|
-
const n =
|
|
265
|
-
if (!
|
|
283
|
+
const n = Je(r);
|
|
284
|
+
if (!L.allowedEncodedLengths.includes(n.length))
|
|
266
285
|
throw new Error("Invalid decoded address length");
|
|
267
|
-
const [o,
|
|
286
|
+
const [o, s, i, a] = gt(n);
|
|
268
287
|
if (!o && !e)
|
|
269
288
|
throw new Error("Invalid decoded address checksum");
|
|
270
|
-
if (t !== -1 && t !==
|
|
271
|
-
throw new Error(
|
|
272
|
-
|
|
289
|
+
if (t !== -1 && t !== a)
|
|
290
|
+
throw new Error(
|
|
291
|
+
`Expected ss58Format ${t}, received ${a}`
|
|
292
|
+
);
|
|
293
|
+
return n.slice(i, s);
|
|
273
294
|
} catch (n) {
|
|
274
295
|
throw new Error(`Decoding ${r}: ${n.message}`);
|
|
275
296
|
}
|
|
276
297
|
}
|
|
277
|
-
function
|
|
278
|
-
const t =
|
|
298
|
+
function mt(r, e = L.prefix) {
|
|
299
|
+
const t = ge(r);
|
|
279
300
|
if (e < 0 || e > 16383 || [46, 47].includes(e))
|
|
280
301
|
throw new Error("Out of range ss58Format specified");
|
|
281
|
-
if (!
|
|
282
|
-
throw new Error(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
302
|
+
if (!L.allowedDecodedLengths.includes(t.length))
|
|
303
|
+
throw new Error(
|
|
304
|
+
`Expected a valid key to convert, with length ${L.allowedDecodedLengths.join(", ")}`
|
|
305
|
+
);
|
|
306
|
+
const n = I(
|
|
307
|
+
e < 64 ? [e] : [
|
|
308
|
+
(e & 252) >> 2 | 64,
|
|
309
|
+
e >> 8 | (e & 3) << 6
|
|
310
|
+
],
|
|
311
|
+
t
|
|
312
|
+
);
|
|
313
|
+
return Ze(
|
|
314
|
+
I(
|
|
315
|
+
n,
|
|
316
|
+
Xe(n).subarray(0, [32, 33].includes(t.length) ? 2 : 1)
|
|
317
|
+
)
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
const me = {
|
|
290
321
|
chars: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
291
|
-
coder:
|
|
322
|
+
coder: ut,
|
|
292
323
|
type: "base64",
|
|
293
324
|
withPadding: !0
|
|
294
|
-
},
|
|
295
|
-
function
|
|
325
|
+
}, Qe = /* @__PURE__ */ Ye(me), yt = /* @__PURE__ */ Ve(me, Qe), er = /* @__PURE__ */ Ke(me);
|
|
326
|
+
function z(r, e) {
|
|
296
327
|
return r << e | r >>> 32 - e;
|
|
297
328
|
}
|
|
298
|
-
function
|
|
329
|
+
function E(r, e) {
|
|
299
330
|
let t = r[e + 3] & 255;
|
|
300
331
|
return t = t << 8 | r[e + 2] & 255, t = t << 8 | r[e + 1] & 255, t << 8 | r[e + 0] & 255;
|
|
301
332
|
}
|
|
302
|
-
function
|
|
333
|
+
function X(r, e, t) {
|
|
303
334
|
for (let n = 0; n < 4; n++)
|
|
304
335
|
r[e + n] = t & 255, t >>>= 8;
|
|
305
336
|
}
|
|
306
|
-
function
|
|
307
|
-
let
|
|
308
|
-
for (let
|
|
309
|
-
|
|
310
|
-
return (1 & a - 1 >>> 8) - 1;
|
|
337
|
+
function wt(r, e, t, n, o) {
|
|
338
|
+
let s = 0;
|
|
339
|
+
for (let i = 0; i < o; i++) s |= r[e + i] ^ t[n + i];
|
|
340
|
+
return (1 & s - 1 >>> 8) - 1;
|
|
311
341
|
}
|
|
312
|
-
function
|
|
313
|
-
const
|
|
342
|
+
function oe(r, e, t, n, o) {
|
|
343
|
+
const s = new Uint32Array(16), i = new Uint32Array(16), a = new Uint32Array(16), l = new Uint32Array(4);
|
|
314
344
|
let c, u, d;
|
|
315
345
|
for (c = 0; c < 4; c++)
|
|
316
|
-
|
|
317
|
-
for (c = 0; c < 16; c++)
|
|
318
|
-
i[c] = s[c];
|
|
346
|
+
i[5 * c] = E(n, 4 * c), i[1 + c] = E(t, 4 * c), i[6 + c] = E(e, 4 * c), i[11 + c] = E(t, 16 + 4 * c);
|
|
347
|
+
for (c = 0; c < 16; c++) a[c] = i[c];
|
|
319
348
|
for (c = 0; c < 20; c++) {
|
|
320
349
|
for (u = 0; u < 4; u++) {
|
|
321
|
-
for (d = 0; d < 4; d++)
|
|
322
|
-
|
|
323
|
-
for (l[1] ^= j(l[0] + l[3] | 0, 7), l[2] ^= j(l[1] + l[0] | 0, 9), l[3] ^= j(l[2] + l[1] | 0, 13), l[0] ^= j(l[3] + l[2] | 0, 18), d = 0; d < 4; d++)
|
|
324
|
-
a[4 * u + (u + d) % 4] = l[d];
|
|
350
|
+
for (d = 0; d < 4; d++) l[d] = i[(5 * u + 4 * d) % 16];
|
|
351
|
+
for (l[1] ^= z(l[0] + l[3] | 0, 7), l[2] ^= z(l[1] + l[0] | 0, 9), l[3] ^= z(l[2] + l[1] | 0, 13), l[0] ^= z(l[3] + l[2] | 0, 18), d = 0; d < 4; d++) s[4 * u + (u + d) % 4] = l[d];
|
|
325
352
|
}
|
|
326
|
-
for (d = 0; d < 16; d++)
|
|
327
|
-
s[d] = a[d];
|
|
353
|
+
for (d = 0; d < 16; d++) i[d] = s[d];
|
|
328
354
|
}
|
|
329
355
|
if (o) {
|
|
330
|
-
for (c = 0; c < 16; c++)
|
|
331
|
-
s[c] = s[c] + i[c] | 0;
|
|
356
|
+
for (c = 0; c < 16; c++) i[c] = i[c] + a[c] | 0;
|
|
332
357
|
for (c = 0; c < 4; c++)
|
|
333
|
-
|
|
358
|
+
i[5 * c] = i[5 * c] - E(n, 4 * c) | 0, i[6 + c] = i[6 + c] - E(e, 4 * c) | 0;
|
|
334
359
|
for (c = 0; c < 4; c++)
|
|
335
|
-
|
|
360
|
+
X(r, 4 * c, i[5 * c]), X(r, 16 + 4 * c, i[6 + c]);
|
|
336
361
|
} else
|
|
337
|
-
for (c = 0; c < 16; c++)
|
|
338
|
-
J(r, 4 * c, s[c] + i[c] | 0);
|
|
362
|
+
for (c = 0; c < 16; c++) X(r, 4 * c, i[c] + a[c] | 0);
|
|
339
363
|
}
|
|
340
|
-
const
|
|
364
|
+
const se = new Uint8Array([
|
|
341
365
|
101,
|
|
342
366
|
120,
|
|
343
367
|
112,
|
|
@@ -355,37 +379,32 @@ const te = new Uint8Array([
|
|
|
355
379
|
32,
|
|
356
380
|
107
|
|
357
381
|
]);
|
|
358
|
-
function
|
|
359
|
-
const
|
|
382
|
+
function bt(r, e, t, n, o, s, i) {
|
|
383
|
+
const a = new Uint8Array(16), l = new Uint8Array(64);
|
|
360
384
|
let c, u;
|
|
361
|
-
if (!o)
|
|
362
|
-
|
|
363
|
-
for (u = 0; u <
|
|
364
|
-
i[u] = 0;
|
|
365
|
-
for (u = 0; u < 8; u++)
|
|
366
|
-
i[u] = a[u];
|
|
385
|
+
if (!o) return 0;
|
|
386
|
+
for (u = 0; u < 16; u++) a[u] = 0;
|
|
387
|
+
for (u = 0; u < 8; u++) a[u] = s[u];
|
|
367
388
|
for (; o >= 64; ) {
|
|
368
|
-
for (
|
|
369
|
-
r[e + u] = (t ? t[n + u] : 0) ^ l[u];
|
|
389
|
+
for (oe(l, a, i, se, !1), u = 0; u < 64; u++) r[e + u] = (t ? t[n + u] : 0) ^ l[u];
|
|
370
390
|
for (c = 1, u = 8; u < 16; u++)
|
|
371
|
-
c = c + (
|
|
391
|
+
c = c + (a[u] & 255) | 0, a[u] = c & 255, c >>>= 8;
|
|
372
392
|
o -= 64, e += 64, t && (n += 64);
|
|
373
393
|
}
|
|
374
394
|
if (o > 0)
|
|
375
|
-
for (
|
|
376
|
-
r[e + u] = (t ? t[n + u] : 0) ^ l[u];
|
|
395
|
+
for (oe(l, a, i, se, !1), u = 0; u < o; u++) r[e + u] = (t ? t[n + u] : 0) ^ l[u];
|
|
377
396
|
return 0;
|
|
378
397
|
}
|
|
379
|
-
function
|
|
380
|
-
const
|
|
381
|
-
return
|
|
398
|
+
function ae(r, e, t, n, o, s, i) {
|
|
399
|
+
const a = new Uint8Array(32);
|
|
400
|
+
return oe(a, s, i, se, !0), bt(r, e, t, n, o, s.subarray(16), a);
|
|
382
401
|
}
|
|
383
|
-
function
|
|
402
|
+
function Q(r, e) {
|
|
384
403
|
let t = 0;
|
|
385
404
|
for (let n = 0; n < 17; n++)
|
|
386
405
|
t = t + (r[n] + e[n] | 0) | 0, r[n] = t & 255, t >>>= 8;
|
|
387
406
|
}
|
|
388
|
-
const
|
|
407
|
+
const vt = new Uint32Array([
|
|
389
408
|
5,
|
|
390
409
|
0,
|
|
391
410
|
0,
|
|
@@ -404,133 +423,124 @@ const et = new Uint32Array([
|
|
|
404
423
|
0,
|
|
405
424
|
252
|
|
406
425
|
]);
|
|
407
|
-
function
|
|
408
|
-
let
|
|
426
|
+
function rr(r, e, t, n, o, s) {
|
|
427
|
+
let i, a, l;
|
|
409
428
|
const c = new Uint32Array(17), u = new Uint32Array(17), d = new Uint32Array(17), p = new Uint32Array(17), b = new Uint32Array(17);
|
|
410
|
-
for (
|
|
411
|
-
|
|
412
|
-
for (i = 0; i < 16; i++)
|
|
413
|
-
u[i] = a[i];
|
|
429
|
+
for (a = 0; a < 17; a++) u[a] = d[a] = 0;
|
|
430
|
+
for (a = 0; a < 16; a++) u[a] = s[a];
|
|
414
431
|
for (u[3] &= 15, u[4] &= 252, u[7] &= 15, u[8] &= 252, u[11] &= 15, u[12] &= 252, u[15] &= 15; o > 0; ) {
|
|
415
|
-
for (
|
|
416
|
-
|
|
417
|
-
for (
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
l = l + d[i] | 0, d[i] = l & 255, l >>>= 8;
|
|
426
|
-
for (l = l + d[16] | 0, d[16] = l & 3, l = 5 * (l >>> 2) | 0, i = 0; i < 16; i++)
|
|
427
|
-
l = l + d[i] | 0, d[i] = l & 255, l >>>= 8;
|
|
432
|
+
for (a = 0; a < 17; a++) p[a] = 0;
|
|
433
|
+
for (a = 0; a < 16 && a < o; ++a) p[a] = t[n + a];
|
|
434
|
+
for (p[a] = 1, n += a, o -= a, Q(d, p), i = 0; i < 17; i++)
|
|
435
|
+
for (c[i] = 0, a = 0; a < 17; a++)
|
|
436
|
+
c[i] = c[i] + d[a] * (a <= i ? u[i - a] : 320 * u[i + 17 - a] | 0) | 0 | 0;
|
|
437
|
+
for (i = 0; i < 17; i++) d[i] = c[i];
|
|
438
|
+
for (l = 0, a = 0; a < 16; a++)
|
|
439
|
+
l = l + d[a] | 0, d[a] = l & 255, l >>>= 8;
|
|
440
|
+
for (l = l + d[16] | 0, d[16] = l & 3, l = 5 * (l >>> 2) | 0, a = 0; a < 16; a++)
|
|
441
|
+
l = l + d[a] | 0, d[a] = l & 255, l >>>= 8;
|
|
428
442
|
l = l + d[16] | 0, d[16] = l;
|
|
429
443
|
}
|
|
430
|
-
for (
|
|
431
|
-
|
|
432
|
-
G(d, et);
|
|
444
|
+
for (a = 0; a < 17; a++) b[a] = d[a];
|
|
445
|
+
Q(d, vt);
|
|
433
446
|
const w = -(d[16] >>> 7) | 0;
|
|
434
|
-
for (
|
|
435
|
-
|
|
436
|
-
for (
|
|
437
|
-
p[i] = a[i + 16];
|
|
438
|
-
for (p[16] = 0, G(d, p), i = 0; i < 16; i++)
|
|
439
|
-
r[e + i] = d[i];
|
|
447
|
+
for (a = 0; a < 17; a++) d[a] ^= w & (b[a] ^ d[a]);
|
|
448
|
+
for (a = 0; a < 16; a++) p[a] = s[a + 16];
|
|
449
|
+
for (p[16] = 0, Q(d, p), a = 0; a < 16; a++) r[e + a] = d[a];
|
|
440
450
|
return 0;
|
|
441
451
|
}
|
|
442
|
-
function
|
|
443
|
-
const
|
|
444
|
-
return
|
|
452
|
+
function kt(r, e, t, n, o, s) {
|
|
453
|
+
const i = new Uint8Array(16);
|
|
454
|
+
return rr(i, 0, t, n, o, s), wt(r, e, i, 0, 16);
|
|
445
455
|
}
|
|
446
|
-
function
|
|
447
|
-
if (t < 32)
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
for (let a = 0; a < 16; a++)
|
|
451
|
-
r[a] = 0;
|
|
456
|
+
function Et(r, e, t, n, o) {
|
|
457
|
+
if (t < 32) return -1;
|
|
458
|
+
ae(r, 0, e, 0, t, n, o), rr(r, 16, r, 32, t - 32, r);
|
|
459
|
+
for (let s = 0; s < 16; s++) r[s] = 0;
|
|
452
460
|
return 0;
|
|
453
461
|
}
|
|
454
|
-
function
|
|
455
|
-
const
|
|
456
|
-
if (t < 32 || (
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
for (let s = 0; s < 32; s++)
|
|
460
|
-
r[s] = 0;
|
|
462
|
+
function xt(r, e, t, n, o) {
|
|
463
|
+
const s = new Uint8Array(32);
|
|
464
|
+
if (t < 32 || (ae(s, 0, null, 0, 32, n, o), kt(e, 16, e, 32, t - 32, s) !== 0)) return -1;
|
|
465
|
+
ae(r, 0, e, 0, t, n, o);
|
|
466
|
+
for (let i = 0; i < 32; i++) r[i] = 0;
|
|
461
467
|
return 0;
|
|
462
468
|
}
|
|
463
|
-
const
|
|
464
|
-
function
|
|
465
|
-
if (r.length !==
|
|
466
|
-
|
|
467
|
-
if (e.length !== at)
|
|
469
|
+
const At = 32, Ut = 24, ie = 32, ce = 16;
|
|
470
|
+
function tr(r, e) {
|
|
471
|
+
if (r.length !== At) throw new Error("bad key size");
|
|
472
|
+
if (e.length !== Ut)
|
|
468
473
|
throw new Error("bad nonce size");
|
|
469
474
|
}
|
|
470
|
-
function
|
|
475
|
+
function nr(...r) {
|
|
471
476
|
for (let e = 0, t = r.length; e < t; e++)
|
|
472
477
|
if (!(r[e] instanceof Uint8Array))
|
|
473
478
|
throw new TypeError("unexpected type, use Uint8Array");
|
|
474
479
|
}
|
|
475
|
-
function
|
|
476
|
-
|
|
477
|
-
const n = new Uint8Array(
|
|
478
|
-
for (let
|
|
479
|
-
n[
|
|
480
|
-
return
|
|
480
|
+
function St(r, e, t) {
|
|
481
|
+
nr(r, e, t), tr(t, e);
|
|
482
|
+
const n = new Uint8Array(ie + r.length), o = new Uint8Array(n.length);
|
|
483
|
+
for (let s = 0; s < r.length; s++)
|
|
484
|
+
n[s + ie] = r[s];
|
|
485
|
+
return Et(o, n, n.length, e, t), o.subarray(ce);
|
|
481
486
|
}
|
|
482
|
-
function
|
|
483
|
-
|
|
484
|
-
const n = new Uint8Array(
|
|
485
|
-
for (let
|
|
486
|
-
n[
|
|
487
|
-
return n.length < 32 ||
|
|
487
|
+
function Bt(r, e, t) {
|
|
488
|
+
nr(r, e, t), tr(t, e);
|
|
489
|
+
const n = new Uint8Array(ce + r.length), o = new Uint8Array(n.length);
|
|
490
|
+
for (let s = 0; s < r.length; s++)
|
|
491
|
+
n[s + ce] = r[s];
|
|
492
|
+
return n.length < 32 || xt(o, n, n.length, e, t) !== 0 ? null : o.subarray(ie);
|
|
488
493
|
}
|
|
489
|
-
function
|
|
490
|
-
return
|
|
494
|
+
function or(r, e, t) {
|
|
495
|
+
return Bt(r, e, t);
|
|
491
496
|
}
|
|
492
|
-
const
|
|
493
|
-
function
|
|
494
|
-
return
|
|
497
|
+
const Rt = Kr.crypto;
|
|
498
|
+
function $t(r) {
|
|
499
|
+
return Rt.getRandomValues(r);
|
|
495
500
|
}
|
|
496
|
-
function
|
|
497
|
-
return
|
|
501
|
+
function _(r = 32) {
|
|
502
|
+
return $t(new Uint8Array(r));
|
|
498
503
|
}
|
|
499
|
-
const
|
|
500
|
-
function
|
|
504
|
+
const Nt = /* @__PURE__ */ Ge(_);
|
|
505
|
+
function Dt(r, e, t = _(24)) {
|
|
501
506
|
return {
|
|
502
|
-
encrypted:
|
|
507
|
+
encrypted: St(r, t, e),
|
|
503
508
|
nonce: t
|
|
504
509
|
};
|
|
505
510
|
}
|
|
506
|
-
const
|
|
511
|
+
const H = {
|
|
507
512
|
N: 32768,
|
|
508
513
|
p: 1,
|
|
509
514
|
r: 8
|
|
510
515
|
};
|
|
511
|
-
function
|
|
516
|
+
function sr(r, e = _(), t = H, n) {
|
|
512
517
|
const o = h(r);
|
|
513
518
|
return {
|
|
514
519
|
params: t,
|
|
515
|
-
password:
|
|
520
|
+
password: jr(o, e, Yr({ dkLen: 64 }, t)),
|
|
516
521
|
salt: e
|
|
517
522
|
};
|
|
518
523
|
}
|
|
519
|
-
const
|
|
520
|
-
function
|
|
521
|
-
const e = r.subarray(0, 32), t =
|
|
522
|
-
if (t !==
|
|
524
|
+
const ee = { isLe: !0 }, re = { bitLength: 32, isLe: !0 }, It = { bitLength: 256, isLe: !0 };
|
|
525
|
+
function ar(r) {
|
|
526
|
+
const e = r.subarray(0, 32), t = Z(r.subarray(32, 36), ee).toNumber(), n = Z(r.subarray(36, 40), ee).toNumber(), o = Z(r.subarray(40, 44), ee).toNumber();
|
|
527
|
+
if (t !== H.N || n !== H.p || o !== H.r)
|
|
523
528
|
throw new Error("Invalid injected scrypt params found");
|
|
524
529
|
return { params: { N: t, p: n, r: o }, salt: e };
|
|
525
530
|
}
|
|
526
|
-
function
|
|
527
|
-
return
|
|
531
|
+
function Pt(r, { N: e, p: t, r: n }) {
|
|
532
|
+
return I(
|
|
533
|
+
r,
|
|
534
|
+
C(e, re),
|
|
535
|
+
C(t, re),
|
|
536
|
+
C(n, re)
|
|
537
|
+
);
|
|
528
538
|
}
|
|
529
|
-
const
|
|
539
|
+
const ye = [
|
|
530
540
|
"scrypt",
|
|
531
541
|
"xsalsa20-poly1305"
|
|
532
|
-
],
|
|
533
|
-
function
|
|
542
|
+
], ir = ["none"], cr = "3", le = 24, lr = 32 + 3 * 4;
|
|
543
|
+
function jt(r, e, t = ye) {
|
|
534
544
|
if (!r)
|
|
535
545
|
throw new Error("No encrypted data available to decode");
|
|
536
546
|
if (t.includes("xsalsa20-poly1305") && !e)
|
|
@@ -539,233 +549,129 @@ function en(r, e, t = Je) {
|
|
|
539
549
|
if (e) {
|
|
540
550
|
let o;
|
|
541
551
|
if (t.includes("scrypt")) {
|
|
542
|
-
const { params:
|
|
543
|
-
o =
|
|
552
|
+
const { params: s, salt: i } = ar(r);
|
|
553
|
+
o = sr(e, i, s).password, r = r.subarray(lr);
|
|
544
554
|
} else
|
|
545
|
-
o =
|
|
546
|
-
n =
|
|
555
|
+
o = V(e);
|
|
556
|
+
n = or(
|
|
557
|
+
r.subarray(le),
|
|
558
|
+
r.subarray(0, le),
|
|
559
|
+
Wr(o, 256, !0)
|
|
560
|
+
);
|
|
547
561
|
}
|
|
548
562
|
if (!n)
|
|
549
563
|
throw new Error("Unable to decode using the supplied passphrase");
|
|
550
564
|
return n;
|
|
551
565
|
}
|
|
552
|
-
function
|
|
566
|
+
function Tt(r, e, t) {
|
|
553
567
|
return {
|
|
554
|
-
encoded:
|
|
568
|
+
encoded: er(r),
|
|
555
569
|
encoding: {
|
|
556
570
|
content: e,
|
|
557
|
-
type: t ?
|
|
558
|
-
version:
|
|
571
|
+
type: t ? ye : ir,
|
|
572
|
+
version: cr
|
|
559
573
|
}
|
|
560
574
|
};
|
|
561
575
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
t = arguments[n];
|
|
566
|
-
for (var a in t) Object.prototype.hasOwnProperty.call(t, a) && (e[a] = t[a]);
|
|
567
|
-
}
|
|
568
|
-
return e;
|
|
569
|
-
}, ke.apply(this, arguments);
|
|
570
|
-
};
|
|
571
|
-
function tn(r, e, t, n) {
|
|
572
|
-
function o(a) {
|
|
573
|
-
return a instanceof t ? a : new t(function(s) {
|
|
574
|
-
s(a);
|
|
575
|
-
});
|
|
576
|
-
}
|
|
577
|
-
return new (t || (t = Promise))(function(a, s) {
|
|
578
|
-
function i(u) {
|
|
579
|
-
try {
|
|
580
|
-
c(n.next(u));
|
|
581
|
-
} catch (d) {
|
|
582
|
-
s(d);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
function l(u) {
|
|
586
|
-
try {
|
|
587
|
-
c(n.throw(u));
|
|
588
|
-
} catch (d) {
|
|
589
|
-
s(d);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
function c(u) {
|
|
593
|
-
u.done ? a(u.value) : o(u.value).then(i, l);
|
|
594
|
-
}
|
|
595
|
-
c((n = n.apply(r, e || [])).next());
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
function nn(r, e) {
|
|
599
|
-
var t = { label: 0, sent: function() {
|
|
600
|
-
if (a[0] & 1) throw a[1];
|
|
601
|
-
return a[1];
|
|
602
|
-
}, trys: [], ops: [] }, n, o, a, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
|
|
603
|
-
return s.next = i(0), s.throw = i(1), s.return = i(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() {
|
|
604
|
-
return this;
|
|
605
|
-
}), s;
|
|
606
|
-
function i(c) {
|
|
607
|
-
return function(u) {
|
|
608
|
-
return l([c, u]);
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
function l(c) {
|
|
612
|
-
if (n) throw new TypeError("Generator is already executing.");
|
|
613
|
-
for (; s && (s = 0, c[0] && (t = 0)), t; ) try {
|
|
614
|
-
if (n = 1, o && (a = c[0] & 2 ? o.return : c[0] ? o.throw || ((a = o.return) && a.call(o), 0) : o.next) && !(a = a.call(o, c[1])).done) return a;
|
|
615
|
-
switch (o = 0, a && (c = [c[0] & 2, a.value]), c[0]) {
|
|
616
|
-
case 0:
|
|
617
|
-
case 1:
|
|
618
|
-
a = c;
|
|
619
|
-
break;
|
|
620
|
-
case 4:
|
|
621
|
-
return t.label++, { value: c[1], done: !1 };
|
|
622
|
-
case 5:
|
|
623
|
-
t.label++, o = c[1], c = [0];
|
|
624
|
-
continue;
|
|
625
|
-
case 7:
|
|
626
|
-
c = t.ops.pop(), t.trys.pop();
|
|
627
|
-
continue;
|
|
628
|
-
default:
|
|
629
|
-
if (a = t.trys, !(a = a.length > 0 && a[a.length - 1]) && (c[0] === 6 || c[0] === 2)) {
|
|
630
|
-
t = 0;
|
|
631
|
-
continue;
|
|
632
|
-
}
|
|
633
|
-
if (c[0] === 3 && (!a || c[1] > a[0] && c[1] < a[3])) {
|
|
634
|
-
t.label = c[1];
|
|
635
|
-
break;
|
|
636
|
-
}
|
|
637
|
-
if (c[0] === 6 && t.label < a[1]) {
|
|
638
|
-
t.label = a[1], a = c;
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
641
|
-
if (a && t.label < a[2]) {
|
|
642
|
-
t.label = a[2], t.ops.push(c);
|
|
643
|
-
break;
|
|
644
|
-
}
|
|
645
|
-
a[2] && t.ops.pop(), t.trys.pop();
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
c = e.call(r, t);
|
|
649
|
-
} catch (u) {
|
|
650
|
-
c = [6, u], o = 0;
|
|
651
|
-
} finally {
|
|
652
|
-
n = a = 0;
|
|
653
|
-
}
|
|
654
|
-
if (c[0] & 5) throw c[1];
|
|
655
|
-
return { value: c[0] ? c[1] : void 0, done: !0 };
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
function on(r, e, t) {
|
|
659
|
-
if (t || arguments.length === 2) for (var n = 0, o = e.length, a; n < o; n++)
|
|
660
|
-
(a || !(n in e)) && (a || (a = Array.prototype.slice.call(e, 0, n)), a[n] = e[n]);
|
|
661
|
-
return r.concat(a || Array.prototype.slice.call(e));
|
|
662
|
-
}
|
|
663
|
-
function _(r, e, t, n) {
|
|
664
|
-
if (t === "a" && !n) throw new TypeError("Private accessor was defined without a getter");
|
|
665
|
-
if (typeof e == "function" ? r !== e || !n : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
666
|
-
return t === "m" ? n : t === "a" ? n.call(r) : n ? n.value : e.get(r);
|
|
667
|
-
}
|
|
668
|
-
function Ee(r, e, t, n, o) {
|
|
669
|
-
if (n === "m") throw new TypeError("Private method is not writable");
|
|
670
|
-
if (n === "a" && !o) throw new TypeError("Private accessor was defined without a setter");
|
|
671
|
-
if (typeof e == "function" ? r !== e || !o : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
672
|
-
return n === "a" ? o.call(r, t) : o ? o.value = t : e.set(r, t), t;
|
|
673
|
-
}
|
|
674
|
-
var $, k;
|
|
675
|
-
const mt = /^\d+$/, wt = 32;
|
|
676
|
-
class he {
|
|
576
|
+
const _t = /^\d+$/, zt = 32;
|
|
577
|
+
var A, v;
|
|
578
|
+
const ke = class ke {
|
|
677
579
|
constructor() {
|
|
678
|
-
|
|
580
|
+
W(this, A, new Uint8Array(32));
|
|
581
|
+
W(this, v, !1);
|
|
679
582
|
}
|
|
680
583
|
static from(e) {
|
|
681
|
-
const t = new
|
|
682
|
-
return t.soft(
|
|
584
|
+
const t = new ke(), [n, o] = e.startsWith("/") ? [e.substring(1), !0] : [e, !1];
|
|
585
|
+
return t.soft(_t.test(n) ? new nt(n, 10) : n), o ? t.harden() : t;
|
|
683
586
|
}
|
|
684
587
|
get chainCode() {
|
|
685
|
-
return
|
|
588
|
+
return k(this, A);
|
|
686
589
|
}
|
|
687
590
|
get isHard() {
|
|
688
|
-
return
|
|
591
|
+
return k(this, v);
|
|
689
592
|
}
|
|
690
593
|
get isSoft() {
|
|
691
|
-
return !
|
|
594
|
+
return !k(this, v);
|
|
692
595
|
}
|
|
693
596
|
hard(e) {
|
|
694
597
|
return this.soft(e).harden();
|
|
695
598
|
}
|
|
696
599
|
harden() {
|
|
697
|
-
return
|
|
600
|
+
return J(this, v, !0), this;
|
|
698
601
|
}
|
|
699
602
|
soft(e) {
|
|
700
|
-
return
|
|
603
|
+
return Jr(e) || Zr(e) || Gr(e) ? this.soft(C(e, It)) : Ce(e) ? this.soft(Xr(e)) : Qr(e) ? this.soft(et(V(e))) : e.length > zt ? this.soft(K(e)) : (k(this, A).fill(0), k(this, A).set(e, 0), this);
|
|
701
604
|
}
|
|
702
605
|
soften() {
|
|
703
|
-
return
|
|
606
|
+
return J(this, v, !1), this;
|
|
704
607
|
}
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
608
|
+
};
|
|
609
|
+
A = new WeakMap(), v = new WeakMap();
|
|
610
|
+
let ue = ke;
|
|
611
|
+
const Ct = /\/(\/?)([^/]+)/g;
|
|
612
|
+
function ur(r) {
|
|
613
|
+
const e = r.match(Ct), t = [];
|
|
710
614
|
let n = "";
|
|
711
615
|
if (e) {
|
|
712
616
|
n = e.join("");
|
|
713
617
|
for (const o of e)
|
|
714
|
-
t.push(
|
|
618
|
+
t.push(ue.from(o.substring(1)));
|
|
715
619
|
}
|
|
716
620
|
if (n !== r)
|
|
717
|
-
throw new Error(
|
|
621
|
+
throw new Error(
|
|
622
|
+
`Re-constructed path "${n}" does not match input`
|
|
623
|
+
);
|
|
718
624
|
return {
|
|
719
625
|
parts: e,
|
|
720
626
|
path: t
|
|
721
627
|
};
|
|
722
628
|
}
|
|
723
|
-
const
|
|
724
|
-
function
|
|
725
|
-
const e = r.match(
|
|
629
|
+
const Lt = /^(\w+( \w+)*)((\/\/?[^/]+)*)(\/\/\/(.*))?$/;
|
|
630
|
+
function Ht(r) {
|
|
631
|
+
const e = r.match(Lt);
|
|
726
632
|
if (e === null)
|
|
727
633
|
throw new Error("Unable to match provided value to a secret URI");
|
|
728
634
|
const [, t, , n, , , o] = e;
|
|
729
635
|
if (!t)
|
|
730
636
|
throw new Error("Unable to extract phrase from provided value");
|
|
731
|
-
const { path:
|
|
637
|
+
const { path: s } = ur(n || "");
|
|
732
638
|
return {
|
|
733
639
|
derivePath: n || "",
|
|
734
640
|
password: o,
|
|
735
|
-
path:
|
|
641
|
+
path: s,
|
|
736
642
|
phrase: t
|
|
737
643
|
};
|
|
738
644
|
}
|
|
739
|
-
const
|
|
740
|
-
function
|
|
645
|
+
const dr = BigInt(0), hr = BigInt(3);
|
|
646
|
+
function te(r) {
|
|
741
647
|
if (typeof r == "string")
|
|
742
|
-
return
|
|
743
|
-
if (
|
|
648
|
+
return he(r);
|
|
649
|
+
if (Te(r))
|
|
744
650
|
return r;
|
|
745
651
|
throw new Error("Wrong data");
|
|
746
652
|
}
|
|
747
653
|
function f(r, e, ...t) {
|
|
748
|
-
if (!
|
|
654
|
+
if (!Te(e))
|
|
749
655
|
throw new Error(`${r}: Uint8Array expected`);
|
|
750
656
|
if (t.length && !t.includes(e.length))
|
|
751
657
|
throw new Error(`${r}: Uint8Array expected of length ${t}, not of length=${e.length}`);
|
|
752
658
|
}
|
|
753
|
-
function
|
|
659
|
+
function q(r, e) {
|
|
754
660
|
if (!Number.isSafeInteger(e) || e < 0 || e > 4294967295)
|
|
755
661
|
throw new Error(`${r}: wrong u32 integer: ${e}`);
|
|
756
662
|
return e;
|
|
757
663
|
}
|
|
758
|
-
function
|
|
664
|
+
function B(...r) {
|
|
759
665
|
for (const e of r)
|
|
760
666
|
e.fill(0);
|
|
761
667
|
}
|
|
762
|
-
const
|
|
763
|
-
function
|
|
668
|
+
const x = Uint8Array.of(), we = zr.CURVE.n;
|
|
669
|
+
function Re(r, e) {
|
|
764
670
|
f(r, e, 32);
|
|
765
|
-
const t =
|
|
766
|
-
return
|
|
671
|
+
const t = S(e);
|
|
672
|
+
return _e(r, t, dr, we), t;
|
|
767
673
|
}
|
|
768
|
-
const
|
|
674
|
+
const j = (r) => _r(r, we), N = 166, m = {
|
|
769
675
|
I: 1,
|
|
770
676
|
A: 2,
|
|
771
677
|
C: 4,
|
|
@@ -773,31 +679,31 @@ const P = (r) => Sr(r, fe), R = 166, y = {
|
|
|
773
679
|
M: 16,
|
|
774
680
|
K: 32
|
|
775
681
|
};
|
|
776
|
-
class
|
|
682
|
+
class be {
|
|
777
683
|
constructor(e) {
|
|
778
|
-
this.state = new Uint8Array(200), this.pos = 0, this.posBegin = 0, this.curFlags = 0, this.state.set([1,
|
|
684
|
+
this.state = new Uint8Array(200), this.pos = 0, this.posBegin = 0, this.curFlags = 0, this.state.set([1, N + 2, 1, 0, 1, 96], 0), this.state.set(he("STROBEv1.0.2"), 6), this.state32 = Cr(this.state), this.keccakF1600(), this.metaAD(e, !1);
|
|
779
685
|
}
|
|
780
686
|
keccakF1600() {
|
|
781
|
-
|
|
687
|
+
Lr(this.state32);
|
|
782
688
|
}
|
|
783
689
|
runF() {
|
|
784
|
-
this.state[this.pos] ^= this.posBegin, this.state[this.pos + 1] ^= 4, this.state[
|
|
690
|
+
this.state[this.pos] ^= this.posBegin, this.state[this.pos + 1] ^= 4, this.state[N + 1] ^= 128, this.keccakF1600(), this.pos = 0, this.posBegin = 0;
|
|
785
691
|
}
|
|
786
692
|
// keccak.update()
|
|
787
693
|
absorb(e) {
|
|
788
694
|
for (let t = 0; t < e.length; t++)
|
|
789
|
-
this.state[this.pos++] ^= e[t], this.pos ===
|
|
695
|
+
this.state[this.pos++] ^= e[t], this.pos === N && this.runF();
|
|
790
696
|
}
|
|
791
697
|
// keccak.xof()
|
|
792
698
|
squeeze(e) {
|
|
793
699
|
const t = new Uint8Array(e);
|
|
794
700
|
for (let n = 0; n < t.length; n++)
|
|
795
|
-
t[n] = this.state[this.pos], this.state[this.pos++] = 0, this.pos ===
|
|
701
|
+
t[n] = this.state[this.pos], this.state[this.pos++] = 0, this.pos === N && this.runF();
|
|
796
702
|
return t;
|
|
797
703
|
}
|
|
798
704
|
overwrite(e) {
|
|
799
705
|
for (let t = 0; t < e.length; t++)
|
|
800
|
-
this.state[this.pos++] = e[t], this.pos ===
|
|
706
|
+
this.state[this.pos++] = e[t], this.pos === N && this.runF();
|
|
801
707
|
}
|
|
802
708
|
beginOp(e, t) {
|
|
803
709
|
if (t) {
|
|
@@ -805,49 +711,49 @@ class pe {
|
|
|
805
711
|
throw new Error(`Continued op with changed flags from ${this.curFlags.toString(2)} to ${e.toString(2)}`);
|
|
806
712
|
return;
|
|
807
713
|
}
|
|
808
|
-
if ((e &
|
|
714
|
+
if ((e & m.T) !== 0)
|
|
809
715
|
throw new Error("T flag is not supported");
|
|
810
716
|
const n = this.posBegin;
|
|
811
|
-
this.posBegin = this.pos + 1, this.curFlags = e, this.absorb(new Uint8Array([n, e])), (e & (
|
|
717
|
+
this.posBegin = this.pos + 1, this.curFlags = e, this.absorb(new Uint8Array([n, e])), (e & (m.C | m.K)) !== 0 && this.pos !== 0 && this.runF();
|
|
812
718
|
}
|
|
813
719
|
// Public API
|
|
814
720
|
metaAD(e, t) {
|
|
815
|
-
this.beginOp(
|
|
721
|
+
this.beginOp(m.M | m.A, t), this.absorb(te(e));
|
|
816
722
|
}
|
|
817
723
|
AD(e, t) {
|
|
818
|
-
this.beginOp(
|
|
724
|
+
this.beginOp(m.A, t), this.absorb(te(e));
|
|
819
725
|
}
|
|
820
726
|
PRF(e, t) {
|
|
821
|
-
return this.beginOp(
|
|
727
|
+
return this.beginOp(m.I | m.A | m.C, t), this.squeeze(e);
|
|
822
728
|
}
|
|
823
729
|
KEY(e, t) {
|
|
824
|
-
this.beginOp(
|
|
730
|
+
this.beginOp(m.A | m.C, t), this.overwrite(te(e));
|
|
825
731
|
}
|
|
826
732
|
// Utils
|
|
827
733
|
clone() {
|
|
828
|
-
const e = new
|
|
734
|
+
const e = new be("0");
|
|
829
735
|
return e.pos = this.pos, e.posBegin = this.posBegin, e.state.set(this.state), e.curFlags = this.curFlags, e;
|
|
830
736
|
}
|
|
831
737
|
clean() {
|
|
832
738
|
this.state.fill(0), this.pos = 0, this.curFlags = 0, this.posBegin = 0;
|
|
833
739
|
}
|
|
834
740
|
}
|
|
835
|
-
class
|
|
741
|
+
class Ot {
|
|
836
742
|
constructor(e) {
|
|
837
|
-
this.strobe = new
|
|
743
|
+
this.strobe = new be("Merlin v1.0"), this.appendMessage("dom-sep", e);
|
|
838
744
|
}
|
|
839
745
|
appendMessage(e, t) {
|
|
840
|
-
this.strobe.metaAD(e, !1),
|
|
746
|
+
this.strobe.metaAD(e, !1), q("Merlin.appendMessage", t.length), this.strobe.metaAD(y(t.length, 4), !0), this.strobe.AD(t, !1);
|
|
841
747
|
}
|
|
842
748
|
challengeBytes(e, t) {
|
|
843
|
-
return this.strobe.metaAD(e, !1),
|
|
749
|
+
return this.strobe.metaAD(e, !1), q("Merlin.challengeBytes", t), this.strobe.metaAD(y(t, 4), !0), this.strobe.PRF(t, !1);
|
|
844
750
|
}
|
|
845
751
|
clean() {
|
|
846
752
|
this.strobe.clean();
|
|
847
753
|
}
|
|
848
754
|
}
|
|
849
|
-
class
|
|
850
|
-
constructor(e, t =
|
|
755
|
+
class R extends Ot {
|
|
756
|
+
constructor(e, t = U) {
|
|
851
757
|
super(e), this.rng = t;
|
|
852
758
|
}
|
|
853
759
|
label(e) {
|
|
@@ -863,149 +769,151 @@ class S extends Et {
|
|
|
863
769
|
this.appendMessage(e, t.toRawBytes());
|
|
864
770
|
}
|
|
865
771
|
challengeScalar(e) {
|
|
866
|
-
return
|
|
772
|
+
return j(S(this.challengeBytes(e, 64)));
|
|
867
773
|
}
|
|
868
774
|
witnessScalar(e, t = []) {
|
|
869
|
-
return
|
|
775
|
+
return j(S(this.witnessBytes(e, 64, t)));
|
|
870
776
|
}
|
|
871
777
|
witnessBytes(e, t, n = []) {
|
|
872
|
-
|
|
778
|
+
q("SigningContext.witnessBytes", t);
|
|
873
779
|
const o = this.strobe.clone();
|
|
874
|
-
for (const
|
|
875
|
-
o.metaAD(e, !1),
|
|
876
|
-
const
|
|
877
|
-
return o.metaAD("rng", !1), o.KEY(
|
|
780
|
+
for (const i of n)
|
|
781
|
+
o.metaAD(e, !1), q("SigningContext.witnessBytes nonce length", i.length), o.metaAD(y(i.length, 4), !0), o.KEY(i, !1);
|
|
782
|
+
const s = this.rng(32);
|
|
783
|
+
return o.metaAD("rng", !1), o.KEY(s, !1), o.metaAD(y(t, 4), !1), o.PRF(t, !1);
|
|
878
784
|
}
|
|
879
785
|
}
|
|
880
|
-
const
|
|
881
|
-
function
|
|
786
|
+
const Ft = Hr(256), fr = (r) => y(r << hr & Ft, 32), $ = (r) => S(r) >> hr;
|
|
787
|
+
function Y(r) {
|
|
882
788
|
f("secretKey", r, 64);
|
|
883
|
-
const e =
|
|
789
|
+
const e = $(r.subarray(0, 32));
|
|
884
790
|
return g.BASE.multiply(e).toRawBytes();
|
|
885
791
|
}
|
|
886
|
-
function
|
|
792
|
+
function pr(r) {
|
|
887
793
|
f("seed", r, 32);
|
|
888
|
-
const e =
|
|
794
|
+
const e = Tr(r);
|
|
889
795
|
e[0] &= 248, e[31] &= 63, e[31] |= 64;
|
|
890
|
-
const t =
|
|
891
|
-
return
|
|
796
|
+
const t = fr($(e.subarray(0, 32))), n = e.subarray(32, 64), o = D(t, n);
|
|
797
|
+
return B(t, n, e), o;
|
|
892
798
|
}
|
|
893
|
-
const
|
|
894
|
-
function
|
|
799
|
+
const gr = he("substrate");
|
|
800
|
+
function Mt(r, e, t = U) {
|
|
895
801
|
f("message", e), f("secretKey", r, 64);
|
|
896
|
-
const n = new
|
|
897
|
-
n.label(
|
|
898
|
-
const o =
|
|
899
|
-
n.protoName("Schnorr-sig"), n.commitPoint("sign:pk",
|
|
900
|
-
const
|
|
802
|
+
const n = new R("SigningContext", t);
|
|
803
|
+
n.label(gr), n.bytes(e);
|
|
804
|
+
const o = $(r.subarray(0, 32)), s = r.subarray(32, 64), i = g.fromHex(Y(r));
|
|
805
|
+
n.protoName("Schnorr-sig"), n.commitPoint("sign:pk", i);
|
|
806
|
+
const a = n.witnessScalar("signing", [s]), l = g.BASE.multiply(a);
|
|
901
807
|
n.commitPoint("sign:R", l);
|
|
902
|
-
const c = n.challengeScalar("sign:c"), u =
|
|
808
|
+
const c = n.challengeScalar("sign:c"), u = j(c * o + a), d = D(l.toRawBytes(), y(u, 32));
|
|
903
809
|
return d[63] |= 128, n.clean(), d;
|
|
904
810
|
}
|
|
905
|
-
function
|
|
811
|
+
function qt(r, e, t) {
|
|
906
812
|
if (f("message", r), f("signature", e, 64), f("publicKey", t, 32), (e[63] & 128) === 0)
|
|
907
813
|
throw new Error("Schnorrkel marker missing");
|
|
908
814
|
const n = Uint8Array.from(e.subarray(32, 64));
|
|
909
815
|
n[31] &= 127;
|
|
910
|
-
const o = g.fromHex(e.subarray(0, 32)),
|
|
911
|
-
|
|
912
|
-
const
|
|
913
|
-
|
|
914
|
-
const
|
|
915
|
-
if (
|
|
816
|
+
const o = g.fromHex(e.subarray(0, 32)), s = S(n);
|
|
817
|
+
_e("s", s, dr, we);
|
|
818
|
+
const i = new R("SigningContext");
|
|
819
|
+
i.label(gr), i.bytes(r);
|
|
820
|
+
const a = g.fromHex(t);
|
|
821
|
+
if (a.equals(g.ZERO))
|
|
916
822
|
return !1;
|
|
917
|
-
|
|
918
|
-
const l =
|
|
919
|
-
return
|
|
823
|
+
i.protoName("Schnorr-sig"), i.commitPoint("sign:pk", a), i.commitPoint("sign:R", o);
|
|
824
|
+
const l = i.challengeScalar("sign:c"), c = g.BASE.multiply(s), u = a.negate().multiply(l).add(c);
|
|
825
|
+
return i.clean(), B(n), u.equals(o);
|
|
920
826
|
}
|
|
921
|
-
const
|
|
922
|
-
secretSoft(r, e, t =
|
|
827
|
+
const mr = {
|
|
828
|
+
secretSoft(r, e, t = U) {
|
|
923
829
|
f("secretKey", r, 64), f("chainCode", e, 32);
|
|
924
|
-
const n =
|
|
925
|
-
|
|
926
|
-
const
|
|
927
|
-
return
|
|
830
|
+
const n = $(r.subarray(0, 32)), o = r.subarray(32, 64), s = g.fromHex(Y(r)), i = new R("SchnorrRistrettoHDKD", t);
|
|
831
|
+
i.bytes(x), i.appendMessage("chain-code", e), i.commitPoint("public-key", s);
|
|
832
|
+
const a = i.challengeScalar("HDKD-scalar"), l = i.challengeBytes("HDKD-chaincode", 32), c = D(y(n, 32), o), u = i.witnessBytes("HDKD-nonce", 32, [o, c]), d = fr(j(n + a)), p = D(d, u);
|
|
833
|
+
return B(d, u, c, l), i.clean(), p;
|
|
928
834
|
},
|
|
929
835
|
secretHard(r, e) {
|
|
930
836
|
f("secretKey", r, 64), f("chainCode", e, 32);
|
|
931
|
-
const t =
|
|
932
|
-
n.bytes(
|
|
933
|
-
const o = n.challengeBytes("HDKD-hard", 32),
|
|
837
|
+
const t = y($(r.subarray(0, 32)), 32), n = new R("SchnorrRistrettoHDKD");
|
|
838
|
+
n.bytes(x), n.appendMessage("chain-code", e), n.appendMessage("secret-key", t);
|
|
839
|
+
const o = n.challengeBytes("HDKD-hard", 32), s = n.challengeBytes("HDKD-chaincode", 32);
|
|
934
840
|
n.clean();
|
|
935
|
-
const
|
|
936
|
-
return
|
|
841
|
+
const i = pr(o);
|
|
842
|
+
return B(t, o, s), n.clean(), i;
|
|
937
843
|
}
|
|
938
|
-
},
|
|
939
|
-
proove(r, e, t, n, o,
|
|
844
|
+
}, $e = {
|
|
845
|
+
proove(r, e, t, n, o, s) {
|
|
940
846
|
n.protoName("DLEQProof"), n.commitPoint("vrf:h", o);
|
|
941
|
-
const
|
|
942
|
-
n.commitPoint("vrf:R=g^r",
|
|
943
|
-
const l = o.multiply(
|
|
944
|
-
n.commitPoint("vrf:h^r", l), n.commitPoint("vrf:pk", t), n.commitPoint("vrf:h^sk",
|
|
945
|
-
const c = n.challengeScalar("prove"), u =
|
|
946
|
-
return { proof: { c, s: u }, proofBatchable: { R:
|
|
847
|
+
const i = n.witnessScalar("proving\x000", [e]), a = g.BASE.multiply(i);
|
|
848
|
+
n.commitPoint("vrf:R=g^r", a);
|
|
849
|
+
const l = o.multiply(i);
|
|
850
|
+
n.commitPoint("vrf:h^r", l), n.commitPoint("vrf:pk", t), n.commitPoint("vrf:h^sk", s);
|
|
851
|
+
const c = n.challengeScalar("prove"), u = j(i - c * r);
|
|
852
|
+
return { proof: { c, s: u }, proofBatchable: { R: a, Hr: l, s: u } };
|
|
947
853
|
},
|
|
948
854
|
verify(r, e, t, n, o) {
|
|
949
855
|
if (r.equals(g.ZERO))
|
|
950
856
|
return !1;
|
|
951
857
|
e.protoName("DLEQProof"), e.commitPoint("vrf:h", t);
|
|
952
|
-
const
|
|
953
|
-
e.commitPoint("vrf:R=g^r",
|
|
954
|
-
const
|
|
955
|
-
e.commitPoint("vrf:h^r",
|
|
956
|
-
const
|
|
957
|
-
return o.c ===
|
|
858
|
+
const s = r.multiply(o.c).add(g.BASE.multiply(o.s));
|
|
859
|
+
e.commitPoint("vrf:R=g^r", s);
|
|
860
|
+
const i = n.multiply(o.c).add(t.multiply(o.s));
|
|
861
|
+
e.commitPoint("vrf:h^r", i), e.commitPoint("vrf:pk", r), e.commitPoint("vrf:h^sk", n);
|
|
862
|
+
const a = e.challengeScalar("prove");
|
|
863
|
+
return o.c === a ? { R: s, Hr: i, s: o.s } : !1;
|
|
958
864
|
}
|
|
959
865
|
};
|
|
960
|
-
function
|
|
961
|
-
const
|
|
962
|
-
|
|
963
|
-
const
|
|
964
|
-
return t.length && l.label(t),
|
|
965
|
-
}
|
|
966
|
-
const
|
|
967
|
-
sign(r, e, t =
|
|
866
|
+
function Ne(r, e, t, n, o = U) {
|
|
867
|
+
const s = new R("SigningContext", o);
|
|
868
|
+
s.label(r), s.bytes(e), s.commitPoint("vrf-nm-pk", n);
|
|
869
|
+
const i = s.challengeBytes("VRFHash", 64), a = g.hashToCurve(i), l = new R("VRF", o);
|
|
870
|
+
return t.length && l.label(t), s.clean(), B(i), { input: a, t: l };
|
|
871
|
+
}
|
|
872
|
+
const yr = {
|
|
873
|
+
sign(r, e, t = x, n = x, o = U) {
|
|
968
874
|
f("msg", r), f("secretKey", e, 64), f("ctx", t), f("extra", n);
|
|
969
|
-
const
|
|
970
|
-
return
|
|
875
|
+
const s = $(e.subarray(0, 32)), i = e.subarray(32, 64), a = g.fromHex(Y(e)), { input: l, t: c } = Ne(t, r, n, a, o), u = l.multiply(s), d = { output: u }, { proof: p } = $e.proove(s, i, a, c, l, u), b = y(p.c, 32), w = y(p.s, 32), Pr = D(d.output.toRawBytes(), b, w);
|
|
876
|
+
return B(i, b, w), Pr;
|
|
971
877
|
},
|
|
972
|
-
verify(r, e, t, n =
|
|
878
|
+
verify(r, e, t, n = x, o = x, s = U) {
|
|
973
879
|
f("msg", r), f("signature", e, 96), f("pubkey", t, 32), f("ctx", n), f("extra", o);
|
|
974
|
-
const
|
|
975
|
-
if (
|
|
880
|
+
const i = g.fromHex(t);
|
|
881
|
+
if (i.equals(g.ZERO))
|
|
976
882
|
return !1;
|
|
977
|
-
const
|
|
978
|
-
c:
|
|
979
|
-
s:
|
|
980
|
-
}, { input: l, t: c } =
|
|
883
|
+
const a = {
|
|
884
|
+
c: Re("signature.c", e.subarray(32, 64)),
|
|
885
|
+
s: Re("signature.s", e.subarray(64, 96))
|
|
886
|
+
}, { input: l, t: c } = Ne(n, r, o, i, s), u = g.fromHex(e.subarray(0, 32));
|
|
981
887
|
if (u.equals(g.ZERO))
|
|
982
888
|
throw new Error("vrf.verify: wrong output point (identity)");
|
|
983
|
-
return
|
|
889
|
+
return $e.verify(i, c, l, u, a) !== !1;
|
|
984
890
|
}
|
|
985
|
-
},
|
|
986
|
-
function
|
|
891
|
+
}, de = 64, Vt = 32, ne = de + Vt;
|
|
892
|
+
function Kt(r) {
|
|
987
893
|
const e = h(r);
|
|
988
|
-
if (e.length !==
|
|
989
|
-
throw new Error(
|
|
894
|
+
if (e.length !== ne)
|
|
895
|
+
throw new Error(
|
|
896
|
+
`Expected keypair with ${ne} bytes, found ${e.length}`
|
|
897
|
+
);
|
|
990
898
|
return {
|
|
991
|
-
publicKey: e.slice(
|
|
992
|
-
secretKey: e.slice(0,
|
|
899
|
+
publicKey: e.slice(de, ne),
|
|
900
|
+
secretKey: e.slice(0, de)
|
|
993
901
|
};
|
|
994
902
|
}
|
|
995
|
-
function
|
|
903
|
+
function wr(r) {
|
|
996
904
|
return (e, t) => {
|
|
997
|
-
if (
|
|
905
|
+
if (!ze(t) || t.length !== 32)
|
|
998
906
|
throw new Error("Invalid chainCode passed to derive");
|
|
999
|
-
const n = r(e.secretKey, t), o =
|
|
1000
|
-
return
|
|
907
|
+
const n = r(e.secretKey, t), o = Y(n);
|
|
908
|
+
return Kt(I(n, o));
|
|
1001
909
|
};
|
|
1002
910
|
}
|
|
1003
|
-
const
|
|
1004
|
-
function
|
|
1005
|
-
return t ?
|
|
911
|
+
const br = /* @__PURE__ */ wr(mr.secretHard), vr = /* @__PURE__ */ wr(mr.secretSoft);
|
|
912
|
+
function kr(r, { chainCode: e, isSoft: t }) {
|
|
913
|
+
return t ? vr(r, e) : br(r, e);
|
|
1006
914
|
}
|
|
1007
|
-
const
|
|
1008
|
-
sr25519:
|
|
915
|
+
const De = {
|
|
916
|
+
sr25519: kr,
|
|
1009
917
|
ecdsa: () => {
|
|
1010
918
|
throw new Error("ECDSA key derivation not implemented yet");
|
|
1011
919
|
},
|
|
@@ -1016,103 +924,108 @@ const Se = {
|
|
|
1016
924
|
throw new Error("Ethereum key derivation not implemented yet");
|
|
1017
925
|
}
|
|
1018
926
|
};
|
|
1019
|
-
function
|
|
927
|
+
function Yt(r, e, t) {
|
|
1020
928
|
if (!t)
|
|
1021
929
|
throw new Error("Invalid type provided");
|
|
1022
|
-
if (!
|
|
930
|
+
if (!De[t])
|
|
1023
931
|
throw new Error(`Unsupported keypair type: ${t}`);
|
|
1024
|
-
const n =
|
|
932
|
+
const n = De[t];
|
|
1025
933
|
let o = r;
|
|
1026
|
-
for (const
|
|
1027
|
-
o = n(o,
|
|
934
|
+
for (const s of e)
|
|
935
|
+
o = n(o, s);
|
|
1028
936
|
return o;
|
|
1029
937
|
}
|
|
1030
|
-
function
|
|
1031
|
-
const o = h(r),
|
|
938
|
+
function Er(r, e = _(), t = 2048, n) {
|
|
939
|
+
const o = h(r), s = h(e);
|
|
1032
940
|
return {
|
|
1033
|
-
password:
|
|
941
|
+
password: Or(Fr, o, s, { c: t, dkLen: 64 }),
|
|
1034
942
|
rounds: t,
|
|
1035
943
|
salt: e
|
|
1036
944
|
};
|
|
1037
945
|
}
|
|
1038
|
-
const It = { 256: Nr }, Nt = It[256], or = "abandon|ability|able|about|above|absent|absorb|abstract|absurd|abuse|access|accident|account|accuse|achieve|acid|acoustic|acquire|across|act|action|actor|actress|actual|adapt|add|addict|address|adjust|admit|adult|advance|advice|aerobic|affair|afford|afraid|again|age|agent|agree|ahead|aim|air|airport|aisle|alarm|album|alcohol|alert|alien|all|alley|allow|almost|alone|alpha|already|also|alter|always|amateur|amazing|among|amount|amused|analyst|anchor|ancient|anger|angle|angry|animal|ankle|announce|annual|another|answer|antenna|antique|anxiety|any|apart|apology|appear|apple|approve|april|arch|arctic|area|arena|argue|arm|armed|armor|army|around|arrange|arrest|arrive|arrow|art|artefact|artist|artwork|ask|aspect|assault|asset|assist|assume|asthma|athlete|atom|attack|attend|attitude|attract|auction|audit|august|aunt|author|auto|autumn|average|avocado|avoid|awake|aware|away|awesome|awful|awkward|axis|baby|bachelor|bacon|badge|bag|balance|balcony|ball|bamboo|banana|banner|bar|barely|bargain|barrel|base|basic|basket|battle|beach|bean|beauty|because|become|beef|before|begin|behave|behind|believe|below|belt|bench|benefit|best|betray|better|between|beyond|bicycle|bid|bike|bind|biology|bird|birth|bitter|black|blade|blame|blanket|blast|bleak|bless|blind|blood|blossom|blouse|blue|blur|blush|board|boat|body|boil|bomb|bone|bonus|book|boost|border|boring|borrow|boss|bottom|bounce|box|boy|bracket|brain|brand|brass|brave|bread|breeze|brick|bridge|brief|bright|bring|brisk|broccoli|broken|bronze|broom|brother|brown|brush|bubble|buddy|budget|buffalo|build|bulb|bulk|bullet|bundle|bunker|burden|burger|burst|bus|business|busy|butter|buyer|buzz|cabbage|cabin|cable|cactus|cage|cake|call|calm|camera|camp|can|canal|cancel|candy|cannon|canoe|canvas|canyon|capable|capital|captain|car|carbon|card|cargo|carpet|carry|cart|case|cash|casino|castle|casual|cat|catalog|catch|category|cattle|caught|cause|caution|cave|ceiling|celery|cement|census|century|cereal|certain|chair|chalk|champion|change|chaos|chapter|charge|chase|chat|cheap|check|cheese|chef|cherry|chest|chicken|chief|child|chimney|choice|choose|chronic|chuckle|chunk|churn|cigar|cinnamon|circle|citizen|city|civil|claim|clap|clarify|claw|clay|clean|clerk|clever|click|client|cliff|climb|clinic|clip|clock|clog|close|cloth|cloud|clown|club|clump|cluster|clutch|coach|coast|coconut|code|coffee|coil|coin|collect|color|column|combine|come|comfort|comic|common|company|concert|conduct|confirm|congress|connect|consider|control|convince|cook|cool|copper|copy|coral|core|corn|correct|cost|cotton|couch|country|couple|course|cousin|cover|coyote|crack|cradle|craft|cram|crane|crash|crater|crawl|crazy|cream|credit|creek|crew|cricket|crime|crisp|critic|crop|cross|crouch|crowd|crucial|cruel|cruise|crumble|crunch|crush|cry|crystal|cube|culture|cup|cupboard|curious|current|curtain|curve|cushion|custom|cute|cycle|dad|damage|damp|dance|danger|daring|dash|daughter|dawn|day|deal|debate|debris|decade|december|decide|decline|decorate|decrease|deer|defense|define|defy|degree|delay|deliver|demand|demise|denial|dentist|deny|depart|depend|deposit|depth|deputy|derive|describe|desert|design|desk|despair|destroy|detail|detect|develop|device|devote|diagram|dial|diamond|diary|dice|diesel|diet|differ|digital|dignity|dilemma|dinner|dinosaur|direct|dirt|disagree|discover|disease|dish|dismiss|disorder|display|distance|divert|divide|divorce|dizzy|doctor|document|dog|doll|dolphin|domain|donate|donkey|donor|door|dose|double|dove|draft|dragon|drama|drastic|draw|dream|dress|drift|drill|drink|drip|drive|drop|drum|dry|duck|dumb|dune|during|dust|dutch|duty|dwarf|dynamic|eager|eagle|early|earn|earth|easily|east|easy|echo|ecology|economy|edge|edit|educate|effort|egg|eight|either|elbow|elder|electric|elegant|element|elephant|elevator|elite|else|embark|embody|embrace|emerge|emotion|employ|empower|empty|enable|enact|end|endless|endorse|enemy|energy|enforce|engage|engine|enhance|enjoy|enlist|enough|enrich|enroll|ensure|enter|entire|entry|envelope|episode|equal|equip|era|erase|erode|erosion|error|erupt|escape|essay|essence|estate|eternal|ethics|evidence|evil|evoke|evolve|exact|example|excess|exchange|excite|exclude|excuse|execute|exercise|exhaust|exhibit|exile|exist|exit|exotic|expand|expect|expire|explain|expose|express|extend|extra|eye|eyebrow|fabric|face|faculty|fade|faint|faith|fall|false|fame|family|famous|fan|fancy|fantasy|farm|fashion|fat|fatal|father|fatigue|fault|favorite|feature|february|federal|fee|feed|feel|female|fence|festival|fetch|fever|few|fiber|fiction|field|figure|file|film|filter|final|find|fine|finger|finish|fire|firm|first|fiscal|fish|fit|fitness|fix|flag|flame|flash|flat|flavor|flee|flight|flip|float|flock|floor|flower|fluid|flush|fly|foam|focus|fog|foil|fold|follow|food|foot|force|forest|forget|fork|fortune|forum|forward|fossil|foster|found|fox|fragile|frame|frequent|fresh|friend|fringe|frog|front|frost|frown|frozen|fruit|fuel|fun|funny|furnace|fury|future|gadget|gain|galaxy|gallery|game|gap|garage|garbage|garden|garlic|garment|gas|gasp|gate|gather|gauge|gaze|general|genius|genre|gentle|genuine|gesture|ghost|giant|gift|giggle|ginger|giraffe|girl|give|glad|glance|glare|glass|glide|glimpse|globe|gloom|glory|glove|glow|glue|goat|goddess|gold|good|goose|gorilla|gospel|gossip|govern|gown|grab|grace|grain|grant|grape|grass|gravity|great|green|grid|grief|grit|grocery|group|grow|grunt|guard|guess|guide|guilt|guitar|gun|gym|habit|hair|half|hammer|hamster|hand|happy|harbor|hard|harsh|harvest|hat|have|hawk|hazard|head|health|heart|heavy|hedgehog|height|hello|helmet|help|hen|hero|hidden|high|hill|hint|hip|hire|history|hobby|hockey|hold|hole|holiday|hollow|home|honey|hood|hope|horn|horror|horse|hospital|host|hotel|hour|hover|hub|huge|human|humble|humor|hundred|hungry|hunt|hurdle|hurry|hurt|husband|hybrid|ice|icon|idea|identify|idle|ignore|ill|illegal|illness|image|imitate|immense|immune|impact|impose|improve|impulse|inch|include|income|increase|index|indicate|indoor|industry|infant|inflict|inform|inhale|inherit|initial|inject|injury|inmate|inner|innocent|input|inquiry|insane|insect|inside|inspire|install|intact|interest|into|invest|invite|involve|iron|island|isolate|issue|item|ivory|jacket|jaguar|jar|jazz|jealous|jeans|jelly|jewel|job|join|joke|journey|joy|judge|juice|jump|jungle|junior|junk|just|kangaroo|keen|keep|ketchup|key|kick|kid|kidney|kind|kingdom|kiss|kit|kitchen|kite|kitten|kiwi|knee|knife|knock|know|lab|label|labor|ladder|lady|lake|lamp|language|laptop|large|later|latin|laugh|laundry|lava|law|lawn|lawsuit|layer|lazy|leader|leaf|learn|leave|lecture|left|leg|legal|legend|leisure|lemon|lend|length|lens|leopard|lesson|letter|level|liar|liberty|library|license|life|lift|light|like|limb|limit|link|lion|liquid|list|little|live|lizard|load|loan|lobster|local|lock|logic|lonely|long|loop|lottery|loud|lounge|love|loyal|lucky|luggage|lumber|lunar|lunch|luxury|lyrics|machine|mad|magic|magnet|maid|mail|main|major|make|mammal|man|manage|mandate|mango|mansion|manual|maple|marble|march|margin|marine|market|marriage|mask|mass|master|match|material|math|matrix|matter|maximum|maze|meadow|mean|measure|meat|mechanic|medal|media|melody|melt|member|memory|mention|menu|mercy|merge|merit|merry|mesh|message|metal|method|middle|midnight|milk|million|mimic|mind|minimum|minor|minute|miracle|mirror|misery|miss|mistake|mix|mixed|mixture|mobile|model|modify|mom|moment|monitor|monkey|monster|month|moon|moral|more|morning|mosquito|mother|motion|motor|mountain|mouse|move|movie|much|muffin|mule|multiply|muscle|museum|mushroom|music|must|mutual|myself|mystery|myth|naive|name|napkin|narrow|nasty|nation|nature|near|neck|need|negative|neglect|neither|nephew|nerve|nest|net|network|neutral|never|news|next|nice|night|noble|noise|nominee|noodle|normal|north|nose|notable|note|nothing|notice|novel|now|nuclear|number|nurse|nut|oak|obey|object|oblige|obscure|observe|obtain|obvious|occur|ocean|october|odor|off|offer|office|often|oil|okay|old|olive|olympic|omit|once|one|onion|online|only|open|opera|opinion|oppose|option|orange|orbit|orchard|order|ordinary|organ|orient|original|orphan|ostrich|other|outdoor|outer|output|outside|oval|oven|over|own|owner|oxygen|oyster|ozone|pact|paddle|page|pair|palace|palm|panda|panel|panic|panther|paper|parade|parent|park|parrot|party|pass|patch|path|patient|patrol|pattern|pause|pave|payment|peace|peanut|pear|peasant|pelican|pen|penalty|pencil|people|pepper|perfect|permit|person|pet|phone|photo|phrase|physical|piano|picnic|picture|piece|pig|pigeon|pill|pilot|pink|pioneer|pipe|pistol|pitch|pizza|place|planet|plastic|plate|play|please|pledge|pluck|plug|plunge|poem|poet|point|polar|pole|police|pond|pony|pool|popular|portion|position|possible|post|potato|pottery|poverty|powder|power|practice|praise|predict|prefer|prepare|present|pretty|prevent|price|pride|primary|print|priority|prison|private|prize|problem|process|produce|profit|program|project|promote|proof|property|prosper|protect|proud|provide|public|pudding|pull|pulp|pulse|pumpkin|punch|pupil|puppy|purchase|purity|purpose|purse|push|put|puzzle|pyramid|quality|quantum|quarter|question|quick|quit|quiz|quote|rabbit|raccoon|race|rack|radar|radio|rail|rain|raise|rally|ramp|ranch|random|range|rapid|rare|rate|rather|raven|raw|razor|ready|real|reason|rebel|rebuild|recall|receive|recipe|record|recycle|reduce|reflect|reform|refuse|region|regret|regular|reject|relax|release|relief|rely|remain|remember|remind|remove|render|renew|rent|reopen|repair|repeat|replace|report|require|rescue|resemble|resist|resource|response|result|retire|retreat|return|reunion|reveal|review|reward|rhythm|rib|ribbon|rice|rich|ride|ridge|rifle|right|rigid|ring|riot|ripple|risk|ritual|rival|river|road|roast|robot|robust|rocket|romance|roof|rookie|room|rose|rotate|rough|round|route|royal|rubber|rude|rug|rule|run|runway|rural|sad|saddle|sadness|safe|sail|salad|salmon|salon|salt|salute|same|sample|sand|satisfy|satoshi|sauce|sausage|save|say|scale|scan|scare|scatter|scene|scheme|school|science|scissors|scorpion|scout|scrap|screen|script|scrub|sea|search|season|seat|second|secret|section|security|seed|seek|segment|select|sell|seminar|senior|sense|sentence|series|service|session|settle|setup|seven|shadow|shaft|shallow|share|shed|shell|sheriff|shield|shift|shine|ship|shiver|shock|shoe|shoot|shop|short|shoulder|shove|shrimp|shrug|shuffle|shy|sibling|sick|side|siege|sight|sign|silent|silk|silly|silver|similar|simple|since|sing|siren|sister|situate|six|size|skate|sketch|ski|skill|skin|skirt|skull|slab|slam|sleep|slender|slice|slide|slight|slim|slogan|slot|slow|slush|small|smart|smile|smoke|smooth|snack|snake|snap|sniff|snow|soap|soccer|social|sock|soda|soft|solar|soldier|solid|solution|solve|someone|song|soon|sorry|sort|soul|sound|soup|source|south|space|spare|spatial|spawn|speak|special|speed|spell|spend|sphere|spice|spider|spike|spin|spirit|split|spoil|sponsor|spoon|sport|spot|spray|spread|spring|spy|square|squeeze|squirrel|stable|stadium|staff|stage|stairs|stamp|stand|start|state|stay|steak|steel|stem|step|stereo|stick|still|sting|stock|stomach|stone|stool|story|stove|strategy|street|strike|strong|struggle|student|stuff|stumble|style|subject|submit|subway|success|such|sudden|suffer|sugar|suggest|suit|summer|sun|sunny|sunset|super|supply|supreme|sure|surface|surge|surprise|surround|survey|suspect|sustain|swallow|swamp|swap|swarm|swear|sweet|swift|swim|swing|switch|sword|symbol|symptom|syrup|system|table|tackle|tag|tail|talent|talk|tank|tape|target|task|taste|tattoo|taxi|teach|team|tell|ten|tenant|tennis|tent|term|test|text|thank|that|theme|then|theory|there|they|thing|this|thought|three|thrive|throw|thumb|thunder|ticket|tide|tiger|tilt|timber|time|tiny|tip|tired|tissue|title|toast|tobacco|today|toddler|toe|together|toilet|token|tomato|tomorrow|tone|tongue|tonight|tool|tooth|top|topic|topple|torch|tornado|tortoise|toss|total|tourist|toward|tower|town|toy|track|trade|traffic|tragic|train|transfer|trap|trash|travel|tray|treat|tree|trend|trial|tribe|trick|trigger|trim|trip|trophy|trouble|truck|true|truly|trumpet|trust|truth|try|tube|tuition|tumble|tuna|tunnel|turkey|turn|turtle|twelve|twenty|twice|twin|twist|two|type|typical|ugly|umbrella|unable|unaware|uncle|uncover|under|undo|unfair|unfold|unhappy|uniform|unique|unit|universe|unknown|unlock|until|unusual|unveil|update|upgrade|uphold|upon|upper|upset|urban|urge|usage|use|used|useful|useless|usual|utility|vacant|vacuum|vague|valid|valley|valve|van|vanish|vapor|various|vast|vault|vehicle|velvet|vendor|venture|venue|verb|verify|version|very|vessel|veteran|viable|vibrant|vicious|victory|video|view|village|vintage|violin|virtual|virus|visa|visit|visual|vital|vivid|vocal|voice|void|volcano|volume|vote|voyage|wage|wagon|wait|walk|wall|walnut|want|warfare|warm|warrior|wash|wasp|waste|water|wave|way|wealth|weapon|wear|weasel|weather|web|wedding|weekend|weird|welcome|west|wet|whale|what|wheat|wheel|when|where|whip|whisper|wide|width|wife|wild|will|win|window|wine|wing|wink|winner|winter|wire|wisdom|wise|wish|witness|wolf|woman|wonder|wood|wool|word|work|world|worry|worth|wrap|wreck|wrestle|wrist|write|wrong|yard|year|yellow|you|young|youth|zebra|zero|zone|zoo".split("|"), Be = "Invalid mnemonic", ar = "Invalid entropy", Pt = "Invalid mnemonic checksum";
|
|
1039
|
-
|
|
946
|
+
const xr = { 256: Mr }, Ar = xr[256], Ur = "abandon|ability|able|about|above|absent|absorb|abstract|absurd|abuse|access|accident|account|accuse|achieve|acid|acoustic|acquire|across|act|action|actor|actress|actual|adapt|add|addict|address|adjust|admit|adult|advance|advice|aerobic|affair|afford|afraid|again|age|agent|agree|ahead|aim|air|airport|aisle|alarm|album|alcohol|alert|alien|all|alley|allow|almost|alone|alpha|already|also|alter|always|amateur|amazing|among|amount|amused|analyst|anchor|ancient|anger|angle|angry|animal|ankle|announce|annual|another|answer|antenna|antique|anxiety|any|apart|apology|appear|apple|approve|april|arch|arctic|area|arena|argue|arm|armed|armor|army|around|arrange|arrest|arrive|arrow|art|artefact|artist|artwork|ask|aspect|assault|asset|assist|assume|asthma|athlete|atom|attack|attend|attitude|attract|auction|audit|august|aunt|author|auto|autumn|average|avocado|avoid|awake|aware|away|awesome|awful|awkward|axis|baby|bachelor|bacon|badge|bag|balance|balcony|ball|bamboo|banana|banner|bar|barely|bargain|barrel|base|basic|basket|battle|beach|bean|beauty|because|become|beef|before|begin|behave|behind|believe|below|belt|bench|benefit|best|betray|better|between|beyond|bicycle|bid|bike|bind|biology|bird|birth|bitter|black|blade|blame|blanket|blast|bleak|bless|blind|blood|blossom|blouse|blue|blur|blush|board|boat|body|boil|bomb|bone|bonus|book|boost|border|boring|borrow|boss|bottom|bounce|box|boy|bracket|brain|brand|brass|brave|bread|breeze|brick|bridge|brief|bright|bring|brisk|broccoli|broken|bronze|broom|brother|brown|brush|bubble|buddy|budget|buffalo|build|bulb|bulk|bullet|bundle|bunker|burden|burger|burst|bus|business|busy|butter|buyer|buzz|cabbage|cabin|cable|cactus|cage|cake|call|calm|camera|camp|can|canal|cancel|candy|cannon|canoe|canvas|canyon|capable|capital|captain|car|carbon|card|cargo|carpet|carry|cart|case|cash|casino|castle|casual|cat|catalog|catch|category|cattle|caught|cause|caution|cave|ceiling|celery|cement|census|century|cereal|certain|chair|chalk|champion|change|chaos|chapter|charge|chase|chat|cheap|check|cheese|chef|cherry|chest|chicken|chief|child|chimney|choice|choose|chronic|chuckle|chunk|churn|cigar|cinnamon|circle|citizen|city|civil|claim|clap|clarify|claw|clay|clean|clerk|clever|click|client|cliff|climb|clinic|clip|clock|clog|close|cloth|cloud|clown|club|clump|cluster|clutch|coach|coast|coconut|code|coffee|coil|coin|collect|color|column|combine|come|comfort|comic|common|company|concert|conduct|confirm|congress|connect|consider|control|convince|cook|cool|copper|copy|coral|core|corn|correct|cost|cotton|couch|country|couple|course|cousin|cover|coyote|crack|cradle|craft|cram|crane|crash|crater|crawl|crazy|cream|credit|creek|crew|cricket|crime|crisp|critic|crop|cross|crouch|crowd|crucial|cruel|cruise|crumble|crunch|crush|cry|crystal|cube|culture|cup|cupboard|curious|current|curtain|curve|cushion|custom|cute|cycle|dad|damage|damp|dance|danger|daring|dash|daughter|dawn|day|deal|debate|debris|decade|december|decide|decline|decorate|decrease|deer|defense|define|defy|degree|delay|deliver|demand|demise|denial|dentist|deny|depart|depend|deposit|depth|deputy|derive|describe|desert|design|desk|despair|destroy|detail|detect|develop|device|devote|diagram|dial|diamond|diary|dice|diesel|diet|differ|digital|dignity|dilemma|dinner|dinosaur|direct|dirt|disagree|discover|disease|dish|dismiss|disorder|display|distance|divert|divide|divorce|dizzy|doctor|document|dog|doll|dolphin|domain|donate|donkey|donor|door|dose|double|dove|draft|dragon|drama|drastic|draw|dream|dress|drift|drill|drink|drip|drive|drop|drum|dry|duck|dumb|dune|during|dust|dutch|duty|dwarf|dynamic|eager|eagle|early|earn|earth|easily|east|easy|echo|ecology|economy|edge|edit|educate|effort|egg|eight|either|elbow|elder|electric|elegant|element|elephant|elevator|elite|else|embark|embody|embrace|emerge|emotion|employ|empower|empty|enable|enact|end|endless|endorse|enemy|energy|enforce|engage|engine|enhance|enjoy|enlist|enough|enrich|enroll|ensure|enter|entire|entry|envelope|episode|equal|equip|era|erase|erode|erosion|error|erupt|escape|essay|essence|estate|eternal|ethics|evidence|evil|evoke|evolve|exact|example|excess|exchange|excite|exclude|excuse|execute|exercise|exhaust|exhibit|exile|exist|exit|exotic|expand|expect|expire|explain|expose|express|extend|extra|eye|eyebrow|fabric|face|faculty|fade|faint|faith|fall|false|fame|family|famous|fan|fancy|fantasy|farm|fashion|fat|fatal|father|fatigue|fault|favorite|feature|february|federal|fee|feed|feel|female|fence|festival|fetch|fever|few|fiber|fiction|field|figure|file|film|filter|final|find|fine|finger|finish|fire|firm|first|fiscal|fish|fit|fitness|fix|flag|flame|flash|flat|flavor|flee|flight|flip|float|flock|floor|flower|fluid|flush|fly|foam|focus|fog|foil|fold|follow|food|foot|force|forest|forget|fork|fortune|forum|forward|fossil|foster|found|fox|fragile|frame|frequent|fresh|friend|fringe|frog|front|frost|frown|frozen|fruit|fuel|fun|funny|furnace|fury|future|gadget|gain|galaxy|gallery|game|gap|garage|garbage|garden|garlic|garment|gas|gasp|gate|gather|gauge|gaze|general|genius|genre|gentle|genuine|gesture|ghost|giant|gift|giggle|ginger|giraffe|girl|give|glad|glance|glare|glass|glide|glimpse|globe|gloom|glory|glove|glow|glue|goat|goddess|gold|good|goose|gorilla|gospel|gossip|govern|gown|grab|grace|grain|grant|grape|grass|gravity|great|green|grid|grief|grit|grocery|group|grow|grunt|guard|guess|guide|guilt|guitar|gun|gym|habit|hair|half|hammer|hamster|hand|happy|harbor|hard|harsh|harvest|hat|have|hawk|hazard|head|health|heart|heavy|hedgehog|height|hello|helmet|help|hen|hero|hidden|high|hill|hint|hip|hire|history|hobby|hockey|hold|hole|holiday|hollow|home|honey|hood|hope|horn|horror|horse|hospital|host|hotel|hour|hover|hub|huge|human|humble|humor|hundred|hungry|hunt|hurdle|hurry|hurt|husband|hybrid|ice|icon|idea|identify|idle|ignore|ill|illegal|illness|image|imitate|immense|immune|impact|impose|improve|impulse|inch|include|income|increase|index|indicate|indoor|industry|infant|inflict|inform|inhale|inherit|initial|inject|injury|inmate|inner|innocent|input|inquiry|insane|insect|inside|inspire|install|intact|interest|into|invest|invite|involve|iron|island|isolate|issue|item|ivory|jacket|jaguar|jar|jazz|jealous|jeans|jelly|jewel|job|join|joke|journey|joy|judge|juice|jump|jungle|junior|junk|just|kangaroo|keen|keep|ketchup|key|kick|kid|kidney|kind|kingdom|kiss|kit|kitchen|kite|kitten|kiwi|knee|knife|knock|know|lab|label|labor|ladder|lady|lake|lamp|language|laptop|large|later|latin|laugh|laundry|lava|law|lawn|lawsuit|layer|lazy|leader|leaf|learn|leave|lecture|left|leg|legal|legend|leisure|lemon|lend|length|lens|leopard|lesson|letter|level|liar|liberty|library|license|life|lift|light|like|limb|limit|link|lion|liquid|list|little|live|lizard|load|loan|lobster|local|lock|logic|lonely|long|loop|lottery|loud|lounge|love|loyal|lucky|luggage|lumber|lunar|lunch|luxury|lyrics|machine|mad|magic|magnet|maid|mail|main|major|make|mammal|man|manage|mandate|mango|mansion|manual|maple|marble|march|margin|marine|market|marriage|mask|mass|master|match|material|math|matrix|matter|maximum|maze|meadow|mean|measure|meat|mechanic|medal|media|melody|melt|member|memory|mention|menu|mercy|merge|merit|merry|mesh|message|metal|method|middle|midnight|milk|million|mimic|mind|minimum|minor|minute|miracle|mirror|misery|miss|mistake|mix|mixed|mixture|mobile|model|modify|mom|moment|monitor|monkey|monster|month|moon|moral|more|morning|mosquito|mother|motion|motor|mountain|mouse|move|movie|much|muffin|mule|multiply|muscle|museum|mushroom|music|must|mutual|myself|mystery|myth|naive|name|napkin|narrow|nasty|nation|nature|near|neck|need|negative|neglect|neither|nephew|nerve|nest|net|network|neutral|never|news|next|nice|night|noble|noise|nominee|noodle|normal|north|nose|notable|note|nothing|notice|novel|now|nuclear|number|nurse|nut|oak|obey|object|oblige|obscure|observe|obtain|obvious|occur|ocean|october|odor|off|offer|office|often|oil|okay|old|olive|olympic|omit|once|one|onion|online|only|open|opera|opinion|oppose|option|orange|orbit|orchard|order|ordinary|organ|orient|original|orphan|ostrich|other|outdoor|outer|output|outside|oval|oven|over|own|owner|oxygen|oyster|ozone|pact|paddle|page|pair|palace|palm|panda|panel|panic|panther|paper|parade|parent|park|parrot|party|pass|patch|path|patient|patrol|pattern|pause|pave|payment|peace|peanut|pear|peasant|pelican|pen|penalty|pencil|people|pepper|perfect|permit|person|pet|phone|photo|phrase|physical|piano|picnic|picture|piece|pig|pigeon|pill|pilot|pink|pioneer|pipe|pistol|pitch|pizza|place|planet|plastic|plate|play|please|pledge|pluck|plug|plunge|poem|poet|point|polar|pole|police|pond|pony|pool|popular|portion|position|possible|post|potato|pottery|poverty|powder|power|practice|praise|predict|prefer|prepare|present|pretty|prevent|price|pride|primary|print|priority|prison|private|prize|problem|process|produce|profit|program|project|promote|proof|property|prosper|protect|proud|provide|public|pudding|pull|pulp|pulse|pumpkin|punch|pupil|puppy|purchase|purity|purpose|purse|push|put|puzzle|pyramid|quality|quantum|quarter|question|quick|quit|quiz|quote|rabbit|raccoon|race|rack|radar|radio|rail|rain|raise|rally|ramp|ranch|random|range|rapid|rare|rate|rather|raven|raw|razor|ready|real|reason|rebel|rebuild|recall|receive|recipe|record|recycle|reduce|reflect|reform|refuse|region|regret|regular|reject|relax|release|relief|rely|remain|remember|remind|remove|render|renew|rent|reopen|repair|repeat|replace|report|require|rescue|resemble|resist|resource|response|result|retire|retreat|return|reunion|reveal|review|reward|rhythm|rib|ribbon|rice|rich|ride|ridge|rifle|right|rigid|ring|riot|ripple|risk|ritual|rival|river|road|roast|robot|robust|rocket|romance|roof|rookie|room|rose|rotate|rough|round|route|royal|rubber|rude|rug|rule|run|runway|rural|sad|saddle|sadness|safe|sail|salad|salmon|salon|salt|salute|same|sample|sand|satisfy|satoshi|sauce|sausage|save|say|scale|scan|scare|scatter|scene|scheme|school|science|scissors|scorpion|scout|scrap|screen|script|scrub|sea|search|season|seat|second|secret|section|security|seed|seek|segment|select|sell|seminar|senior|sense|sentence|series|service|session|settle|setup|seven|shadow|shaft|shallow|share|shed|shell|sheriff|shield|shift|shine|ship|shiver|shock|shoe|shoot|shop|short|shoulder|shove|shrimp|shrug|shuffle|shy|sibling|sick|side|siege|sight|sign|silent|silk|silly|silver|similar|simple|since|sing|siren|sister|situate|six|size|skate|sketch|ski|skill|skin|skirt|skull|slab|slam|sleep|slender|slice|slide|slight|slim|slogan|slot|slow|slush|small|smart|smile|smoke|smooth|snack|snake|snap|sniff|snow|soap|soccer|social|sock|soda|soft|solar|soldier|solid|solution|solve|someone|song|soon|sorry|sort|soul|sound|soup|source|south|space|spare|spatial|spawn|speak|special|speed|spell|spend|sphere|spice|spider|spike|spin|spirit|split|spoil|sponsor|spoon|sport|spot|spray|spread|spring|spy|square|squeeze|squirrel|stable|stadium|staff|stage|stairs|stamp|stand|start|state|stay|steak|steel|stem|step|stereo|stick|still|sting|stock|stomach|stone|stool|story|stove|strategy|street|strike|strong|struggle|student|stuff|stumble|style|subject|submit|subway|success|such|sudden|suffer|sugar|suggest|suit|summer|sun|sunny|sunset|super|supply|supreme|sure|surface|surge|surprise|surround|survey|suspect|sustain|swallow|swamp|swap|swarm|swear|sweet|swift|swim|swing|switch|sword|symbol|symptom|syrup|system|table|tackle|tag|tail|talent|talk|tank|tape|target|task|taste|tattoo|taxi|teach|team|tell|ten|tenant|tennis|tent|term|test|text|thank|that|theme|then|theory|there|they|thing|this|thought|three|thrive|throw|thumb|thunder|ticket|tide|tiger|tilt|timber|time|tiny|tip|tired|tissue|title|toast|tobacco|today|toddler|toe|together|toilet|token|tomato|tomorrow|tone|tongue|tonight|tool|tooth|top|topic|topple|torch|tornado|tortoise|toss|total|tourist|toward|tower|town|toy|track|trade|traffic|tragic|train|transfer|trap|trash|travel|tray|treat|tree|trend|trial|tribe|trick|trigger|trim|trip|trophy|trouble|truck|true|truly|trumpet|trust|truth|try|tube|tuition|tumble|tuna|tunnel|turkey|turn|turtle|twelve|twenty|twice|twin|twist|two|type|typical|ugly|umbrella|unable|unaware|uncle|uncover|under|undo|unfair|unfold|unhappy|uniform|unique|unit|universe|unknown|unlock|until|unusual|unveil|update|upgrade|uphold|upon|upper|upset|urban|urge|usage|use|used|useful|useless|usual|utility|vacant|vacuum|vague|valid|valley|valve|van|vanish|vapor|various|vast|vault|vehicle|velvet|vendor|venture|venue|verb|verify|version|very|vessel|veteran|viable|vibrant|vicious|victory|video|view|village|vintage|violin|virtual|virus|visa|visit|visual|vital|vivid|vocal|voice|void|volcano|volume|vote|voyage|wage|wagon|wait|walk|wall|walnut|want|warfare|warm|warrior|wash|wasp|waste|water|wave|way|wealth|weapon|wear|weasel|weather|web|wedding|weekend|weird|welcome|west|wet|whale|what|wheat|wheel|when|where|whip|whisper|wide|width|wife|wild|will|win|window|wine|wing|wink|winner|winter|wire|wisdom|wise|wish|witness|wolf|woman|wonder|wood|wool|word|work|world|worry|worth|wrap|wreck|wrestle|wrist|write|wrong|yard|year|yellow|you|young|youth|zebra|zero|zone|zoo".split(
|
|
947
|
+
"|"
|
|
948
|
+
), Ie = "Invalid mnemonic", Sr = "Invalid entropy", Wt = "Invalid mnemonic checksum";
|
|
949
|
+
function Jt(r) {
|
|
1040
950
|
return (r || "").normalize("NFKD");
|
|
1041
951
|
}
|
|
1042
|
-
function
|
|
952
|
+
function Br(r) {
|
|
1043
953
|
return Number.parseInt(r, 2);
|
|
1044
954
|
}
|
|
1045
|
-
function
|
|
955
|
+
function Rr(r) {
|
|
1046
956
|
return r.map((e) => e.toString(2).padStart(8, "0")).join("");
|
|
1047
957
|
}
|
|
1048
|
-
function
|
|
1049
|
-
return
|
|
958
|
+
function $r(r) {
|
|
959
|
+
return Rr(Array.from(Ar(r))).slice(
|
|
960
|
+
0,
|
|
961
|
+
r.length * 8 / 32
|
|
962
|
+
);
|
|
1050
963
|
}
|
|
1051
|
-
function
|
|
1052
|
-
const t =
|
|
964
|
+
function Nr(r, e = Ur) {
|
|
965
|
+
const t = Jt(r).split(" ");
|
|
1053
966
|
if (t.length % 3 !== 0)
|
|
1054
|
-
throw new Error(
|
|
967
|
+
throw new Error(Ie);
|
|
1055
968
|
const n = t.map((u) => {
|
|
1056
969
|
const d = e.indexOf(u);
|
|
1057
970
|
if (d === -1)
|
|
1058
|
-
throw new Error(
|
|
971
|
+
throw new Error(Ie);
|
|
1059
972
|
return d.toString(2).padStart(11, "0");
|
|
1060
|
-
}).join(""), o = Math.floor(n.length / 33) * 32,
|
|
973
|
+
}).join(""), o = Math.floor(n.length / 33) * 32, s = n.slice(0, o), i = n.slice(o), a = s.match(/(.{1,8})/g), l = a == null ? void 0 : a.map(Br);
|
|
1061
974
|
if (!l || l.length % 4 !== 0 || l.length < 16 || l.length > 32)
|
|
1062
|
-
throw new Error(
|
|
975
|
+
throw new Error(Sr);
|
|
1063
976
|
const c = h(l);
|
|
1064
|
-
if (
|
|
1065
|
-
throw new Error(
|
|
977
|
+
if ($r(c) !== i)
|
|
978
|
+
throw new Error(Wt);
|
|
1066
979
|
return c;
|
|
1067
980
|
}
|
|
1068
|
-
function
|
|
981
|
+
function Zt(r, e = Ur) {
|
|
1069
982
|
if (r.length % 4 !== 0 || r.length < 16 || r.length > 32)
|
|
1070
|
-
throw new Error(
|
|
1071
|
-
const t = `${
|
|
983
|
+
throw new Error(Sr);
|
|
984
|
+
const t = `${Rr(Array.from(r))}${$r(r)}`.match(
|
|
985
|
+
/(.{1,11})/g
|
|
986
|
+
), n = t == null ? void 0 : t.map((o) => e[Br(o)]);
|
|
1072
987
|
if (!n || n.length < 12)
|
|
1073
988
|
throw new Error("Unable to map entropy to mnemonic");
|
|
1074
989
|
return n.join(" ");
|
|
1075
990
|
}
|
|
1076
|
-
function
|
|
991
|
+
function Gt(r, e) {
|
|
1077
992
|
try {
|
|
1078
|
-
|
|
993
|
+
Nr(r, e);
|
|
1079
994
|
} catch {
|
|
1080
995
|
return !1;
|
|
1081
996
|
}
|
|
1082
997
|
return !0;
|
|
1083
998
|
}
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
entropyToMnemonic: jt,
|
|
1087
|
-
mnemonicToEntropy: ge,
|
|
1088
|
-
validateMnemonic: lr
|
|
1089
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
1090
|
-
function zt(r, e, t) {
|
|
1091
|
-
return ge(r, e);
|
|
999
|
+
function Dr(r, e, t) {
|
|
1000
|
+
return Nr(r, e);
|
|
1092
1001
|
}
|
|
1093
|
-
function
|
|
1094
|
-
return
|
|
1002
|
+
function Ir(r, e) {
|
|
1003
|
+
return Gt(r, e);
|
|
1095
1004
|
}
|
|
1096
|
-
function
|
|
1097
|
-
if (!
|
|
1005
|
+
function Xt(r, e = "", t, n) {
|
|
1006
|
+
if (!Ir(r, t))
|
|
1098
1007
|
throw new Error("Invalid bip39 mnemonic specified");
|
|
1099
|
-
const o =
|
|
1100
|
-
return
|
|
1008
|
+
const o = Dr(r, t), s = V(`mnemonic${e}`);
|
|
1009
|
+
return Er(o, s).password.slice(0, 32);
|
|
1101
1010
|
}
|
|
1102
|
-
function
|
|
1011
|
+
function Qt(r, e) {
|
|
1103
1012
|
if (![33, 65].includes(r.length))
|
|
1104
|
-
throw new Error(
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1013
|
+
throw new Error(
|
|
1014
|
+
`Invalid publicKey provided, received ${r.length} bytes input`
|
|
1015
|
+
);
|
|
1016
|
+
return r.length === 33 ? r : qr.ProjectivePoint.fromHex(r).toRawBytes(!0);
|
|
1017
|
+
}
|
|
1018
|
+
function ve(r, e, t) {
|
|
1019
|
+
const n = h(r), o = h(e), s = h(t);
|
|
1020
|
+
if (s.length !== 32)
|
|
1110
1021
|
throw new Error("Invalid publicKey length, expected 32 bytes");
|
|
1111
1022
|
if (o.length !== 64)
|
|
1112
1023
|
throw new Error("Invalid signature length, expected 64 bytes");
|
|
1113
|
-
return
|
|
1024
|
+
return qt(n, o, s);
|
|
1114
1025
|
}
|
|
1115
|
-
const
|
|
1026
|
+
const en = [
|
|
1027
|
+
//["ecdsa", secp256k1VerifyHasher("blake2")],
|
|
1028
|
+
//["ethereum", secp256k1VerifyHasher("keccak")],
|
|
1116
1029
|
[
|
|
1117
1030
|
"ecdsa",
|
|
1118
1031
|
() => {
|
|
@@ -1125,132 +1038,190 @@ const Ot = [
|
|
|
1125
1038
|
throw new Error("Not Implemented");
|
|
1126
1039
|
}
|
|
1127
1040
|
]
|
|
1128
|
-
],
|
|
1041
|
+
], rn = [
|
|
1042
|
+
//["ed25519", ed25519Verify],
|
|
1129
1043
|
[
|
|
1130
1044
|
"ed25519",
|
|
1131
1045
|
() => {
|
|
1132
1046
|
throw new Error("Not Implemented");
|
|
1133
1047
|
}
|
|
1134
1048
|
],
|
|
1135
|
-
["sr25519",
|
|
1136
|
-
...
|
|
1137
|
-
],
|
|
1049
|
+
["sr25519", ve],
|
|
1050
|
+
...en
|
|
1051
|
+
], tn = [
|
|
1138
1052
|
"ed25519",
|
|
1139
1053
|
"sr25519",
|
|
1140
1054
|
"ecdsa"
|
|
1141
1055
|
];
|
|
1142
|
-
function
|
|
1143
|
-
return r.isValid = o.some(([
|
|
1056
|
+
function nn(r, { message: e, publicKey: t, signature: n }, o = rn) {
|
|
1057
|
+
return r.isValid = o.some(([s, i]) => {
|
|
1144
1058
|
try {
|
|
1145
|
-
if (
|
|
1146
|
-
return r.crypto =
|
|
1059
|
+
if (i(e, n, t))
|
|
1060
|
+
return r.crypto = s, !0;
|
|
1147
1061
|
} catch {
|
|
1148
1062
|
}
|
|
1149
1063
|
return !1;
|
|
1150
1064
|
}), r;
|
|
1151
1065
|
}
|
|
1152
|
-
function
|
|
1066
|
+
function on(r, { message: e, publicKey: t, signature: n }) {
|
|
1153
1067
|
const o = n[0];
|
|
1154
1068
|
if (o === void 0)
|
|
1155
|
-
throw new Error(
|
|
1069
|
+
throw new Error(
|
|
1070
|
+
"Invalid signature, expected first byte to indicate crypto type"
|
|
1071
|
+
);
|
|
1156
1072
|
if (![0, 1, 2].includes(o))
|
|
1157
|
-
throw new Error(
|
|
1158
|
-
|
|
1159
|
-
|
|
1073
|
+
throw new Error(
|
|
1074
|
+
`Unknown crypto type, expected signature prefix [0..2], found ${n[0]}`
|
|
1075
|
+
);
|
|
1076
|
+
const s = tn[o];
|
|
1077
|
+
if (!s)
|
|
1160
1078
|
throw new Error(`Unknown crypto type, found ${o}`);
|
|
1161
|
-
r.crypto =
|
|
1079
|
+
r.crypto = s;
|
|
1162
1080
|
try {
|
|
1163
1081
|
r.isValid = {
|
|
1164
|
-
sr25519: () =>
|
|
1082
|
+
sr25519: () => ve(e, n.subarray(1), t),
|
|
1165
1083
|
ecdsa: () => !1,
|
|
1166
1084
|
ethereum: () => !1,
|
|
1167
1085
|
ed25519: () => !1
|
|
1168
|
-
}[
|
|
1086
|
+
}[s]();
|
|
1169
1087
|
} catch {
|
|
1170
1088
|
}
|
|
1171
1089
|
return r;
|
|
1172
1090
|
}
|
|
1173
|
-
function
|
|
1091
|
+
function sn(r) {
|
|
1174
1092
|
const e = r[0];
|
|
1175
|
-
if (
|
|
1176
|
-
throw new Error(
|
|
1177
|
-
|
|
1093
|
+
if (e === void 0)
|
|
1094
|
+
throw new Error(
|
|
1095
|
+
"Invalid signature, expected first byte to indicate crypto type"
|
|
1096
|
+
);
|
|
1097
|
+
return [0, 1, 2].includes(e) && [65, 66].includes(r.length) ? on : nn;
|
|
1178
1098
|
}
|
|
1179
|
-
function
|
|
1099
|
+
function an(r, e, t) {
|
|
1180
1100
|
const n = h(e);
|
|
1181
1101
|
if (![64, 65, 66].includes(n.length))
|
|
1182
|
-
throw new Error(
|
|
1183
|
-
|
|
1102
|
+
throw new Error(
|
|
1103
|
+
`Invalid signature length, expected [64..66] bytes, found ${n.length}`
|
|
1104
|
+
);
|
|
1105
|
+
const o = ge(t), s = {
|
|
1184
1106
|
message: h(r),
|
|
1185
1107
|
publicKey: o,
|
|
1186
1108
|
signature: n
|
|
1187
|
-
},
|
|
1109
|
+
}, i = {
|
|
1188
1110
|
crypto: "none",
|
|
1189
1111
|
isValid: !1,
|
|
1190
|
-
isWrapped:
|
|
1112
|
+
isWrapped: Ue(s.message, !0),
|
|
1191
1113
|
publicKey: o
|
|
1192
|
-
},
|
|
1193
|
-
return l(
|
|
1114
|
+
}, a = Ue(s.message, !1), l = sn(n);
|
|
1115
|
+
return l(i, s), i.crypto !== "none" || i.isWrapped && !a ? i : (s.message = a ? rt(s.message) : tt(s.message), l(i, s));
|
|
1194
1116
|
}
|
|
1195
|
-
function
|
|
1117
|
+
function cn(r) {
|
|
1196
1118
|
const e = h(r);
|
|
1197
1119
|
if (e.length !== 32)
|
|
1198
1120
|
throw new Error(`Expected a seed of 32 bytes, found ${e.length}`);
|
|
1199
|
-
const t =
|
|
1121
|
+
const t = pr(e), n = S(t.subarray(0, 32)) >> 3n, o = g.BASE.multiply(n).toRawBytes();
|
|
1200
1122
|
return {
|
|
1201
1123
|
publicKey: new Uint8Array(o),
|
|
1202
1124
|
secretKey: new Uint8Array(t)
|
|
1203
1125
|
};
|
|
1204
1126
|
}
|
|
1205
|
-
function
|
|
1127
|
+
function ln(r, { publicKey: e, secretKey: t }) {
|
|
1206
1128
|
const n = typeof r == "string" ? new TextEncoder().encode(r) : r, o = h(t);
|
|
1207
1129
|
if (o.length !== 64)
|
|
1208
|
-
throw new Error(
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1130
|
+
throw new Error(
|
|
1131
|
+
`Expected secretKey to be 64 bytes, found ${o.length}`
|
|
1132
|
+
);
|
|
1133
|
+
return Mt(o, n);
|
|
1134
|
+
}
|
|
1135
|
+
const Pe = new Uint8Array();
|
|
1136
|
+
function un(r, { secretKey: e }, t = Pe, n = Pe) {
|
|
1137
|
+
const o = h(r), s = h(e), i = h(t), a = h(n);
|
|
1138
|
+
if (s.length !== 64)
|
|
1215
1139
|
throw new Error("Invalid secretKey length, expected 64 bytes");
|
|
1216
|
-
return
|
|
1140
|
+
return yr.sign(o, s, i, a);
|
|
1217
1141
|
}
|
|
1218
|
-
const
|
|
1219
|
-
function
|
|
1220
|
-
const
|
|
1221
|
-
if (
|
|
1142
|
+
const je = new Uint8Array();
|
|
1143
|
+
function dn(r, e, t, n = je, o = je) {
|
|
1144
|
+
const s = h(r), i = h(e), a = h(t), l = h(n), c = h(o);
|
|
1145
|
+
if (a.length !== 32)
|
|
1222
1146
|
throw new Error("Invalid publicKey length, expected 32 bytes");
|
|
1223
|
-
if (
|
|
1147
|
+
if (i.length !== 96)
|
|
1224
1148
|
throw new Error("Invalid vrfSign output length, expected 96 bytes");
|
|
1225
|
-
return
|
|
1226
|
-
|
|
1149
|
+
return yr.verify(
|
|
1150
|
+
s,
|
|
1151
|
+
i,
|
|
1152
|
+
a,
|
|
1153
|
+
l,
|
|
1154
|
+
c
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1157
|
+
const mn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1158
|
+
__proto__: null,
|
|
1159
|
+
ENCODING: ye,
|
|
1160
|
+
ENCODING_NONE: ir,
|
|
1161
|
+
ENCODING_VERSION: cr,
|
|
1162
|
+
NONCE_LENGTH: le,
|
|
1163
|
+
SCRYPT_LENGTH: lr,
|
|
1164
|
+
base58Decode: Je,
|
|
1165
|
+
base58Encode: Ze,
|
|
1166
|
+
base58Validate: We,
|
|
1167
|
+
base64Decode: yt,
|
|
1168
|
+
base64Encode: er,
|
|
1169
|
+
base64Validate: Qe,
|
|
1170
|
+
blake2AsHex: ft,
|
|
1171
|
+
blake2AsU8a: K,
|
|
1172
|
+
decodeAddress: ge,
|
|
1173
|
+
encodeAddress: mt,
|
|
1174
|
+
entropyToMnemonic: Zt,
|
|
1175
|
+
jsonDecryptData: jt,
|
|
1176
|
+
jsonEncryptFormat: Tt,
|
|
1177
|
+
keyExtractPath: ur,
|
|
1178
|
+
keyExtractSuri: Ht,
|
|
1179
|
+
keyFromPath: Yt,
|
|
1180
|
+
keyHdkdSr25519: kr,
|
|
1181
|
+
mnemonicToEntropy: Dr,
|
|
1182
|
+
mnemonicToMiniSecret: Xt,
|
|
1183
|
+
mnemonicValidate: Ir,
|
|
1184
|
+
naclDecrypt: or,
|
|
1185
|
+
naclEncrypt: Dt,
|
|
1186
|
+
pbkdf2Encode: Er,
|
|
1187
|
+
randomAsHex: Nt,
|
|
1188
|
+
randomAsU8a: _,
|
|
1189
|
+
scryptEncode: sr,
|
|
1190
|
+
scryptFromU8a: ar,
|
|
1191
|
+
scryptToU8a: Pt,
|
|
1192
|
+
secp256k1Compress: Qt,
|
|
1193
|
+
sha256AsU8a: Ar,
|
|
1194
|
+
shaAsU8a: xr,
|
|
1195
|
+
signatureVerify: an,
|
|
1196
|
+
sr25519DeriveHard: br,
|
|
1197
|
+
sr25519DeriveSoft: vr,
|
|
1198
|
+
sr25519FromSeed: cn,
|
|
1199
|
+
sr25519Sign: ln,
|
|
1200
|
+
sr25519Verify: ve,
|
|
1201
|
+
sr25519VrfSign: un,
|
|
1202
|
+
sr25519VrfVerify: dn
|
|
1203
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1227
1204
|
export {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
ut as u,
|
|
1251
|
-
Zt as v,
|
|
1252
|
-
tn as w,
|
|
1253
|
-
ke as x,
|
|
1254
|
-
nn as y,
|
|
1255
|
-
on as z
|
|
1205
|
+
Pt as a,
|
|
1206
|
+
ft as b,
|
|
1207
|
+
Tt as c,
|
|
1208
|
+
dn as d,
|
|
1209
|
+
un as e,
|
|
1210
|
+
an as f,
|
|
1211
|
+
Qt as g,
|
|
1212
|
+
ln as h,
|
|
1213
|
+
Yt as i,
|
|
1214
|
+
jt as j,
|
|
1215
|
+
ur as k,
|
|
1216
|
+
cn as l,
|
|
1217
|
+
ge as m,
|
|
1218
|
+
Dt as n,
|
|
1219
|
+
mt as o,
|
|
1220
|
+
yt as p,
|
|
1221
|
+
Ht as q,
|
|
1222
|
+
Xt as r,
|
|
1223
|
+
sr as s,
|
|
1224
|
+
$t as t,
|
|
1225
|
+
Nt as u,
|
|
1226
|
+
mn as v
|
|
1256
1227
|
};
|