@agentvault/agentvault 0.19.50 → 0.19.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1816 -1023
- package/dist/cli.js.map +4 -4
- package/dist/index.js +1822 -1029
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
- package/dist/__tests__/crypto-helpers.test.d.ts +0 -2
- package/dist/__tests__/crypto-helpers.test.d.ts.map +0 -1
- package/dist/__tests__/functional.test.d.ts +0 -21
- package/dist/__tests__/functional.test.d.ts.map +0 -1
- package/dist/__tests__/multi-session.test.d.ts +0 -2
- package/dist/__tests__/multi-session.test.d.ts.map +0 -1
- package/dist/__tests__/state.test.d.ts +0 -2
- package/dist/__tests__/state.test.d.ts.map +0 -1
- package/dist/__tests__/transport.test.d.ts +0 -2
- package/dist/__tests__/transport.test.d.ts.map +0 -1
- package/dist/_cp.d.ts +0 -10
- package/dist/_cp.d.ts.map +0 -1
- package/dist/account-config.d.ts +0 -20
- package/dist/account-config.d.ts.map +0 -1
- package/dist/channel.d.ts +0 -396
- package/dist/channel.d.ts.map +0 -1
- package/dist/cli.d.ts +0 -2
- package/dist/cli.d.ts.map +0 -1
- package/dist/create-agent.d.ts +0 -28
- package/dist/create-agent.d.ts.map +0 -1
- package/dist/credential-store.d.ts +0 -62
- package/dist/credential-store.d.ts.map +0 -1
- package/dist/crypto-helpers.d.ts +0 -2
- package/dist/crypto-helpers.d.ts.map +0 -1
- package/dist/doctor.d.ts +0 -41
- package/dist/doctor.d.ts.map +0 -1
- package/dist/fetch-interceptor.d.ts +0 -32
- package/dist/fetch-interceptor.d.ts.map +0 -1
- package/dist/gateway-send.d.ts +0 -98
- package/dist/gateway-send.d.ts.map +0 -1
- package/dist/http-handlers.d.ts +0 -53
- package/dist/http-handlers.d.ts.map +0 -1
- package/dist/index.d.ts +0 -27
- package/dist/index.d.ts.map +0 -1
- package/dist/mcp-handlers.d.ts +0 -26
- package/dist/mcp-handlers.d.ts.map +0 -1
- package/dist/mcp-proxy-helpers.d.ts +0 -9
- package/dist/mcp-proxy-helpers.d.ts.map +0 -1
- package/dist/mcp-server.d.ts +0 -91
- package/dist/mcp-server.d.ts.map +0 -1
- package/dist/mls-state.d.ts +0 -16
- package/dist/mls-state.d.ts.map +0 -1
- package/dist/openclaw-compat.d.ts +0 -33
- package/dist/openclaw-compat.d.ts.map +0 -1
- package/dist/openclaw-entry.d.ts +0 -32
- package/dist/openclaw-entry.d.ts.map +0 -1
- package/dist/openclaw-plugin.d.ts +0 -102
- package/dist/openclaw-plugin.d.ts.map +0 -1
- package/dist/openclaw-types.d.ts +0 -186
- package/dist/openclaw-types.d.ts.map +0 -1
- package/dist/policy-enforcer.d.ts +0 -78
- package/dist/policy-enforcer.d.ts.map +0 -1
- package/dist/setup.d.ts +0 -27
- package/dist/setup.d.ts.map +0 -1
- package/dist/skill-invoker.d.ts +0 -30
- package/dist/skill-invoker.d.ts.map +0 -1
- package/dist/skill-manifest.d.ts +0 -30
- package/dist/skill-manifest.d.ts.map +0 -1
- package/dist/skill-telemetry.d.ts +0 -36
- package/dist/skill-telemetry.d.ts.map +0 -1
- package/dist/skills-publish.d.ts +0 -8
- package/dist/skills-publish.d.ts.map +0 -1
- package/dist/state.d.ts +0 -32
- package/dist/state.d.ts.map +0 -1
- package/dist/transport.d.ts +0 -24
- package/dist/transport.d.ts.map +0 -1
- package/dist/types.d.ts +0 -419
- package/dist/types.d.ts.map +0 -1
- package/dist/workspace-handlers.d.ts +0 -62
- package/dist/workspace-handlers.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ var __toESM = (mod4, isNodeMode, target) => (target = mod4 != null ? __create(__
|
|
|
32
32
|
));
|
|
33
33
|
|
|
34
34
|
// ../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs
|
|
35
|
-
var __filename, __dirname, url2, path, Module, Module, root, window_, crypto_, randomValuesStandard,
|
|
35
|
+
var __filename, __dirname, url2, path, Module, Module, root, window_, crypto_, randomValuesStandard, crypto4, randomValueNodeJS, _Module, libsodium_sumo_default;
|
|
36
36
|
var init_libsodium_sumo = __esm({
|
|
37
37
|
async "../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs"() {
|
|
38
38
|
try {
|
|
@@ -96,9 +96,9 @@ var init_libsodium_sumo = __esm({
|
|
|
96
96
|
Module.getRandomValue = randomValuesStandard;
|
|
97
97
|
} catch (e) {
|
|
98
98
|
try {
|
|
99
|
-
|
|
99
|
+
crypto4 = null;
|
|
100
100
|
randomValueNodeJS = function() {
|
|
101
|
-
var buf =
|
|
101
|
+
var buf = crypto4["randomBytes"](4);
|
|
102
102
|
return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0;
|
|
103
103
|
};
|
|
104
104
|
randomValueNodeJS();
|
|
@@ -20931,7 +20931,7 @@ var init_libsodium_sumo = __esm({
|
|
|
20931
20931
|
var c3 = 0, d2 = 0, e = 0, f2 = 0, g2 = 0, h2 = 0, i4 = 0, j2 = 0, k2 = 0, l2 = 0, m3 = 0, n3 = 0, o3 = 0, p2 = 0;
|
|
20932
20932
|
l2 = T2 - 48 | 0;
|
|
20933
20933
|
T2 = l2;
|
|
20934
|
-
c3 =
|
|
20934
|
+
c3 = nc2(a3);
|
|
20935
20935
|
a: {
|
|
20936
20936
|
if (c3) {
|
|
20937
20937
|
break a;
|
|
@@ -25894,7 +25894,7 @@ var init_libsodium_sumo = __esm({
|
|
|
25894
25894
|
c3 = -11;
|
|
25895
25895
|
b3 = 11;
|
|
25896
25896
|
}
|
|
25897
|
-
a3 =
|
|
25897
|
+
a3 = nc2(i4);
|
|
25898
25898
|
if (a3) {
|
|
25899
25899
|
break d;
|
|
25900
25900
|
}
|
|
@@ -33332,7 +33332,7 @@ var init_libsodium_sumo = __esm({
|
|
|
33332
33332
|
}
|
|
33333
33333
|
y2[a3 + 4 >> 2] = y2[e + 12 >> 2];
|
|
33334
33334
|
b3 = y2[e + 8 >> 2];
|
|
33335
|
-
h2 =
|
|
33335
|
+
h2 = nc2(a3);
|
|
33336
33336
|
if (h2) {
|
|
33337
33337
|
break a;
|
|
33338
33338
|
}
|
|
@@ -35945,7 +35945,7 @@ var init_libsodium_sumo = __esm({
|
|
|
35945
35945
|
T2 = f2 + 256 | 0;
|
|
35946
35946
|
return a3 | 0;
|
|
35947
35947
|
}
|
|
35948
|
-
function
|
|
35948
|
+
function nc2(a3) {
|
|
35949
35949
|
var b3 = 0, c3 = 0, d2 = 0;
|
|
35950
35950
|
if (!a3) {
|
|
35951
35951
|
return -25;
|
|
@@ -36557,7 +36557,7 @@ var init_libsodium_sumo = __esm({
|
|
|
36557
36557
|
b3 = a3 ^ 127;
|
|
36558
36558
|
return (((b3 | f2) & 255) - 1 | (((b3 | g2) & 255) - 1 | (((b3 | h2) & 255) - 1 | (((a3 ^ 122 | i4) & 255) - 1 | (((a3 ^ 5 | j2) & 255) - 1 | (((a3 | k2) & 255) - 1 | ((a3 | e) & 255) - 1)))))) >>> 8 & 1;
|
|
36559
36559
|
}
|
|
36560
|
-
function
|
|
36560
|
+
function ed(a3, b3, c3, d2, e, f2) {
|
|
36561
36561
|
a3 = a3 | 0;
|
|
36562
36562
|
b3 = b3 | 0;
|
|
36563
36563
|
c3 = c3 | 0;
|
|
@@ -40024,7 +40024,7 @@ var init_libsodium_sumo = __esm({
|
|
|
40024
40024
|
}
|
|
40025
40025
|
return { e: Object.create(Object.prototype, { grow: { value: ba2 }, buffer: { get: function() {
|
|
40026
40026
|
return v2;
|
|
40027
|
-
} } }), f: yi, g: ma2, h: Ba2, i: ma2, j: ka2, k: Le2, l: Je2, m: zg, n: yg, o: xg, p: wg, q: ka2, r: Ba2, s: ka2, t: ka2, u: Le2, v: ra2, w: vg, x: ug, y: tg, z: sg, A: Ba2, B: rg, C: qg, D: pg, E: ng, F: mg, G: lg, H: kg, I: jg, J: ka2, K: Ce2, L: Ba2, M: ma2, N: Ta2, O: ra2, P: ka2, Q: Oa2, R: Ba2, S: ma2, T: Ta2, U: ra2, V: ig, W: hg, X: gg, Y: fg, Z: ka2, _: Ma2, $: Ba2, aa: ma2, ba: Ta2, ca: ra2, da: ka2, ea: ka2, fa: Kg, ga: wd, ha: vd, ia: ra2, ja: ka2, ka: ka2, la: Cb, ma: ra2, na: Xa2, oa: eg, pa: qb, qa: dg, ra: cg, sa: ua2, ta: ka2, ua: Dc, va: ra2, wa: Va2, xa: ud, ya: Ya2, za: bg, Aa: ag, Ba: ka2, Ca: ka2, Da: Dc, Ea: ra2, Fa: ze2, Ga: ud, Ha: Ng, Ia: wd, Ja: vd, Ka: ka2, La: ka2, Ma: ka2, Na: ka2, Oa: Ma2, Pa: ka2, Qa: ma2, Ra: ma2, Sa: Ta2, Ta: dh2, Ua: ch, Va: bh, Wa: ah, Xa: Lb, Ya: Kb, Za: td, _a: sd, $a: rd, ab: $f, bb: _f, cb: Zf, db: qd, eb: Yf, fb: pd, gb: Xf, hb: Wf, ib: Uf, jb: Md, kb: tc, lb: nb, mb, nb: Lb, ob: Kb, pb: td, qb: sd, rb: ka2, sb: ka2, tb: ka2, ub: ka2, vb: Ma2, wb: ka2, xb: ma2, yb: ma2, zb: Ta2, Ab: Aa2, Bb: ka2, Cb: ma2, Db: ka2, Eb: ma2, Fb: Sa2, Gb: ka2, Hb: ma2, Ib: ka2, Jb: ma2, Kb: vb, Lb: ua2, Mb: ma2, Nb: ka2, Ob: ma2, Pb: ub, Qb: ua2, Rb: ma2, Sb: ka2, Tb: ma2, Ub: tb, Vb: ua2, Wb: ma2, Xb: ka2, Yb: ma2, Zb: ma2, _b: ua2, $b: ka2, ac: ma2, bc: ua2, cc: ka2, dc: Nd, ec: pe2, fc: od, gc: fh, hc: nd, ic: eh, jc: ra2, kc: ma2, lc: ua2, mc: ka2, nc: ma2, oc: ua2, pc: ka2, qc: ma2, rc: ma2, sc: pe2, tc: ra2, uc: od, vc: Tf, wc: Ja2, xc: xh, yc: nd, zc: Ia2, Ac: ua2, Bc: md, Cc: Lg, Dc: ka2, Ec: Ag, Fc: Ub, Gc: Sf, Hc: Ua2, Ic: Rf, Jc: ua2, Kc: Cb, Lc: Za2, Mc: ic, Nc: Ca2, Oc: md, Pc: ma2, Qc: ua2, Rc: Oa2, Sc: ka2, Tc: ld, Uc: Nd, Vc: ma2, Wc: ua2, Xc: Oa2, Yc: ka2, Zc: ld, _c: ra2, $c: Gh, ad: Fh, bd: Eh, cd: Dh, dd: ra2, ed: Ch, fd: ka2, gd: Ba2, hd: Bh, id: Cb, jd: ze2, kd: hi, ld: gi, md: fi, nd: ei, od: di, pd: ua2, qd: Ba2, rd: ci, sd: Dc, td: Gg, ud: nb, vd: Fg, wd: Eg, xd: ka2, yd: ka2, zd: ka2, Ad: ka2, Bd: Dg, Cd: Rc, Dd: ma2, Ed: ka2, Fd: kd, Gd: jd, Hd: Sg, Id: id, Jd: Rg, Kd: Qg, Ld: ra2, Md: kd, Nd: jd, Od: Ga2, Pd: id, Qd: Fa2, Rd: ma2, Sd: ka2, Td: Rc, Ud: ra2, Vd: Db, Wd: ma2, Xd: wa2, Yd: Ba2, Zd: wa2, _d: ma2, $d: yc, ae: wh, be: Vb, ce: wa2, de: xc, ee: wc, fe: vc, ge: me2, he: vh, ie: uh, je: Oa2, ke: th, le: Pf, me: Of, ne: Nf, oe: Mf, pe: Lf, qe: fb, re: ma2, se: wa2, te: Ba2, ue: wa2, ve: ma2, we: yc, xe: fe2, ye: Db, ze: wa2, Ae: xc, Be: wc, Ce: fb, De: ee2, Ee: Vb, Fe: de2, Ge: vc, He: uc, Ie: Kf, Je: hd, Ke: Jf, Le: Db, Me: fb, Ne: fb, Oe: ma2, Pe: wa2, Qe: Ba2, Re: wa2, Se: ma2, Te: yc, Ue: fe2, Ve: Db, We: wa2, Xe: xc, Ye: wc, Ze: fb, _e: ee2, $e: Vb, af: de2, bf: vc, cf: uc, df: Hf, ef: hd, ff: Gf, gf: Ff, hf: Ef, jf: sh, kf: Jg, lf: Ig, mf: Hg, nf: ka2, of: ka2, pf: Ea2, qf: wb, rf: ka2, sf: ka2, tf: ka2, uf: Ma2, vf: ka2, wf: ma2, xf: ma2, yf: Ta2, zf: Mg, Af: Lb, Bf: Kb, Cf: ra2, Df: rd, Ef: Df, Ff: qd, Gf: pd, Hf: Lb, If: Kb, Jf: ka2, Kf: Ma2, Lf: ka2, Mf: ma2, Nf: ma2, Of: Ta2, Pf: ra2, Qf: ra2, Rf: Mh, Sf: Lh, Tf: Kh, Uf: Cf, Vf: Bf, Wf: Jh, Xf: Ih, Yf: Ma2, Zf: ka2, _f: Hh, $f: Ba2, ag: Db, bg: fb, cg: Vb, dg: Oa2, eg: ma2, fg: Tg, gg: gd, hg: Je2, ig: Oa2, jg: ma2, kg: gd, lg: Cb, mg: ua2, ng: ka2, og: ka2, pg: ua2, qg: Wd, rg: lh, sg: kh, tg: jh, ug: fd, vg:
|
|
40027
|
+
} } }), f: yi, g: ma2, h: Ba2, i: ma2, j: ka2, k: Le2, l: Je2, m: zg, n: yg, o: xg, p: wg, q: ka2, r: Ba2, s: ka2, t: ka2, u: Le2, v: ra2, w: vg, x: ug, y: tg, z: sg, A: Ba2, B: rg, C: qg, D: pg, E: ng, F: mg, G: lg, H: kg, I: jg, J: ka2, K: Ce2, L: Ba2, M: ma2, N: Ta2, O: ra2, P: ka2, Q: Oa2, R: Ba2, S: ma2, T: Ta2, U: ra2, V: ig, W: hg, X: gg, Y: fg, Z: ka2, _: Ma2, $: Ba2, aa: ma2, ba: Ta2, ca: ra2, da: ka2, ea: ka2, fa: Kg, ga: wd, ha: vd, ia: ra2, ja: ka2, ka: ka2, la: Cb, ma: ra2, na: Xa2, oa: eg, pa: qb, qa: dg, ra: cg, sa: ua2, ta: ka2, ua: Dc, va: ra2, wa: Va2, xa: ud, ya: Ya2, za: bg, Aa: ag, Ba: ka2, Ca: ka2, Da: Dc, Ea: ra2, Fa: ze2, Ga: ud, Ha: Ng, Ia: wd, Ja: vd, Ka: ka2, La: ka2, Ma: ka2, Na: ka2, Oa: Ma2, Pa: ka2, Qa: ma2, Ra: ma2, Sa: Ta2, Ta: dh2, Ua: ch, Va: bh, Wa: ah, Xa: Lb, Ya: Kb, Za: td, _a: sd, $a: rd, ab: $f, bb: _f, cb: Zf, db: qd, eb: Yf, fb: pd, gb: Xf, hb: Wf, ib: Uf, jb: Md, kb: tc, lb: nb, mb, nb: Lb, ob: Kb, pb: td, qb: sd, rb: ka2, sb: ka2, tb: ka2, ub: ka2, vb: Ma2, wb: ka2, xb: ma2, yb: ma2, zb: Ta2, Ab: Aa2, Bb: ka2, Cb: ma2, Db: ka2, Eb: ma2, Fb: Sa2, Gb: ka2, Hb: ma2, Ib: ka2, Jb: ma2, Kb: vb, Lb: ua2, Mb: ma2, Nb: ka2, Ob: ma2, Pb: ub, Qb: ua2, Rb: ma2, Sb: ka2, Tb: ma2, Ub: tb, Vb: ua2, Wb: ma2, Xb: ka2, Yb: ma2, Zb: ma2, _b: ua2, $b: ka2, ac: ma2, bc: ua2, cc: ka2, dc: Nd, ec: pe2, fc: od, gc: fh, hc: nd, ic: eh, jc: ra2, kc: ma2, lc: ua2, mc: ka2, nc: ma2, oc: ua2, pc: ka2, qc: ma2, rc: ma2, sc: pe2, tc: ra2, uc: od, vc: Tf, wc: Ja2, xc: xh, yc: nd, zc: Ia2, Ac: ua2, Bc: md, Cc: Lg, Dc: ka2, Ec: Ag, Fc: Ub, Gc: Sf, Hc: Ua2, Ic: Rf, Jc: ua2, Kc: Cb, Lc: Za2, Mc: ic, Nc: Ca2, Oc: md, Pc: ma2, Qc: ua2, Rc: Oa2, Sc: ka2, Tc: ld, Uc: Nd, Vc: ma2, Wc: ua2, Xc: Oa2, Yc: ka2, Zc: ld, _c: ra2, $c: Gh, ad: Fh, bd: Eh, cd: Dh, dd: ra2, ed: Ch, fd: ka2, gd: Ba2, hd: Bh, id: Cb, jd: ze2, kd: hi, ld: gi, md: fi, nd: ei, od: di, pd: ua2, qd: Ba2, rd: ci, sd: Dc, td: Gg, ud: nb, vd: Fg, wd: Eg, xd: ka2, yd: ka2, zd: ka2, Ad: ka2, Bd: Dg, Cd: Rc, Dd: ma2, Ed: ka2, Fd: kd, Gd: jd, Hd: Sg, Id: id, Jd: Rg, Kd: Qg, Ld: ra2, Md: kd, Nd: jd, Od: Ga2, Pd: id, Qd: Fa2, Rd: ma2, Sd: ka2, Td: Rc, Ud: ra2, Vd: Db, Wd: ma2, Xd: wa2, Yd: Ba2, Zd: wa2, _d: ma2, $d: yc, ae: wh, be: Vb, ce: wa2, de: xc, ee: wc, fe: vc, ge: me2, he: vh, ie: uh, je: Oa2, ke: th, le: Pf, me: Of, ne: Nf, oe: Mf, pe: Lf, qe: fb, re: ma2, se: wa2, te: Ba2, ue: wa2, ve: ma2, we: yc, xe: fe2, ye: Db, ze: wa2, Ae: xc, Be: wc, Ce: fb, De: ee2, Ee: Vb, Fe: de2, Ge: vc, He: uc, Ie: Kf, Je: hd, Ke: Jf, Le: Db, Me: fb, Ne: fb, Oe: ma2, Pe: wa2, Qe: Ba2, Re: wa2, Se: ma2, Te: yc, Ue: fe2, Ve: Db, We: wa2, Xe: xc, Ye: wc, Ze: fb, _e: ee2, $e: Vb, af: de2, bf: vc, cf: uc, df: Hf, ef: hd, ff: Gf, gf: Ff, hf: Ef, jf: sh, kf: Jg, lf: Ig, mf: Hg, nf: ka2, of: ka2, pf: Ea2, qf: wb, rf: ka2, sf: ka2, tf: ka2, uf: Ma2, vf: ka2, wf: ma2, xf: ma2, yf: Ta2, zf: Mg, Af: Lb, Bf: Kb, Cf: ra2, Df: rd, Ef: Df, Ff: qd, Gf: pd, Hf: Lb, If: Kb, Jf: ka2, Kf: Ma2, Lf: ka2, Mf: ma2, Nf: ma2, Of: Ta2, Pf: ra2, Qf: ra2, Rf: Mh, Sf: Lh, Tf: Kh, Uf: Cf, Vf: Bf, Wf: Jh, Xf: Ih, Yf: Ma2, Zf: ka2, _f: Hh, $f: Ba2, ag: Db, bg: fb, cg: Vb, dg: Oa2, eg: ma2, fg: Tg, gg: gd, hg: Je2, ig: Oa2, jg: ma2, kg: gd, lg: Cb, mg: ua2, ng: ka2, og: ka2, pg: ua2, qg: Wd, rg: lh, sg: kh, tg: jh, ug: fd, vg: ed, wg: dd, xg: cd, yg: ih, zg: ic, Ag: hh, Bg: gh, Cg: Cb, Dg: ua2, Eg: ka2, Fg: ka2, Gg: ua2, Hg: Wd, Ig: nh, Jg: mh, Kg: Vd, Lg: ic, Mg: Ud, Ng: Td, Og: Yd, Pg: Xd, Qg: ph, Rg: oh, Sg: cd, Tg: ed, Ug: dd, Vg: fd, Wg: ka2, Xg: Oa2, Yg: wa2, Zg: ka2, _g: Ce2, $g: wa2, ah: zf, bh: yf, ch: xf, dh: wf, eh: vf, fh: uf, gh: ra2, hh: ra2, ih: ka2, jh: Ma2, kh: wa2, lh: qh, mh: bd, nh: ad, oh: ra2, ph: ka2, qh: Oa2, rh: wa2, sh: tf, th: sf, uh: rf, vh: ra2, wh: bd, xh: qf, yh: ad, zh: ka2, Ah: Ma2, Bh: wa2, Ch: ra2, Dh: ma2, Eh: ka2, Fh: ua2, Gh: db, Hh: kb, Ih: xd, Jh: oi, Kh: ni, Lh: Ae2, Mh: mi, Nh: za2, Oh: li, Ph: ka2, Qh: ki, Rh: pf, Sh: Ah, Th: zh, Uh: yh, Vh: Bc, Wh: Ac, Xh: ti, Yh: ji, Zh: ii, _h: Cg, $h: Bg, ai: fb, bi: Ba2, ci: tc, di: nb, ei: rh, fi: $c, gi: of, hi: nf, ii: mf, ji: _c, ki: lf, li: Yc, mi: kf, ni: ka2, oi: ka2, pi: ka2, qi: ka2, ri: Ma2, si: ma2, ti: Ta2, ui: jf, vi: hf, wi: Md, xi: bi, yi: ai, zi: $h, Ai: _h, Bi: Zh, Ci: ye2, Di: xe2, Ei: we2, Fi: ve2, Gi: ue2, Hi: te2, Ii: se2, Ji: re2, Ki: ka2, Li: ua2, Mi: ka2, Ni: ua2, Oi: ka2, Pi: Yh, Qi: Xh, Ri: Wh, Si: Vh, Ti: Uh, Ui: Th, Vi: Sh, Wi: Rh, Xi: Qh, Yi: Ph, Zi: Oh, _i: re2, $i: Nh, aj: ka2, bj: ua2, cj: ua2, dj: ka2, ej: gf, fj: ma2, gj: wa2, hj: Ba2, ij: wa2, jj: ka2, kj: $g, lj: _g, mj: Zg, nj: wa2, oj: Ed, pj: wa2, qj: Yg, rj: Ed, sj: me2, tj: uc, uj: ff, vj: ef, wj: df, xj: cf, yj: Xg, zj: Wg, Aj: Vg, Bj: Ug, Cj: ka2, Dj: ka2, Ej: Pg, Fj: Og, Gj: ka2, Hj: ka2, Ij: $c, Jj: bf, Kj: _c, Lj: Yc, Mj: ka2, Nj: Ma2, Oj: ma2, Pj: Ta2, Qj: ma2, Rj: ma2, Sj: af, Tj: $e2, Uj: _e2, Vj: ka2, Wj: Oa2, Xj: wa2, Yj: ra2, Zj: Ze2, _j: Ye2, $j: ka2, ak: Oa2, bk: wa2, ck: ra2, dk: ka2, ek: Ma2, fk: wa2, gk: Xe2, hk: We2, ik: Ve2, jk: ra2, kk: Da2, lk: ta2 };
|
|
40028
40028
|
}
|
|
40029
40029
|
return da2(ea2);
|
|
40030
40030
|
})(info);
|
|
@@ -40301,7 +40301,7 @@ var init_libsodium_sumo = __esm({
|
|
|
40301
40301
|
try {
|
|
40302
40302
|
var window_ = "object" === typeof window ? window : self;
|
|
40303
40303
|
var crypto_ = typeof window_.crypto !== "undefined" ? window_.crypto : window_.msCrypto;
|
|
40304
|
-
crypto_ = crypto_ === void 0 ?
|
|
40304
|
+
crypto_ = crypto_ === void 0 ? crypto4 : crypto_;
|
|
40305
40305
|
var randomValuesStandard = function() {
|
|
40306
40306
|
var buf = new Uint32Array(1);
|
|
40307
40307
|
crypto_.getRandomValues(buf);
|
|
@@ -40311,9 +40311,9 @@ var init_libsodium_sumo = __esm({
|
|
|
40311
40311
|
Module3.getRandomValue = randomValuesStandard;
|
|
40312
40312
|
} catch (e) {
|
|
40313
40313
|
try {
|
|
40314
|
-
var
|
|
40314
|
+
var crypto4 = null;
|
|
40315
40315
|
var randomValueNodeJS = function() {
|
|
40316
|
-
var buf =
|
|
40316
|
+
var buf = crypto4["randomBytes"](4);
|
|
40317
40317
|
return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0;
|
|
40318
40318
|
};
|
|
40319
40319
|
randomValueNodeJS();
|
|
@@ -41361,7 +41361,7 @@ var init_libsodium_sumo = __esm({
|
|
|
41361
41361
|
try {
|
|
41362
41362
|
var window_ = "object" === typeof window ? window : self;
|
|
41363
41363
|
var crypto_ = typeof window_.crypto !== "undefined" ? window_.crypto : window_.msCrypto;
|
|
41364
|
-
crypto_ = crypto_ === void 0 ?
|
|
41364
|
+
crypto_ = crypto_ === void 0 ? crypto4 : crypto_;
|
|
41365
41365
|
var randomValuesStandard = function() {
|
|
41366
41366
|
var buf = new Uint32Array(1);
|
|
41367
41367
|
crypto_.getRandomValues(buf);
|
|
@@ -41371,9 +41371,9 @@ var init_libsodium_sumo = __esm({
|
|
|
41371
41371
|
Module2.getRandomValue = randomValuesStandard;
|
|
41372
41372
|
} catch (e) {
|
|
41373
41373
|
try {
|
|
41374
|
-
var
|
|
41374
|
+
var crypto4 = null;
|
|
41375
41375
|
var randomValueNodeJS = function() {
|
|
41376
|
-
var buf =
|
|
41376
|
+
var buf = crypto4["randomBytes"](4);
|
|
41377
41377
|
return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0;
|
|
41378
41378
|
};
|
|
41379
41379
|
randomValueNodeJS();
|
|
@@ -47467,7 +47467,7 @@ var init_proposal = __esm({
|
|
|
47467
47467
|
}
|
|
47468
47468
|
};
|
|
47469
47469
|
encodeProposal = encode(proposalEncoder);
|
|
47470
|
-
decodeProposalAdd = mapDecoder(decodeAdd, (
|
|
47470
|
+
decodeProposalAdd = mapDecoder(decodeAdd, (add4) => ({ proposalType: "add", add: add4 }));
|
|
47471
47471
|
decodeProposalUpdate = mapDecoder(decodeUpdate, (update) => ({
|
|
47472
47472
|
proposalType: "update",
|
|
47473
47473
|
update
|
|
@@ -50978,8 +50978,8 @@ async function loadSubtleCrypto() {
|
|
|
50978
50978
|
return globalThis.crypto.subtle;
|
|
50979
50979
|
}
|
|
50980
50980
|
try {
|
|
50981
|
-
const { webcrypto } = await import("crypto");
|
|
50982
|
-
return
|
|
50981
|
+
const { webcrypto: webcrypto2 } = await import("crypto");
|
|
50982
|
+
return webcrypto2.subtle;
|
|
50983
50983
|
} catch (e) {
|
|
50984
50984
|
throw new NotSupportedError(e);
|
|
50985
50985
|
}
|
|
@@ -54033,9 +54033,9 @@ function createCipher(core, opts) {
|
|
|
54033
54033
|
if (nonceNcLen !== nonce.length)
|
|
54034
54034
|
throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`);
|
|
54035
54035
|
if (nonceNcLen !== 12) {
|
|
54036
|
-
const
|
|
54037
|
-
|
|
54038
|
-
nonce =
|
|
54036
|
+
const nc2 = new Uint8Array(12);
|
|
54037
|
+
nc2.set(nonce, counterRight ? 0 : 12 - nonce.length);
|
|
54038
|
+
nonce = nc2;
|
|
54039
54039
|
toClean.push(nonce);
|
|
54040
54040
|
}
|
|
54041
54041
|
const n32 = u322(nonce);
|
|
@@ -54872,31 +54872,32 @@ var init_rng = __esm({
|
|
|
54872
54872
|
}
|
|
54873
54873
|
});
|
|
54874
54874
|
|
|
54875
|
-
//
|
|
54875
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
54876
|
+
import * as nc from "node:crypto";
|
|
54877
|
+
var crypto2;
|
|
54878
|
+
var init_cryptoNode = __esm({
|
|
54879
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js"() {
|
|
54880
|
+
crypto2 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
54881
|
+
}
|
|
54882
|
+
});
|
|
54883
|
+
|
|
54884
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js
|
|
54876
54885
|
function isBytes3(a2) {
|
|
54877
54886
|
return a2 instanceof Uint8Array || ArrayBuffer.isView(a2) && a2.constructor.name === "Uint8Array";
|
|
54878
54887
|
}
|
|
54879
|
-
function anumber3(n2
|
|
54880
|
-
if (!Number.isSafeInteger(n2) || n2 < 0)
|
|
54881
|
-
|
|
54882
|
-
throw new Error(`${prefix}expected integer >= 0, got ${n2}`);
|
|
54883
|
-
}
|
|
54888
|
+
function anumber3(n2) {
|
|
54889
|
+
if (!Number.isSafeInteger(n2) || n2 < 0)
|
|
54890
|
+
throw new Error("positive integer expected, got " + n2);
|
|
54884
54891
|
}
|
|
54885
|
-
function abytes3(
|
|
54886
|
-
|
|
54887
|
-
|
|
54888
|
-
|
|
54889
|
-
|
|
54890
|
-
const prefix = title && `"${title}" `;
|
|
54891
|
-
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
54892
|
-
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
54893
|
-
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
54894
|
-
}
|
|
54895
|
-
return value;
|
|
54892
|
+
function abytes3(b2, ...lengths) {
|
|
54893
|
+
if (!isBytes3(b2))
|
|
54894
|
+
throw new Error("Uint8Array expected");
|
|
54895
|
+
if (lengths.length > 0 && !lengths.includes(b2.length))
|
|
54896
|
+
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b2.length);
|
|
54896
54897
|
}
|
|
54897
54898
|
function ahash2(h2) {
|
|
54898
54899
|
if (typeof h2 !== "function" || typeof h2.create !== "function")
|
|
54899
|
-
throw new Error("Hash
|
|
54900
|
+
throw new Error("Hash should be wrapped by utils.createHasher");
|
|
54900
54901
|
anumber3(h2.outputLen);
|
|
54901
54902
|
anumber3(h2.blockLen);
|
|
54902
54903
|
}
|
|
@@ -54907,10 +54908,10 @@ function aexists3(instance, checkFinished = true) {
|
|
|
54907
54908
|
throw new Error("Hash#digest() has already been called");
|
|
54908
54909
|
}
|
|
54909
54910
|
function aoutput3(out, instance) {
|
|
54910
|
-
abytes3(out
|
|
54911
|
+
abytes3(out);
|
|
54911
54912
|
const min = instance.outputLen;
|
|
54912
54913
|
if (out.length < min) {
|
|
54913
|
-
throw new Error(
|
|
54914
|
+
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
54914
54915
|
}
|
|
54915
54916
|
}
|
|
54916
54917
|
function u323(arr) {
|
|
@@ -54976,6 +54977,17 @@ function hexToBytes3(hex3) {
|
|
|
54976
54977
|
}
|
|
54977
54978
|
return array2;
|
|
54978
54979
|
}
|
|
54980
|
+
function utf8ToBytes(str) {
|
|
54981
|
+
if (typeof str !== "string")
|
|
54982
|
+
throw new Error("string expected");
|
|
54983
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
54984
|
+
}
|
|
54985
|
+
function toBytes(data) {
|
|
54986
|
+
if (typeof data === "string")
|
|
54987
|
+
data = utf8ToBytes(data);
|
|
54988
|
+
abytes3(data);
|
|
54989
|
+
return data;
|
|
54990
|
+
}
|
|
54979
54991
|
function concatBytes2(...arrays) {
|
|
54980
54992
|
let sum = 0;
|
|
54981
54993
|
for (let i2 = 0; i2 < arrays.length; i2++) {
|
|
@@ -54991,24 +55003,35 @@ function concatBytes2(...arrays) {
|
|
|
54991
55003
|
}
|
|
54992
55004
|
return res;
|
|
54993
55005
|
}
|
|
54994
|
-
function createHasher2(hashCons
|
|
54995
|
-
const hashC = (msg
|
|
54996
|
-
const tmp = hashCons(
|
|
55006
|
+
function createHasher2(hashCons) {
|
|
55007
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
55008
|
+
const tmp = hashCons();
|
|
55009
|
+
hashC.outputLen = tmp.outputLen;
|
|
55010
|
+
hashC.blockLen = tmp.blockLen;
|
|
55011
|
+
hashC.create = () => hashCons();
|
|
55012
|
+
return hashC;
|
|
55013
|
+
}
|
|
55014
|
+
function createXOFer(hashCons) {
|
|
55015
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
55016
|
+
const tmp = hashCons({});
|
|
54997
55017
|
hashC.outputLen = tmp.outputLen;
|
|
54998
55018
|
hashC.blockLen = tmp.blockLen;
|
|
54999
55019
|
hashC.create = (opts) => hashCons(opts);
|
|
55000
|
-
|
|
55001
|
-
return Object.freeze(hashC);
|
|
55020
|
+
return hashC;
|
|
55002
55021
|
}
|
|
55003
55022
|
function randomBytes2(bytesLength = 32) {
|
|
55004
|
-
|
|
55005
|
-
|
|
55006
|
-
|
|
55007
|
-
|
|
55023
|
+
if (crypto2 && typeof crypto2.getRandomValues === "function") {
|
|
55024
|
+
return crypto2.getRandomValues(new Uint8Array(bytesLength));
|
|
55025
|
+
}
|
|
55026
|
+
if (crypto2 && typeof crypto2.randomBytes === "function") {
|
|
55027
|
+
return Uint8Array.from(crypto2.randomBytes(bytesLength));
|
|
55028
|
+
}
|
|
55029
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
55008
55030
|
}
|
|
55009
|
-
var isLE3, swap32IfBE2, hasHexBuiltin, hexes, asciis,
|
|
55031
|
+
var isLE3, swap32IfBE2, hasHexBuiltin, hexes, asciis, Hash;
|
|
55010
55032
|
var init_utils2 = __esm({
|
|
55011
|
-
"
|
|
55033
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js"() {
|
|
55034
|
+
init_cryptoNode();
|
|
55012
55035
|
isLE3 = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
55013
55036
|
swap32IfBE2 = isLE3 ? (u2) => u2 : byteSwap32;
|
|
55014
55037
|
hasHexBuiltin = /* @__PURE__ */ (() => (
|
|
@@ -55017,13 +55040,24 @@ var init_utils2 = __esm({
|
|
|
55017
55040
|
))();
|
|
55018
55041
|
hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_2, i2) => i2.toString(16).padStart(2, "0"));
|
|
55019
55042
|
asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
55020
|
-
|
|
55021
|
-
|
|
55022
|
-
});
|
|
55043
|
+
Hash = class {
|
|
55044
|
+
};
|
|
55023
55045
|
}
|
|
55024
55046
|
});
|
|
55025
55047
|
|
|
55026
|
-
//
|
|
55048
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js
|
|
55049
|
+
function setBigUint64(view, byteOffset, value, isLE4) {
|
|
55050
|
+
if (typeof view.setBigUint64 === "function")
|
|
55051
|
+
return view.setBigUint64(byteOffset, value, isLE4);
|
|
55052
|
+
const _32n4 = BigInt(32);
|
|
55053
|
+
const _u32_max = BigInt(4294967295);
|
|
55054
|
+
const wh = Number(value >> _32n4 & _u32_max);
|
|
55055
|
+
const wl = Number(value & _u32_max);
|
|
55056
|
+
const h2 = isLE4 ? 4 : 0;
|
|
55057
|
+
const l2 = isLE4 ? 0 : 4;
|
|
55058
|
+
view.setUint32(byteOffset + h2, wh, isLE4);
|
|
55059
|
+
view.setUint32(byteOffset + l2, wl, isLE4);
|
|
55060
|
+
}
|
|
55027
55061
|
function Chi2(a2, b2, c2) {
|
|
55028
55062
|
return a2 & b2 ^ ~a2 & c2;
|
|
55029
55063
|
}
|
|
@@ -55032,21 +55066,15 @@ function Maj2(a2, b2, c2) {
|
|
|
55032
55066
|
}
|
|
55033
55067
|
var HashMD2, SHA256_IV2, SHA384_IV2, SHA512_IV2;
|
|
55034
55068
|
var init_md2 = __esm({
|
|
55035
|
-
"
|
|
55069
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js"() {
|
|
55036
55070
|
init_utils2();
|
|
55037
|
-
HashMD2 = class {
|
|
55038
|
-
blockLen;
|
|
55039
|
-
outputLen;
|
|
55040
|
-
padOffset;
|
|
55041
|
-
isLE;
|
|
55042
|
-
// For partial updates less than block size
|
|
55043
|
-
buffer;
|
|
55044
|
-
view;
|
|
55045
|
-
finished = false;
|
|
55046
|
-
length = 0;
|
|
55047
|
-
pos = 0;
|
|
55048
|
-
destroyed = false;
|
|
55071
|
+
HashMD2 = class extends Hash {
|
|
55049
55072
|
constructor(blockLen, outputLen, padOffset, isLE4) {
|
|
55073
|
+
super();
|
|
55074
|
+
this.finished = false;
|
|
55075
|
+
this.length = 0;
|
|
55076
|
+
this.pos = 0;
|
|
55077
|
+
this.destroyed = false;
|
|
55050
55078
|
this.blockLen = blockLen;
|
|
55051
55079
|
this.outputLen = outputLen;
|
|
55052
55080
|
this.padOffset = padOffset;
|
|
@@ -55056,6 +55084,7 @@ var init_md2 = __esm({
|
|
|
55056
55084
|
}
|
|
55057
55085
|
update(data) {
|
|
55058
55086
|
aexists3(this);
|
|
55087
|
+
data = toBytes(data);
|
|
55059
55088
|
abytes3(data);
|
|
55060
55089
|
const { view, buffer, blockLen } = this;
|
|
55061
55090
|
const len = data.length;
|
|
@@ -55093,12 +55122,12 @@ var init_md2 = __esm({
|
|
|
55093
55122
|
}
|
|
55094
55123
|
for (let i2 = pos; i2 < blockLen; i2++)
|
|
55095
55124
|
buffer[i2] = 0;
|
|
55096
|
-
|
|
55125
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE4);
|
|
55097
55126
|
this.process(view, 0);
|
|
55098
55127
|
const oview = createView3(out);
|
|
55099
55128
|
const len = this.outputLen;
|
|
55100
55129
|
if (len % 4)
|
|
55101
|
-
throw new Error("_sha2: outputLen
|
|
55130
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
55102
55131
|
const outLen = len / 4;
|
|
55103
55132
|
const state = this.get();
|
|
55104
55133
|
if (outLen > state.length)
|
|
@@ -55114,7 +55143,7 @@ var init_md2 = __esm({
|
|
|
55114
55143
|
return res;
|
|
55115
55144
|
}
|
|
55116
55145
|
_cloneInto(to) {
|
|
55117
|
-
to
|
|
55146
|
+
to || (to = new this.constructor());
|
|
55118
55147
|
to.set(...this.get());
|
|
55119
55148
|
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
55120
55149
|
to.destroyed = destroyed;
|
|
@@ -55178,7 +55207,7 @@ var init_md2 = __esm({
|
|
|
55178
55207
|
}
|
|
55179
55208
|
});
|
|
55180
55209
|
|
|
55181
|
-
//
|
|
55210
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js
|
|
55182
55211
|
function fromBig2(n2, le2 = false) {
|
|
55183
55212
|
if (le2)
|
|
55184
55213
|
return { h: Number(n2 & U32_MASK642), l: Number(n2 >> _32n2 & U32_MASK642) };
|
|
@@ -55200,7 +55229,7 @@ function add2(Ah, Al, Bh, Bl) {
|
|
|
55200
55229
|
}
|
|
55201
55230
|
var U32_MASK642, _32n2, shrSH2, shrSL2, rotrSH2, rotrSL2, rotrBH2, rotrBL2, rotlSH2, rotlSL2, rotlBH2, rotlBL2, add3L2, add3H2, add4L2, add4H2, add5L2, add5H2;
|
|
55202
55231
|
var init_u642 = __esm({
|
|
55203
|
-
"
|
|
55232
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js"() {
|
|
55204
55233
|
U32_MASK642 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
55205
55234
|
_32n2 = /* @__PURE__ */ BigInt(32);
|
|
55206
55235
|
shrSH2 = (h2, _l, s2) => h2 >>> s2;
|
|
@@ -55222,10 +55251,10 @@ var init_u642 = __esm({
|
|
|
55222
55251
|
}
|
|
55223
55252
|
});
|
|
55224
55253
|
|
|
55225
|
-
//
|
|
55226
|
-
var SHA256_K, SHA256_W,
|
|
55254
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha2.js
|
|
55255
|
+
var SHA256_K, SHA256_W, SHA256, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA512, SHA384, sha2562, sha5122, sha3842;
|
|
55227
55256
|
var init_sha22 = __esm({
|
|
55228
|
-
"
|
|
55257
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha2.js"() {
|
|
55229
55258
|
init_md2();
|
|
55230
55259
|
init_u642();
|
|
55231
55260
|
init_utils2();
|
|
@@ -55296,9 +55325,17 @@ var init_sha22 = __esm({
|
|
|
55296
55325
|
3329325298
|
|
55297
55326
|
]);
|
|
55298
55327
|
SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
55299
|
-
|
|
55300
|
-
constructor(outputLen) {
|
|
55328
|
+
SHA256 = class extends HashMD2 {
|
|
55329
|
+
constructor(outputLen = 32) {
|
|
55301
55330
|
super(64, outputLen, 8, false);
|
|
55331
|
+
this.A = SHA256_IV2[0] | 0;
|
|
55332
|
+
this.B = SHA256_IV2[1] | 0;
|
|
55333
|
+
this.C = SHA256_IV2[2] | 0;
|
|
55334
|
+
this.D = SHA256_IV2[3] | 0;
|
|
55335
|
+
this.E = SHA256_IV2[4] | 0;
|
|
55336
|
+
this.F = SHA256_IV2[5] | 0;
|
|
55337
|
+
this.G = SHA256_IV2[6] | 0;
|
|
55338
|
+
this.H = SHA256_IV2[7] | 0;
|
|
55302
55339
|
}
|
|
55303
55340
|
get() {
|
|
55304
55341
|
const { A: A2, B: B2, C: C2, D: D2, E: E2, F: F2, G: G2, H: H2 } = this;
|
|
@@ -55358,21 +55395,6 @@ var init_sha22 = __esm({
|
|
|
55358
55395
|
clean3(this.buffer);
|
|
55359
55396
|
}
|
|
55360
55397
|
};
|
|
55361
|
-
_SHA256 = class extends SHA2_32B {
|
|
55362
|
-
// We cannot use array here since array allows indexing by variable
|
|
55363
|
-
// which means optimizer/compiler cannot use registers.
|
|
55364
|
-
A = SHA256_IV2[0] | 0;
|
|
55365
|
-
B = SHA256_IV2[1] | 0;
|
|
55366
|
-
C = SHA256_IV2[2] | 0;
|
|
55367
|
-
D = SHA256_IV2[3] | 0;
|
|
55368
|
-
E = SHA256_IV2[4] | 0;
|
|
55369
|
-
F = SHA256_IV2[5] | 0;
|
|
55370
|
-
G = SHA256_IV2[6] | 0;
|
|
55371
|
-
H = SHA256_IV2[7] | 0;
|
|
55372
|
-
constructor() {
|
|
55373
|
-
super(32);
|
|
55374
|
-
}
|
|
55375
|
-
};
|
|
55376
55398
|
K512 = /* @__PURE__ */ (() => split2([
|
|
55377
55399
|
"0x428a2f98d728ae22",
|
|
55378
55400
|
"0x7137449123ef65cd",
|
|
@@ -55459,9 +55481,25 @@ var init_sha22 = __esm({
|
|
|
55459
55481
|
SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
|
|
55460
55482
|
SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
55461
55483
|
SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
55462
|
-
|
|
55463
|
-
constructor(outputLen) {
|
|
55484
|
+
SHA512 = class extends HashMD2 {
|
|
55485
|
+
constructor(outputLen = 64) {
|
|
55464
55486
|
super(128, outputLen, 16, false);
|
|
55487
|
+
this.Ah = SHA512_IV2[0] | 0;
|
|
55488
|
+
this.Al = SHA512_IV2[1] | 0;
|
|
55489
|
+
this.Bh = SHA512_IV2[2] | 0;
|
|
55490
|
+
this.Bl = SHA512_IV2[3] | 0;
|
|
55491
|
+
this.Ch = SHA512_IV2[4] | 0;
|
|
55492
|
+
this.Cl = SHA512_IV2[5] | 0;
|
|
55493
|
+
this.Dh = SHA512_IV2[6] | 0;
|
|
55494
|
+
this.Dl = SHA512_IV2[7] | 0;
|
|
55495
|
+
this.Eh = SHA512_IV2[8] | 0;
|
|
55496
|
+
this.El = SHA512_IV2[9] | 0;
|
|
55497
|
+
this.Fh = SHA512_IV2[10] | 0;
|
|
55498
|
+
this.Fl = SHA512_IV2[11] | 0;
|
|
55499
|
+
this.Gh = SHA512_IV2[12] | 0;
|
|
55500
|
+
this.Gl = SHA512_IV2[13] | 0;
|
|
55501
|
+
this.Hh = SHA512_IV2[14] | 0;
|
|
55502
|
+
this.Hl = SHA512_IV2[15] | 0;
|
|
55465
55503
|
}
|
|
55466
55504
|
// prettier-ignore
|
|
55467
55505
|
get() {
|
|
@@ -55554,87 +55592,55 @@ var init_sha22 = __esm({
|
|
|
55554
55592
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
55555
55593
|
}
|
|
55556
55594
|
};
|
|
55557
|
-
|
|
55558
|
-
Ah = SHA512_IV2[0] | 0;
|
|
55559
|
-
Al = SHA512_IV2[1] | 0;
|
|
55560
|
-
Bh = SHA512_IV2[2] | 0;
|
|
55561
|
-
Bl = SHA512_IV2[3] | 0;
|
|
55562
|
-
Ch = SHA512_IV2[4] | 0;
|
|
55563
|
-
Cl = SHA512_IV2[5] | 0;
|
|
55564
|
-
Dh = SHA512_IV2[6] | 0;
|
|
55565
|
-
Dl = SHA512_IV2[7] | 0;
|
|
55566
|
-
Eh = SHA512_IV2[8] | 0;
|
|
55567
|
-
El = SHA512_IV2[9] | 0;
|
|
55568
|
-
Fh = SHA512_IV2[10] | 0;
|
|
55569
|
-
Fl = SHA512_IV2[11] | 0;
|
|
55570
|
-
Gh = SHA512_IV2[12] | 0;
|
|
55571
|
-
Gl = SHA512_IV2[13] | 0;
|
|
55572
|
-
Hh = SHA512_IV2[14] | 0;
|
|
55573
|
-
Hl = SHA512_IV2[15] | 0;
|
|
55574
|
-
constructor() {
|
|
55575
|
-
super(64);
|
|
55576
|
-
}
|
|
55577
|
-
};
|
|
55578
|
-
_SHA384 = class extends SHA2_64B {
|
|
55579
|
-
Ah = SHA384_IV2[0] | 0;
|
|
55580
|
-
Al = SHA384_IV2[1] | 0;
|
|
55581
|
-
Bh = SHA384_IV2[2] | 0;
|
|
55582
|
-
Bl = SHA384_IV2[3] | 0;
|
|
55583
|
-
Ch = SHA384_IV2[4] | 0;
|
|
55584
|
-
Cl = SHA384_IV2[5] | 0;
|
|
55585
|
-
Dh = SHA384_IV2[6] | 0;
|
|
55586
|
-
Dl = SHA384_IV2[7] | 0;
|
|
55587
|
-
Eh = SHA384_IV2[8] | 0;
|
|
55588
|
-
El = SHA384_IV2[9] | 0;
|
|
55589
|
-
Fh = SHA384_IV2[10] | 0;
|
|
55590
|
-
Fl = SHA384_IV2[11] | 0;
|
|
55591
|
-
Gh = SHA384_IV2[12] | 0;
|
|
55592
|
-
Gl = SHA384_IV2[13] | 0;
|
|
55593
|
-
Hh = SHA384_IV2[14] | 0;
|
|
55594
|
-
Hl = SHA384_IV2[15] | 0;
|
|
55595
|
+
SHA384 = class extends SHA512 {
|
|
55595
55596
|
constructor() {
|
|
55596
55597
|
super(48);
|
|
55597
|
-
|
|
55598
|
-
|
|
55599
|
-
|
|
55600
|
-
|
|
55601
|
-
|
|
55602
|
-
|
|
55603
|
-
|
|
55604
|
-
|
|
55605
|
-
|
|
55606
|
-
|
|
55607
|
-
|
|
55608
|
-
|
|
55609
|
-
|
|
55610
|
-
|
|
55598
|
+
this.Ah = SHA384_IV2[0] | 0;
|
|
55599
|
+
this.Al = SHA384_IV2[1] | 0;
|
|
55600
|
+
this.Bh = SHA384_IV2[2] | 0;
|
|
55601
|
+
this.Bl = SHA384_IV2[3] | 0;
|
|
55602
|
+
this.Ch = SHA384_IV2[4] | 0;
|
|
55603
|
+
this.Cl = SHA384_IV2[5] | 0;
|
|
55604
|
+
this.Dh = SHA384_IV2[6] | 0;
|
|
55605
|
+
this.Dl = SHA384_IV2[7] | 0;
|
|
55606
|
+
this.Eh = SHA384_IV2[8] | 0;
|
|
55607
|
+
this.El = SHA384_IV2[9] | 0;
|
|
55608
|
+
this.Fh = SHA384_IV2[10] | 0;
|
|
55609
|
+
this.Fl = SHA384_IV2[11] | 0;
|
|
55610
|
+
this.Gh = SHA384_IV2[12] | 0;
|
|
55611
|
+
this.Gl = SHA384_IV2[13] | 0;
|
|
55612
|
+
this.Hh = SHA384_IV2[14] | 0;
|
|
55613
|
+
this.Hl = SHA384_IV2[15] | 0;
|
|
55614
|
+
}
|
|
55615
|
+
};
|
|
55616
|
+
sha2562 = /* @__PURE__ */ createHasher2(() => new SHA256());
|
|
55617
|
+
sha5122 = /* @__PURE__ */ createHasher2(() => new SHA512());
|
|
55618
|
+
sha3842 = /* @__PURE__ */ createHasher2(() => new SHA384());
|
|
55611
55619
|
}
|
|
55612
55620
|
});
|
|
55613
55621
|
|
|
55614
|
-
//
|
|
55615
|
-
function
|
|
55622
|
+
// ../../node_modules/@noble/curves/esm/utils.js
|
|
55623
|
+
function _abool2(value, title = "") {
|
|
55616
55624
|
if (typeof value !== "boolean") {
|
|
55617
|
-
const prefix = title && `"${title}"
|
|
55625
|
+
const prefix = title && `"${title}"`;
|
|
55618
55626
|
throw new Error(prefix + "expected boolean, got type=" + typeof value);
|
|
55619
55627
|
}
|
|
55620
55628
|
return value;
|
|
55621
55629
|
}
|
|
55622
|
-
function
|
|
55623
|
-
|
|
55624
|
-
|
|
55625
|
-
|
|
55626
|
-
|
|
55627
|
-
anumber3(n2);
|
|
55628
|
-
return n2;
|
|
55629
|
-
}
|
|
55630
|
-
function asafenumber(value, title = "") {
|
|
55631
|
-
if (!Number.isSafeInteger(value)) {
|
|
55630
|
+
function _abytes2(value, length, title = "") {
|
|
55631
|
+
const bytes = isBytes3(value);
|
|
55632
|
+
const len = value?.length;
|
|
55633
|
+
const needsLen = length !== void 0;
|
|
55634
|
+
if (!bytes || needsLen && len !== length) {
|
|
55632
55635
|
const prefix = title && `"${title}" `;
|
|
55633
|
-
|
|
55636
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
55637
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
55638
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
55634
55639
|
}
|
|
55640
|
+
return value;
|
|
55635
55641
|
}
|
|
55636
55642
|
function numberToHexUnpadded(num) {
|
|
55637
|
-
const hex3 =
|
|
55643
|
+
const hex3 = num.toString(16);
|
|
55638
55644
|
return hex3.length & 1 ? "0" + hex3 : hex3;
|
|
55639
55645
|
}
|
|
55640
55646
|
function hexToNumber3(hex3) {
|
|
@@ -55646,19 +55652,33 @@ function bytesToNumberBE(bytes) {
|
|
|
55646
55652
|
return hexToNumber3(bytesToHex3(bytes));
|
|
55647
55653
|
}
|
|
55648
55654
|
function bytesToNumberLE2(bytes) {
|
|
55649
|
-
|
|
55655
|
+
abytes3(bytes);
|
|
55656
|
+
return hexToNumber3(bytesToHex3(Uint8Array.from(bytes).reverse()));
|
|
55650
55657
|
}
|
|
55651
55658
|
function numberToBytesBE2(n2, len) {
|
|
55652
|
-
|
|
55653
|
-
n2 = abignumber(n2);
|
|
55654
|
-
const res = hexToBytes3(n2.toString(16).padStart(len * 2, "0"));
|
|
55655
|
-
if (res.length !== len)
|
|
55656
|
-
throw new Error("number too large");
|
|
55657
|
-
return res;
|
|
55659
|
+
return hexToBytes3(n2.toString(16).padStart(len * 2, "0"));
|
|
55658
55660
|
}
|
|
55659
55661
|
function numberToBytesLE2(n2, len) {
|
|
55660
55662
|
return numberToBytesBE2(n2, len).reverse();
|
|
55661
55663
|
}
|
|
55664
|
+
function ensureBytes(title, hex3, expectedLength) {
|
|
55665
|
+
let res;
|
|
55666
|
+
if (typeof hex3 === "string") {
|
|
55667
|
+
try {
|
|
55668
|
+
res = hexToBytes3(hex3);
|
|
55669
|
+
} catch (e) {
|
|
55670
|
+
throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
|
|
55671
|
+
}
|
|
55672
|
+
} else if (isBytes3(hex3)) {
|
|
55673
|
+
res = Uint8Array.from(hex3);
|
|
55674
|
+
} else {
|
|
55675
|
+
throw new Error(title + " must be hex string or Uint8Array");
|
|
55676
|
+
}
|
|
55677
|
+
const len = res.length;
|
|
55678
|
+
if (typeof expectedLength === "number" && len !== expectedLength)
|
|
55679
|
+
throw new Error(title + " of length " + expectedLength + " expected, got " + len);
|
|
55680
|
+
return res;
|
|
55681
|
+
}
|
|
55662
55682
|
function equalBytes2(a2, b2) {
|
|
55663
55683
|
if (a2.length !== b2.length)
|
|
55664
55684
|
return false;
|
|
@@ -55693,15 +55713,14 @@ function bitLen(n2) {
|
|
|
55693
55713
|
return len;
|
|
55694
55714
|
}
|
|
55695
55715
|
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
55696
|
-
|
|
55697
|
-
|
|
55716
|
+
if (typeof hashLen !== "number" || hashLen < 2)
|
|
55717
|
+
throw new Error("hashLen must be a number");
|
|
55718
|
+
if (typeof qByteLen !== "number" || qByteLen < 2)
|
|
55719
|
+
throw new Error("qByteLen must be a number");
|
|
55698
55720
|
if (typeof hmacFn !== "function")
|
|
55699
55721
|
throw new Error("hmacFn must be a function");
|
|
55700
55722
|
const u8n = (len) => new Uint8Array(len);
|
|
55701
|
-
const
|
|
55702
|
-
const byte0 = Uint8Array.of(0);
|
|
55703
|
-
const byte1 = Uint8Array.of(1);
|
|
55704
|
-
const _maxDrbgIters = 1e3;
|
|
55723
|
+
const u8of = (byte) => Uint8Array.of(byte);
|
|
55705
55724
|
let v2 = u8n(hashLen);
|
|
55706
55725
|
let k2 = u8n(hashLen);
|
|
55707
55726
|
let i2 = 0;
|
|
@@ -55710,18 +55729,18 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
55710
55729
|
k2.fill(0);
|
|
55711
55730
|
i2 = 0;
|
|
55712
55731
|
};
|
|
55713
|
-
const h2 = (...
|
|
55714
|
-
const reseed = (seed =
|
|
55715
|
-
k2 = h2(
|
|
55732
|
+
const h2 = (...b2) => hmacFn(k2, v2, ...b2);
|
|
55733
|
+
const reseed = (seed = u8n(0)) => {
|
|
55734
|
+
k2 = h2(u8of(0), seed);
|
|
55716
55735
|
v2 = h2();
|
|
55717
55736
|
if (seed.length === 0)
|
|
55718
55737
|
return;
|
|
55719
|
-
k2 = h2(
|
|
55738
|
+
k2 = h2(u8of(1), seed);
|
|
55720
55739
|
v2 = h2();
|
|
55721
55740
|
};
|
|
55722
55741
|
const gen = () => {
|
|
55723
|
-
if (i2++ >=
|
|
55724
|
-
throw new Error("drbg: tried
|
|
55742
|
+
if (i2++ >= 1e3)
|
|
55743
|
+
throw new Error("drbg: tried 1000 values");
|
|
55725
55744
|
let len = 0;
|
|
55726
55745
|
const out = [];
|
|
55727
55746
|
while (len < qByteLen) {
|
|
@@ -55743,7 +55762,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
55743
55762
|
};
|
|
55744
55763
|
return genUntil;
|
|
55745
55764
|
}
|
|
55746
|
-
function
|
|
55765
|
+
function isHash(val) {
|
|
55766
|
+
return typeof val === "function" && Number.isSafeInteger(val.outputLen);
|
|
55767
|
+
}
|
|
55768
|
+
function _validateObject(object3, fields, optFields = {}) {
|
|
55747
55769
|
if (!object3 || typeof object3 !== "object")
|
|
55748
55770
|
throw new Error("expected valid options object");
|
|
55749
55771
|
function checkField(fieldName, expectedType, isOpt) {
|
|
@@ -55754,9 +55776,8 @@ function validateObject2(object3, fields = {}, optFields = {}) {
|
|
|
55754
55776
|
if (current !== expectedType || val === null)
|
|
55755
55777
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
55756
55778
|
}
|
|
55757
|
-
|
|
55758
|
-
|
|
55759
|
-
iter(optFields, true);
|
|
55779
|
+
Object.entries(fields).forEach(([k2, v2]) => checkField(k2, v2, false));
|
|
55780
|
+
Object.entries(optFields).forEach(([k2, v2]) => checkField(k2, v2, true));
|
|
55760
55781
|
}
|
|
55761
55782
|
function memoized(fn) {
|
|
55762
55783
|
const map2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -55771,7 +55792,7 @@ function memoized(fn) {
|
|
|
55771
55792
|
}
|
|
55772
55793
|
var _0n2, _1n2, isPosBig, bitMask, notImplemented;
|
|
55773
55794
|
var init_utils3 = __esm({
|
|
55774
|
-
"
|
|
55795
|
+
"../../node_modules/@noble/curves/esm/utils.js"() {
|
|
55775
55796
|
init_utils2();
|
|
55776
55797
|
init_utils2();
|
|
55777
55798
|
_0n2 = /* @__PURE__ */ BigInt(0);
|
|
@@ -55784,7 +55805,7 @@ var init_utils3 = __esm({
|
|
|
55784
55805
|
}
|
|
55785
55806
|
});
|
|
55786
55807
|
|
|
55787
|
-
//
|
|
55808
|
+
// ../../node_modules/@noble/curves/esm/abstract/modular.js
|
|
55788
55809
|
function mod3(a2, b2) {
|
|
55789
55810
|
const result = a2 % b2;
|
|
55790
55811
|
return result >= _0n3 ? result : b2 + result;
|
|
@@ -55920,6 +55941,7 @@ function FpSqrt(P2) {
|
|
|
55920
55941
|
function validateField(field) {
|
|
55921
55942
|
const initial = {
|
|
55922
55943
|
ORDER: "bigint",
|
|
55944
|
+
MASK: "bigint",
|
|
55923
55945
|
BYTES: "number",
|
|
55924
55946
|
BITS: "number"
|
|
55925
55947
|
};
|
|
@@ -55927,7 +55949,7 @@ function validateField(field) {
|
|
|
55927
55949
|
map2[val] = "function";
|
|
55928
55950
|
return map2;
|
|
55929
55951
|
}, initial);
|
|
55930
|
-
|
|
55952
|
+
_validateObject(field, opts);
|
|
55931
55953
|
return field;
|
|
55932
55954
|
}
|
|
55933
55955
|
function FpPow(Fp3, num, power) {
|
|
@@ -55981,8 +56003,102 @@ function nLength(n2, nBitLength) {
|
|
|
55981
56003
|
const nByteLength = Math.ceil(_nBitLength / 8);
|
|
55982
56004
|
return { nBitLength: _nBitLength, nByteLength };
|
|
55983
56005
|
}
|
|
55984
|
-
function Field(ORDER, opts = {}) {
|
|
55985
|
-
|
|
56006
|
+
function Field(ORDER, bitLenOrOpts, isLE4 = false, opts = {}) {
|
|
56007
|
+
if (ORDER <= _0n3)
|
|
56008
|
+
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
|
56009
|
+
let _nbitLength = void 0;
|
|
56010
|
+
let _sqrt = void 0;
|
|
56011
|
+
let modFromBytes = false;
|
|
56012
|
+
let allowedLengths = void 0;
|
|
56013
|
+
if (typeof bitLenOrOpts === "object" && bitLenOrOpts != null) {
|
|
56014
|
+
if (opts.sqrt || isLE4)
|
|
56015
|
+
throw new Error("cannot specify opts in two arguments");
|
|
56016
|
+
const _opts = bitLenOrOpts;
|
|
56017
|
+
if (_opts.BITS)
|
|
56018
|
+
_nbitLength = _opts.BITS;
|
|
56019
|
+
if (_opts.sqrt)
|
|
56020
|
+
_sqrt = _opts.sqrt;
|
|
56021
|
+
if (typeof _opts.isLE === "boolean")
|
|
56022
|
+
isLE4 = _opts.isLE;
|
|
56023
|
+
if (typeof _opts.modFromBytes === "boolean")
|
|
56024
|
+
modFromBytes = _opts.modFromBytes;
|
|
56025
|
+
allowedLengths = _opts.allowedLengths;
|
|
56026
|
+
} else {
|
|
56027
|
+
if (typeof bitLenOrOpts === "number")
|
|
56028
|
+
_nbitLength = bitLenOrOpts;
|
|
56029
|
+
if (opts.sqrt)
|
|
56030
|
+
_sqrt = opts.sqrt;
|
|
56031
|
+
}
|
|
56032
|
+
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, _nbitLength);
|
|
56033
|
+
if (BYTES > 2048)
|
|
56034
|
+
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
56035
|
+
let sqrtP;
|
|
56036
|
+
const f2 = Object.freeze({
|
|
56037
|
+
ORDER,
|
|
56038
|
+
isLE: isLE4,
|
|
56039
|
+
BITS,
|
|
56040
|
+
BYTES,
|
|
56041
|
+
MASK: bitMask(BITS),
|
|
56042
|
+
ZERO: _0n3,
|
|
56043
|
+
ONE: _1n3,
|
|
56044
|
+
allowedLengths,
|
|
56045
|
+
create: (num) => mod3(num, ORDER),
|
|
56046
|
+
isValid: (num) => {
|
|
56047
|
+
if (typeof num !== "bigint")
|
|
56048
|
+
throw new Error("invalid field element: expected bigint, got " + typeof num);
|
|
56049
|
+
return _0n3 <= num && num < ORDER;
|
|
56050
|
+
},
|
|
56051
|
+
is0: (num) => num === _0n3,
|
|
56052
|
+
// is valid and invertible
|
|
56053
|
+
isValidNot0: (num) => !f2.is0(num) && f2.isValid(num),
|
|
56054
|
+
isOdd: (num) => (num & _1n3) === _1n3,
|
|
56055
|
+
neg: (num) => mod3(-num, ORDER),
|
|
56056
|
+
eql: (lhs, rhs) => lhs === rhs,
|
|
56057
|
+
sqr: (num) => mod3(num * num, ORDER),
|
|
56058
|
+
add: (lhs, rhs) => mod3(lhs + rhs, ORDER),
|
|
56059
|
+
sub: (lhs, rhs) => mod3(lhs - rhs, ORDER),
|
|
56060
|
+
mul: (lhs, rhs) => mod3(lhs * rhs, ORDER),
|
|
56061
|
+
pow: (num, power) => FpPow(f2, num, power),
|
|
56062
|
+
div: (lhs, rhs) => mod3(lhs * invert(rhs, ORDER), ORDER),
|
|
56063
|
+
// Same as above, but doesn't normalize
|
|
56064
|
+
sqrN: (num) => num * num,
|
|
56065
|
+
addN: (lhs, rhs) => lhs + rhs,
|
|
56066
|
+
subN: (lhs, rhs) => lhs - rhs,
|
|
56067
|
+
mulN: (lhs, rhs) => lhs * rhs,
|
|
56068
|
+
inv: (num) => invert(num, ORDER),
|
|
56069
|
+
sqrt: _sqrt || ((n2) => {
|
|
56070
|
+
if (!sqrtP)
|
|
56071
|
+
sqrtP = FpSqrt(ORDER);
|
|
56072
|
+
return sqrtP(f2, n2);
|
|
56073
|
+
}),
|
|
56074
|
+
toBytes: (num) => isLE4 ? numberToBytesLE2(num, BYTES) : numberToBytesBE2(num, BYTES),
|
|
56075
|
+
fromBytes: (bytes, skipValidation = true) => {
|
|
56076
|
+
if (allowedLengths) {
|
|
56077
|
+
if (!allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
|
|
56078
|
+
throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
|
|
56079
|
+
}
|
|
56080
|
+
const padded = new Uint8Array(BYTES);
|
|
56081
|
+
padded.set(bytes, isLE4 ? 0 : padded.length - bytes.length);
|
|
56082
|
+
bytes = padded;
|
|
56083
|
+
}
|
|
56084
|
+
if (bytes.length !== BYTES)
|
|
56085
|
+
throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
|
|
56086
|
+
let scalar = isLE4 ? bytesToNumberLE2(bytes) : bytesToNumberBE(bytes);
|
|
56087
|
+
if (modFromBytes)
|
|
56088
|
+
scalar = mod3(scalar, ORDER);
|
|
56089
|
+
if (!skipValidation) {
|
|
56090
|
+
if (!f2.isValid(scalar))
|
|
56091
|
+
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
56092
|
+
}
|
|
56093
|
+
return scalar;
|
|
56094
|
+
},
|
|
56095
|
+
// TODO: we don't need it here, move out to separate fn
|
|
56096
|
+
invertBatch: (lst) => FpInvertBatch(f2, lst),
|
|
56097
|
+
// We can't move this out because Fp6, Fp12 implement it
|
|
56098
|
+
// and it's unclear what to return in there.
|
|
56099
|
+
cmov: (a2, b2, c2) => c2 ? b2 : a2
|
|
56100
|
+
});
|
|
56101
|
+
return Object.freeze(f2);
|
|
55986
56102
|
}
|
|
55987
56103
|
function FpSqrtEven(Fp3, elm) {
|
|
55988
56104
|
if (!Fp3.isOdd)
|
|
@@ -56001,7 +56117,6 @@ function getMinHashLength(fieldOrder) {
|
|
|
56001
56117
|
return length + Math.ceil(length / 2);
|
|
56002
56118
|
}
|
|
56003
56119
|
function mapHashToField(key, fieldOrder, isLE4 = false) {
|
|
56004
|
-
abytes3(key);
|
|
56005
56120
|
const len = key.length;
|
|
56006
56121
|
const fieldLen = getFieldBytesLength(fieldOrder);
|
|
56007
56122
|
const minLen = getMinHashLength(fieldOrder);
|
|
@@ -56011,12 +56126,12 @@ function mapHashToField(key, fieldOrder, isLE4 = false) {
|
|
|
56011
56126
|
const reduced = mod3(num, fieldOrder - _1n3) + _1n3;
|
|
56012
56127
|
return isLE4 ? numberToBytesLE2(reduced, fieldLen) : numberToBytesBE2(reduced, fieldLen);
|
|
56013
56128
|
}
|
|
56014
|
-
var _0n3, _1n3, _2n2, _3n, _4n, _5n, _7n2, _8n, _9n, _16n, isNegativeLE, FIELD_FIELDS
|
|
56129
|
+
var _0n3, _1n3, _2n2, _3n, _4n, _5n, _7n2, _8n, _9n, _16n, isNegativeLE, FIELD_FIELDS;
|
|
56015
56130
|
var init_modular2 = __esm({
|
|
56016
|
-
"
|
|
56131
|
+
"../../node_modules/@noble/curves/esm/abstract/modular.js"() {
|
|
56017
56132
|
init_utils3();
|
|
56018
|
-
_0n3 =
|
|
56019
|
-
_1n3 =
|
|
56133
|
+
_0n3 = BigInt(0);
|
|
56134
|
+
_1n3 = BigInt(1);
|
|
56020
56135
|
_2n2 = /* @__PURE__ */ BigInt(2);
|
|
56021
56136
|
_3n = /* @__PURE__ */ BigInt(3);
|
|
56022
56137
|
_4n = /* @__PURE__ */ BigInt(4);
|
|
@@ -56045,145 +56160,10 @@ var init_modular2 = __esm({
|
|
|
56045
56160
|
"mulN",
|
|
56046
56161
|
"sqrN"
|
|
56047
56162
|
];
|
|
56048
|
-
_Field = class {
|
|
56049
|
-
ORDER;
|
|
56050
|
-
BITS;
|
|
56051
|
-
BYTES;
|
|
56052
|
-
isLE;
|
|
56053
|
-
ZERO = _0n3;
|
|
56054
|
-
ONE = _1n3;
|
|
56055
|
-
_lengths;
|
|
56056
|
-
_sqrt;
|
|
56057
|
-
// cached sqrt
|
|
56058
|
-
_mod;
|
|
56059
|
-
constructor(ORDER, opts = {}) {
|
|
56060
|
-
if (ORDER <= _0n3)
|
|
56061
|
-
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
|
56062
|
-
let _nbitLength = void 0;
|
|
56063
|
-
this.isLE = false;
|
|
56064
|
-
if (opts != null && typeof opts === "object") {
|
|
56065
|
-
if (typeof opts.BITS === "number")
|
|
56066
|
-
_nbitLength = opts.BITS;
|
|
56067
|
-
if (typeof opts.sqrt === "function")
|
|
56068
|
-
this.sqrt = opts.sqrt;
|
|
56069
|
-
if (typeof opts.isLE === "boolean")
|
|
56070
|
-
this.isLE = opts.isLE;
|
|
56071
|
-
if (opts.allowedLengths)
|
|
56072
|
-
this._lengths = opts.allowedLengths?.slice();
|
|
56073
|
-
if (typeof opts.modFromBytes === "boolean")
|
|
56074
|
-
this._mod = opts.modFromBytes;
|
|
56075
|
-
}
|
|
56076
|
-
const { nBitLength, nByteLength } = nLength(ORDER, _nbitLength);
|
|
56077
|
-
if (nByteLength > 2048)
|
|
56078
|
-
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
56079
|
-
this.ORDER = ORDER;
|
|
56080
|
-
this.BITS = nBitLength;
|
|
56081
|
-
this.BYTES = nByteLength;
|
|
56082
|
-
this._sqrt = void 0;
|
|
56083
|
-
Object.preventExtensions(this);
|
|
56084
|
-
}
|
|
56085
|
-
create(num) {
|
|
56086
|
-
return mod3(num, this.ORDER);
|
|
56087
|
-
}
|
|
56088
|
-
isValid(num) {
|
|
56089
|
-
if (typeof num !== "bigint")
|
|
56090
|
-
throw new Error("invalid field element: expected bigint, got " + typeof num);
|
|
56091
|
-
return _0n3 <= num && num < this.ORDER;
|
|
56092
|
-
}
|
|
56093
|
-
is0(num) {
|
|
56094
|
-
return num === _0n3;
|
|
56095
|
-
}
|
|
56096
|
-
// is valid and invertible
|
|
56097
|
-
isValidNot0(num) {
|
|
56098
|
-
return !this.is0(num) && this.isValid(num);
|
|
56099
|
-
}
|
|
56100
|
-
isOdd(num) {
|
|
56101
|
-
return (num & _1n3) === _1n3;
|
|
56102
|
-
}
|
|
56103
|
-
neg(num) {
|
|
56104
|
-
return mod3(-num, this.ORDER);
|
|
56105
|
-
}
|
|
56106
|
-
eql(lhs, rhs) {
|
|
56107
|
-
return lhs === rhs;
|
|
56108
|
-
}
|
|
56109
|
-
sqr(num) {
|
|
56110
|
-
return mod3(num * num, this.ORDER);
|
|
56111
|
-
}
|
|
56112
|
-
add(lhs, rhs) {
|
|
56113
|
-
return mod3(lhs + rhs, this.ORDER);
|
|
56114
|
-
}
|
|
56115
|
-
sub(lhs, rhs) {
|
|
56116
|
-
return mod3(lhs - rhs, this.ORDER);
|
|
56117
|
-
}
|
|
56118
|
-
mul(lhs, rhs) {
|
|
56119
|
-
return mod3(lhs * rhs, this.ORDER);
|
|
56120
|
-
}
|
|
56121
|
-
pow(num, power) {
|
|
56122
|
-
return FpPow(this, num, power);
|
|
56123
|
-
}
|
|
56124
|
-
div(lhs, rhs) {
|
|
56125
|
-
return mod3(lhs * invert(rhs, this.ORDER), this.ORDER);
|
|
56126
|
-
}
|
|
56127
|
-
// Same as above, but doesn't normalize
|
|
56128
|
-
sqrN(num) {
|
|
56129
|
-
return num * num;
|
|
56130
|
-
}
|
|
56131
|
-
addN(lhs, rhs) {
|
|
56132
|
-
return lhs + rhs;
|
|
56133
|
-
}
|
|
56134
|
-
subN(lhs, rhs) {
|
|
56135
|
-
return lhs - rhs;
|
|
56136
|
-
}
|
|
56137
|
-
mulN(lhs, rhs) {
|
|
56138
|
-
return lhs * rhs;
|
|
56139
|
-
}
|
|
56140
|
-
inv(num) {
|
|
56141
|
-
return invert(num, this.ORDER);
|
|
56142
|
-
}
|
|
56143
|
-
sqrt(num) {
|
|
56144
|
-
if (!this._sqrt)
|
|
56145
|
-
this._sqrt = FpSqrt(this.ORDER);
|
|
56146
|
-
return this._sqrt(this, num);
|
|
56147
|
-
}
|
|
56148
|
-
toBytes(num) {
|
|
56149
|
-
return this.isLE ? numberToBytesLE2(num, this.BYTES) : numberToBytesBE2(num, this.BYTES);
|
|
56150
|
-
}
|
|
56151
|
-
fromBytes(bytes, skipValidation = false) {
|
|
56152
|
-
abytes3(bytes);
|
|
56153
|
-
const { _lengths: allowedLengths, BYTES, isLE: isLE4, ORDER, _mod: modFromBytes } = this;
|
|
56154
|
-
if (allowedLengths) {
|
|
56155
|
-
if (!allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
|
|
56156
|
-
throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
|
|
56157
|
-
}
|
|
56158
|
-
const padded = new Uint8Array(BYTES);
|
|
56159
|
-
padded.set(bytes, isLE4 ? 0 : padded.length - bytes.length);
|
|
56160
|
-
bytes = padded;
|
|
56161
|
-
}
|
|
56162
|
-
if (bytes.length !== BYTES)
|
|
56163
|
-
throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
|
|
56164
|
-
let scalar = isLE4 ? bytesToNumberLE2(bytes) : bytesToNumberBE(bytes);
|
|
56165
|
-
if (modFromBytes)
|
|
56166
|
-
scalar = mod3(scalar, ORDER);
|
|
56167
|
-
if (!skipValidation) {
|
|
56168
|
-
if (!this.isValid(scalar))
|
|
56169
|
-
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
56170
|
-
}
|
|
56171
|
-
return scalar;
|
|
56172
|
-
}
|
|
56173
|
-
// TODO: we don't need it here, move out to separate fn
|
|
56174
|
-
invertBatch(lst) {
|
|
56175
|
-
return FpInvertBatch(this, lst);
|
|
56176
|
-
}
|
|
56177
|
-
// We can't move this out because Fp6, Fp12 implement it
|
|
56178
|
-
// and it's unclear what to return in there.
|
|
56179
|
-
cmov(a2, b2, condition) {
|
|
56180
|
-
return condition ? b2 : a2;
|
|
56181
|
-
}
|
|
56182
|
-
};
|
|
56183
56163
|
}
|
|
56184
56164
|
});
|
|
56185
56165
|
|
|
56186
|
-
//
|
|
56166
|
+
// ../../node_modules/@noble/curves/esm/abstract/curve.js
|
|
56187
56167
|
function negateCt(condition, item) {
|
|
56188
56168
|
const neg = item.negate();
|
|
56189
56169
|
return condition ? neg : item;
|
|
@@ -56259,8 +56239,7 @@ function mulEndoUnsafe(Point, point, k1, k2) {
|
|
|
56259
56239
|
}
|
|
56260
56240
|
return { p1, p2 };
|
|
56261
56241
|
}
|
|
56262
|
-
function pippenger(c2, points, scalars) {
|
|
56263
|
-
const fieldN = c2.Fn;
|
|
56242
|
+
function pippenger(c2, fieldN, points, scalars) {
|
|
56264
56243
|
validateMSMPoints(points, c2);
|
|
56265
56244
|
validateMSMScalars(scalars, fieldN);
|
|
56266
56245
|
const plength = points.length;
|
|
@@ -56309,7 +56288,7 @@ function createField(order, field, isLE4) {
|
|
|
56309
56288
|
return Field(order, { isLE: isLE4 });
|
|
56310
56289
|
}
|
|
56311
56290
|
}
|
|
56312
|
-
function
|
|
56291
|
+
function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
|
|
56313
56292
|
if (FpFnLE === void 0)
|
|
56314
56293
|
FpFnLE = type === "edwards";
|
|
56315
56294
|
if (!CURVE || typeof CURVE !== "object")
|
|
@@ -56330,26 +56309,16 @@ function createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
|
|
|
56330
56309
|
CURVE = Object.freeze(Object.assign({}, CURVE));
|
|
56331
56310
|
return { CURVE, Fp: Fp3, Fn: Fn3 };
|
|
56332
56311
|
}
|
|
56333
|
-
function createKeygen2(randomSecretKey, getPublicKey) {
|
|
56334
|
-
return function keygen(seed) {
|
|
56335
|
-
const secretKey = randomSecretKey(seed);
|
|
56336
|
-
return { secretKey, publicKey: getPublicKey(secretKey) };
|
|
56337
|
-
};
|
|
56338
|
-
}
|
|
56339
56312
|
var _0n4, _1n4, pointPrecomputes, pointWindowSizes, wNAF;
|
|
56340
56313
|
var init_curve2 = __esm({
|
|
56341
|
-
"
|
|
56314
|
+
"../../node_modules/@noble/curves/esm/abstract/curve.js"() {
|
|
56342
56315
|
init_utils3();
|
|
56343
56316
|
init_modular2();
|
|
56344
|
-
_0n4 =
|
|
56345
|
-
_1n4 =
|
|
56317
|
+
_0n4 = BigInt(0);
|
|
56318
|
+
_1n4 = BigInt(1);
|
|
56346
56319
|
pointPrecomputes = /* @__PURE__ */ new WeakMap();
|
|
56347
56320
|
pointWindowSizes = /* @__PURE__ */ new WeakMap();
|
|
56348
56321
|
wNAF = class {
|
|
56349
|
-
BASE;
|
|
56350
|
-
ZERO;
|
|
56351
|
-
Fn;
|
|
56352
|
-
bits;
|
|
56353
56322
|
// Parametrized with a given Point class (not individual point)
|
|
56354
56323
|
constructor(Point, bits) {
|
|
56355
56324
|
this.BASE = Point.BASE;
|
|
@@ -56479,7 +56448,7 @@ var init_curve2 = __esm({
|
|
|
56479
56448
|
}
|
|
56480
56449
|
});
|
|
56481
56450
|
|
|
56482
|
-
//
|
|
56451
|
+
// ../../node_modules/@noble/curves/esm/abstract/edwards.js
|
|
56483
56452
|
function isEdValidXY(Fp3, CURVE, x2, y2) {
|
|
56484
56453
|
const x22 = Fp3.sqr(x2);
|
|
56485
56454
|
const y22 = Fp3.sqr(y2);
|
|
@@ -56488,11 +56457,11 @@ function isEdValidXY(Fp3, CURVE, x2, y2) {
|
|
|
56488
56457
|
return Fp3.eql(left2, right2);
|
|
56489
56458
|
}
|
|
56490
56459
|
function edwards(params, extraOpts = {}) {
|
|
56491
|
-
const validated =
|
|
56460
|
+
const validated = _createCurveFields("edwards", params, extraOpts, extraOpts.FpFnLE);
|
|
56492
56461
|
const { Fp: Fp3, Fn: Fn3 } = validated;
|
|
56493
56462
|
let CURVE = validated.CURVE;
|
|
56494
56463
|
const { h: cofactor } = CURVE;
|
|
56495
|
-
|
|
56464
|
+
_validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
56496
56465
|
const MASK = _2n3 << BigInt(Fn3.BYTES * 8) - _1n5;
|
|
56497
56466
|
const modP = (n2) => Fp3.create(n2);
|
|
56498
56467
|
const uvRatio3 = extraOpts.uvRatio || ((u2, v2) => {
|
|
@@ -56509,9 +56478,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
56509
56478
|
aInRange2("coordinate " + title, n2, min, MASK);
|
|
56510
56479
|
return n2;
|
|
56511
56480
|
}
|
|
56512
|
-
function
|
|
56481
|
+
function aextpoint(other) {
|
|
56513
56482
|
if (!(other instanceof Point))
|
|
56514
|
-
throw new Error("
|
|
56483
|
+
throw new Error("ExtendedPoint expected");
|
|
56515
56484
|
}
|
|
56516
56485
|
const toAffineMemo = memoized((p2, iz) => {
|
|
56517
56486
|
const { X: X2, Y: Y2, Z: Z2 } = p2;
|
|
@@ -56548,19 +56517,6 @@ function edwards(params, extraOpts = {}) {
|
|
|
56548
56517
|
return true;
|
|
56549
56518
|
});
|
|
56550
56519
|
class Point {
|
|
56551
|
-
// base / generator point
|
|
56552
|
-
static BASE = new Point(CURVE.Gx, CURVE.Gy, _1n5, modP(CURVE.Gx * CURVE.Gy));
|
|
56553
|
-
// zero / infinity / identity point
|
|
56554
|
-
static ZERO = new Point(_0n5, _1n5, _1n5, _0n5);
|
|
56555
|
-
// 0, 1, 1, 0
|
|
56556
|
-
// math field
|
|
56557
|
-
static Fp = Fp3;
|
|
56558
|
-
// scalar field
|
|
56559
|
-
static Fn = Fn3;
|
|
56560
|
-
X;
|
|
56561
|
-
Y;
|
|
56562
|
-
Z;
|
|
56563
|
-
T;
|
|
56564
56520
|
constructor(X2, Y2, Z2, T2) {
|
|
56565
56521
|
this.X = acoord("x", X2);
|
|
56566
56522
|
this.Y = acoord("y", Y2);
|
|
@@ -56583,8 +56539,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
56583
56539
|
static fromBytes(bytes, zip215 = false) {
|
|
56584
56540
|
const len = Fp3.BYTES;
|
|
56585
56541
|
const { a: a2, d: d2 } = CURVE;
|
|
56586
|
-
bytes = copyBytes3(
|
|
56587
|
-
|
|
56542
|
+
bytes = copyBytes3(_abytes2(bytes, len, "point"));
|
|
56543
|
+
_abool2(zip215, "zip215");
|
|
56588
56544
|
const normed = copyBytes3(bytes);
|
|
56589
56545
|
const lastByte = bytes[len - 1];
|
|
56590
56546
|
normed[len - 1] = lastByte & ~128;
|
|
@@ -56605,8 +56561,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
56605
56561
|
x2 = modP(-x2);
|
|
56606
56562
|
return Point.fromAffine({ x: x2, y: y2 });
|
|
56607
56563
|
}
|
|
56608
|
-
static fromHex(
|
|
56609
|
-
return Point.fromBytes(
|
|
56564
|
+
static fromHex(bytes, zip215 = false) {
|
|
56565
|
+
return Point.fromBytes(ensureBytes("point", bytes), zip215);
|
|
56610
56566
|
}
|
|
56611
56567
|
get x() {
|
|
56612
56568
|
return this.toAffine().x;
|
|
@@ -56626,7 +56582,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
56626
56582
|
}
|
|
56627
56583
|
// Compare one point to another.
|
|
56628
56584
|
equals(other) {
|
|
56629
|
-
|
|
56585
|
+
aextpoint(other);
|
|
56630
56586
|
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
56631
56587
|
const { X: X2, Y: Y2, Z: Z2 } = other;
|
|
56632
56588
|
const X1Z2 = modP(X1 * Z2);
|
|
@@ -56666,7 +56622,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
56666
56622
|
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
|
|
56667
56623
|
// Cost: 9M + 1*a + 1*d + 7add.
|
|
56668
56624
|
add(other) {
|
|
56669
|
-
|
|
56625
|
+
aextpoint(other);
|
|
56670
56626
|
const { a: a2, d: d2 } = CURVE;
|
|
56671
56627
|
const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
|
|
56672
56628
|
const { X: X2, Y: Y2, Z: Z2, T: T2 } = other;
|
|
@@ -56742,7 +56698,36 @@ function edwards(params, extraOpts = {}) {
|
|
|
56742
56698
|
toString() {
|
|
56743
56699
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
56744
56700
|
}
|
|
56701
|
+
// TODO: remove
|
|
56702
|
+
get ex() {
|
|
56703
|
+
return this.X;
|
|
56704
|
+
}
|
|
56705
|
+
get ey() {
|
|
56706
|
+
return this.Y;
|
|
56707
|
+
}
|
|
56708
|
+
get ez() {
|
|
56709
|
+
return this.Z;
|
|
56710
|
+
}
|
|
56711
|
+
get et() {
|
|
56712
|
+
return this.T;
|
|
56713
|
+
}
|
|
56714
|
+
static normalizeZ(points) {
|
|
56715
|
+
return normalizeZ(Point, points);
|
|
56716
|
+
}
|
|
56717
|
+
static msm(points, scalars) {
|
|
56718
|
+
return pippenger(Point, Fn3, points, scalars);
|
|
56719
|
+
}
|
|
56720
|
+
_setWindowSize(windowSize) {
|
|
56721
|
+
this.precompute(windowSize);
|
|
56722
|
+
}
|
|
56723
|
+
toRawBytes() {
|
|
56724
|
+
return this.toBytes();
|
|
56725
|
+
}
|
|
56745
56726
|
}
|
|
56727
|
+
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n5, modP(CURVE.Gx * CURVE.Gy));
|
|
56728
|
+
Point.ZERO = new Point(_0n5, _1n5, _1n5, _0n5);
|
|
56729
|
+
Point.Fp = Fp3;
|
|
56730
|
+
Point.Fn = Fn3;
|
|
56746
56731
|
const wnaf = new wNAF(Point, Fn3.BITS);
|
|
56747
56732
|
Point.BASE.precompute(8);
|
|
56748
56733
|
return Point;
|
|
@@ -56750,7 +56735,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
56750
56735
|
function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
56751
56736
|
if (typeof cHash !== "function")
|
|
56752
56737
|
throw new Error('"hash" function param is required');
|
|
56753
|
-
|
|
56738
|
+
_validateObject(eddsaOpts, {}, {
|
|
56754
56739
|
adjustScalarBytes: "function",
|
|
56755
56740
|
randomBytes: "function",
|
|
56756
56741
|
domain: "function",
|
|
@@ -56762,7 +56747,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56762
56747
|
const randomBytes3 = eddsaOpts.randomBytes || randomBytes2;
|
|
56763
56748
|
const adjustScalarBytes3 = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
|
|
56764
56749
|
const domain2 = eddsaOpts.domain || ((data, ctx, phflag) => {
|
|
56765
|
-
|
|
56750
|
+
_abool2(phflag, "phflag");
|
|
56766
56751
|
if (ctx.length || phflag)
|
|
56767
56752
|
throw new Error("Contexts/pre-hash are not supported");
|
|
56768
56753
|
return data;
|
|
@@ -56772,8 +56757,8 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56772
56757
|
}
|
|
56773
56758
|
function getPrivateScalar(key) {
|
|
56774
56759
|
const len = lengths.secretKey;
|
|
56775
|
-
|
|
56776
|
-
const hashed =
|
|
56760
|
+
key = ensureBytes("private key", key, len);
|
|
56761
|
+
const hashed = ensureBytes("hashed private key", cHash(key), 2 * len);
|
|
56777
56762
|
const head = adjustScalarBytes3(hashed.slice(0, len));
|
|
56778
56763
|
const prefix = hashed.slice(len, 2 * len);
|
|
56779
56764
|
const scalar = modN_LE(head);
|
|
@@ -56790,10 +56775,10 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56790
56775
|
}
|
|
56791
56776
|
function hashDomainToScalar(context = Uint8Array.of(), ...msgs) {
|
|
56792
56777
|
const msg = concatBytes2(...msgs);
|
|
56793
|
-
return modN_LE(cHash(domain2(msg,
|
|
56778
|
+
return modN_LE(cHash(domain2(msg, ensureBytes("context", context), !!prehash)));
|
|
56794
56779
|
}
|
|
56795
56780
|
function sign(msg, secretKey, options = {}) {
|
|
56796
|
-
msg =
|
|
56781
|
+
msg = ensureBytes("message", msg);
|
|
56797
56782
|
if (prehash)
|
|
56798
56783
|
msg = prehash(msg);
|
|
56799
56784
|
const { prefix, scalar, pointBytes } = getExtendedPublicKey(secretKey);
|
|
@@ -56804,17 +56789,17 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56804
56789
|
if (!Fn3.isValid(s2))
|
|
56805
56790
|
throw new Error("sign failed: invalid s");
|
|
56806
56791
|
const rs = concatBytes2(R2, Fn3.toBytes(s2));
|
|
56807
|
-
return
|
|
56792
|
+
return _abytes2(rs, lengths.signature, "result");
|
|
56808
56793
|
}
|
|
56809
56794
|
const verifyOpts = { zip215: true };
|
|
56810
56795
|
function verify(sig, msg, publicKey, options = verifyOpts) {
|
|
56811
56796
|
const { context, zip215 } = options;
|
|
56812
56797
|
const len = lengths.signature;
|
|
56813
|
-
sig =
|
|
56814
|
-
msg =
|
|
56815
|
-
publicKey =
|
|
56798
|
+
sig = ensureBytes("signature", sig, len);
|
|
56799
|
+
msg = ensureBytes("message", msg);
|
|
56800
|
+
publicKey = ensureBytes("publicKey", publicKey, lengths.publicKey);
|
|
56816
56801
|
if (zip215 !== void 0)
|
|
56817
|
-
|
|
56802
|
+
_abool2(zip215, "zip215");
|
|
56818
56803
|
if (prehash)
|
|
56819
56804
|
msg = prehash(msg);
|
|
56820
56805
|
const mid = len / 2;
|
|
@@ -56842,7 +56827,11 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56842
56827
|
seed: _size2
|
|
56843
56828
|
};
|
|
56844
56829
|
function randomSecretKey(seed = randomBytes3(lengths.seed)) {
|
|
56845
|
-
return
|
|
56830
|
+
return _abytes2(seed, lengths.seed, "seed");
|
|
56831
|
+
}
|
|
56832
|
+
function keygen(seed) {
|
|
56833
|
+
const secretKey = utils.randomSecretKey(seed);
|
|
56834
|
+
return { secretKey, publicKey: getPublicKey(secretKey) };
|
|
56846
56835
|
}
|
|
56847
56836
|
function isValidSecretKey(key) {
|
|
56848
56837
|
return isBytes3(key) && key.length === Fn3.BYTES;
|
|
@@ -56879,13 +56868,19 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56879
56868
|
},
|
|
56880
56869
|
toMontgomerySecret(secretKey) {
|
|
56881
56870
|
const size = lengths.secretKey;
|
|
56882
|
-
|
|
56871
|
+
_abytes2(secretKey, size);
|
|
56883
56872
|
const hashed = cHash(secretKey.subarray(0, size));
|
|
56884
56873
|
return adjustScalarBytes3(hashed).subarray(0, size);
|
|
56874
|
+
},
|
|
56875
|
+
/** @deprecated */
|
|
56876
|
+
randomPrivateKey: randomSecretKey,
|
|
56877
|
+
/** @deprecated */
|
|
56878
|
+
precompute(windowSize = 8, point = Point.BASE) {
|
|
56879
|
+
return point.precompute(windowSize, false);
|
|
56885
56880
|
}
|
|
56886
56881
|
};
|
|
56887
56882
|
return Object.freeze({
|
|
56888
|
-
keygen
|
|
56883
|
+
keygen,
|
|
56889
56884
|
getPublicKey,
|
|
56890
56885
|
sign,
|
|
56891
56886
|
verify,
|
|
@@ -56894,21 +56889,55 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56894
56889
|
lengths
|
|
56895
56890
|
});
|
|
56896
56891
|
}
|
|
56892
|
+
function _eddsa_legacy_opts_to_new(c2) {
|
|
56893
|
+
const CURVE = {
|
|
56894
|
+
a: c2.a,
|
|
56895
|
+
d: c2.d,
|
|
56896
|
+
p: c2.Fp.ORDER,
|
|
56897
|
+
n: c2.n,
|
|
56898
|
+
h: c2.h,
|
|
56899
|
+
Gx: c2.Gx,
|
|
56900
|
+
Gy: c2.Gy
|
|
56901
|
+
};
|
|
56902
|
+
const Fp3 = c2.Fp;
|
|
56903
|
+
const Fn3 = Field(CURVE.n, c2.nBitLength, true);
|
|
56904
|
+
const curveOpts = { Fp: Fp3, Fn: Fn3, uvRatio: c2.uvRatio };
|
|
56905
|
+
const eddsaOpts = {
|
|
56906
|
+
randomBytes: c2.randomBytes,
|
|
56907
|
+
adjustScalarBytes: c2.adjustScalarBytes,
|
|
56908
|
+
domain: c2.domain,
|
|
56909
|
+
prehash: c2.prehash,
|
|
56910
|
+
mapToCurve: c2.mapToCurve
|
|
56911
|
+
};
|
|
56912
|
+
return { CURVE, curveOpts, hash: c2.hash, eddsaOpts };
|
|
56913
|
+
}
|
|
56914
|
+
function _eddsa_new_output_to_legacy(c2, eddsa2) {
|
|
56915
|
+
const Point = eddsa2.Point;
|
|
56916
|
+
const legacy = Object.assign({}, eddsa2, {
|
|
56917
|
+
ExtendedPoint: Point,
|
|
56918
|
+
CURVE: c2,
|
|
56919
|
+
nBitLength: Point.Fn.BITS,
|
|
56920
|
+
nByteLength: Point.Fn.BYTES
|
|
56921
|
+
});
|
|
56922
|
+
return legacy;
|
|
56923
|
+
}
|
|
56924
|
+
function twistedEdwards(c2) {
|
|
56925
|
+
const { CURVE, curveOpts, hash: hash2, eddsaOpts } = _eddsa_legacy_opts_to_new(c2);
|
|
56926
|
+
const Point = edwards(CURVE, curveOpts);
|
|
56927
|
+
const EDDSA = eddsa(Point, hash2, eddsaOpts);
|
|
56928
|
+
return _eddsa_new_output_to_legacy(c2, EDDSA);
|
|
56929
|
+
}
|
|
56897
56930
|
var _0n5, _1n5, _2n3, _8n2, PrimeEdwardsPoint;
|
|
56898
56931
|
var init_edwards = __esm({
|
|
56899
|
-
"
|
|
56932
|
+
"../../node_modules/@noble/curves/esm/abstract/edwards.js"() {
|
|
56900
56933
|
init_utils3();
|
|
56901
56934
|
init_curve2();
|
|
56935
|
+
init_modular2();
|
|
56902
56936
|
_0n5 = BigInt(0);
|
|
56903
56937
|
_1n5 = BigInt(1);
|
|
56904
56938
|
_2n3 = BigInt(2);
|
|
56905
56939
|
_8n2 = BigInt(8);
|
|
56906
56940
|
PrimeEdwardsPoint = class {
|
|
56907
|
-
static BASE;
|
|
56908
|
-
static ZERO;
|
|
56909
|
-
static Fp;
|
|
56910
|
-
static Fn;
|
|
56911
|
-
ep;
|
|
56912
56941
|
constructor(ep) {
|
|
56913
56942
|
this.ep = ep;
|
|
56914
56943
|
}
|
|
@@ -56970,14 +56999,18 @@ var init_edwards = __esm({
|
|
|
56970
56999
|
precompute(windowSize, isLazy) {
|
|
56971
57000
|
return this.init(this.ep.precompute(windowSize, isLazy));
|
|
56972
57001
|
}
|
|
57002
|
+
/** @deprecated use `toBytes` */
|
|
57003
|
+
toRawBytes() {
|
|
57004
|
+
return this.toBytes();
|
|
57005
|
+
}
|
|
56973
57006
|
};
|
|
56974
57007
|
}
|
|
56975
57008
|
});
|
|
56976
57009
|
|
|
56977
|
-
//
|
|
57010
|
+
// ../../node_modules/@noble/curves/esm/abstract/hash-to-curve.js
|
|
56978
57011
|
function i2osp(value, length) {
|
|
56979
|
-
|
|
56980
|
-
|
|
57012
|
+
anum(value);
|
|
57013
|
+
anum(length);
|
|
56981
57014
|
if (value < 0 || value >= 1 << 8 * length)
|
|
56982
57015
|
throw new Error("invalid I2OSP input: " + value);
|
|
56983
57016
|
const res = Array.from({ length }).fill(0);
|
|
@@ -56994,17 +57027,21 @@ function strxor(a2, b2) {
|
|
|
56994
57027
|
}
|
|
56995
57028
|
return arr;
|
|
56996
57029
|
}
|
|
57030
|
+
function anum(item) {
|
|
57031
|
+
if (!Number.isSafeInteger(item))
|
|
57032
|
+
throw new Error("number expected");
|
|
57033
|
+
}
|
|
56997
57034
|
function normDST(DST) {
|
|
56998
57035
|
if (!isBytes3(DST) && typeof DST !== "string")
|
|
56999
|
-
throw new Error("DST must be Uint8Array or
|
|
57000
|
-
return typeof DST === "string" ?
|
|
57036
|
+
throw new Error("DST must be Uint8Array or string");
|
|
57037
|
+
return typeof DST === "string" ? utf8ToBytes(DST) : DST;
|
|
57001
57038
|
}
|
|
57002
57039
|
function expand_message_xmd(msg, DST, lenInBytes, H2) {
|
|
57003
57040
|
abytes3(msg);
|
|
57004
|
-
|
|
57041
|
+
anum(lenInBytes);
|
|
57005
57042
|
DST = normDST(DST);
|
|
57006
57043
|
if (DST.length > 255)
|
|
57007
|
-
DST = H2(concatBytes2(
|
|
57044
|
+
DST = H2(concatBytes2(utf8ToBytes("H2C-OVERSIZE-DST-"), DST));
|
|
57008
57045
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H2;
|
|
57009
57046
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
|
57010
57047
|
if (lenInBytes > 65535 || ell > 255)
|
|
@@ -57024,27 +57061,28 @@ function expand_message_xmd(msg, DST, lenInBytes, H2) {
|
|
|
57024
57061
|
}
|
|
57025
57062
|
function expand_message_xof(msg, DST, lenInBytes, k2, H2) {
|
|
57026
57063
|
abytes3(msg);
|
|
57027
|
-
|
|
57064
|
+
anum(lenInBytes);
|
|
57028
57065
|
DST = normDST(DST);
|
|
57029
57066
|
if (DST.length > 255) {
|
|
57030
57067
|
const dkLen = Math.ceil(2 * k2 / 8);
|
|
57031
|
-
DST = H2.create({ dkLen }).update(
|
|
57068
|
+
DST = H2.create({ dkLen }).update(utf8ToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
|
|
57032
57069
|
}
|
|
57033
57070
|
if (lenInBytes > 65535 || DST.length > 255)
|
|
57034
57071
|
throw new Error("expand_message_xof: invalid lenInBytes");
|
|
57035
57072
|
return H2.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
|
|
57036
57073
|
}
|
|
57037
57074
|
function hash_to_field(msg, count, options) {
|
|
57038
|
-
|
|
57075
|
+
_validateObject(options, {
|
|
57039
57076
|
p: "bigint",
|
|
57040
57077
|
m: "number",
|
|
57041
57078
|
k: "number",
|
|
57042
57079
|
hash: "function"
|
|
57043
57080
|
});
|
|
57044
57081
|
const { p: p2, k: k2, m: m2, hash: hash2, expand, DST } = options;
|
|
57045
|
-
|
|
57082
|
+
if (!isHash(options.hash))
|
|
57083
|
+
throw new Error("expected valid hash");
|
|
57046
57084
|
abytes3(msg);
|
|
57047
|
-
|
|
57085
|
+
anum(count);
|
|
57048
57086
|
const log2p = p2.toString(2).length;
|
|
57049
57087
|
const L2 = Math.ceil((log2p + k2) / 8);
|
|
57050
57088
|
const len_in_bytes = count * m2 * L2;
|
|
@@ -57084,8 +57122,7 @@ function createHasher3(Point, mapToCurve, defaults) {
|
|
|
57084
57122
|
return P2;
|
|
57085
57123
|
}
|
|
57086
57124
|
return {
|
|
57087
|
-
defaults
|
|
57088
|
-
Point,
|
|
57125
|
+
defaults,
|
|
57089
57126
|
hashToCurve(msg, options) {
|
|
57090
57127
|
const opts = Object.assign({}, defaults, options);
|
|
57091
57128
|
const u2 = hash_to_field(msg, 2, opts);
|
|
@@ -57102,11 +57139,6 @@ function createHasher3(Point, mapToCurve, defaults) {
|
|
|
57102
57139
|
},
|
|
57103
57140
|
/** See {@link H2CHasher} */
|
|
57104
57141
|
mapToCurve(scalars) {
|
|
57105
|
-
if (defaults.m === 1) {
|
|
57106
|
-
if (typeof scalars !== "bigint")
|
|
57107
|
-
throw new Error("expected bigint (m=1)");
|
|
57108
|
-
return clear(map2([scalars]));
|
|
57109
|
-
}
|
|
57110
57142
|
if (!Array.isArray(scalars))
|
|
57111
57143
|
throw new Error("expected array of bigints");
|
|
57112
57144
|
for (const i2 of scalars)
|
|
@@ -57125,17 +57157,17 @@ function createHasher3(Point, mapToCurve, defaults) {
|
|
|
57125
57157
|
}
|
|
57126
57158
|
var os2ip, _DST_scalar;
|
|
57127
57159
|
var init_hash_to_curve = __esm({
|
|
57128
|
-
"
|
|
57160
|
+
"../../node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
|
|
57129
57161
|
init_utils3();
|
|
57130
57162
|
init_modular2();
|
|
57131
57163
|
os2ip = bytesToNumberBE;
|
|
57132
|
-
_DST_scalar =
|
|
57164
|
+
_DST_scalar = utf8ToBytes("HashToScalar-");
|
|
57133
57165
|
}
|
|
57134
57166
|
});
|
|
57135
57167
|
|
|
57136
|
-
//
|
|
57168
|
+
// ../../node_modules/@noble/curves/esm/abstract/montgomery.js
|
|
57137
57169
|
function validateOpts(curve) {
|
|
57138
|
-
|
|
57170
|
+
_validateObject(curve, {
|
|
57139
57171
|
adjustScalarBytes: "function",
|
|
57140
57172
|
powPminus2: "function"
|
|
57141
57173
|
});
|
|
@@ -57161,13 +57193,13 @@ function montgomery2(curveDef) {
|
|
|
57161
57193
|
return numberToBytesLE2(modP(u2), fieldLen);
|
|
57162
57194
|
}
|
|
57163
57195
|
function decodeU(u2) {
|
|
57164
|
-
const _u =
|
|
57196
|
+
const _u = ensureBytes("u coordinate", u2, fieldLen);
|
|
57165
57197
|
if (is25519)
|
|
57166
57198
|
_u[31] &= 127;
|
|
57167
57199
|
return modP(bytesToNumberLE2(_u));
|
|
57168
57200
|
}
|
|
57169
57201
|
function decodeScalar(scalar) {
|
|
57170
|
-
return bytesToNumberLE2(adjustScalarBytes3(
|
|
57202
|
+
return bytesToNumberLE2(adjustScalarBytes3(ensureBytes("scalar", scalar, fieldLen)));
|
|
57171
57203
|
}
|
|
57172
57204
|
function scalarMult(scalar, u2) {
|
|
57173
57205
|
const pu = montgomeryLadder(decodeU(u2), decodeScalar(scalar));
|
|
@@ -57178,8 +57210,6 @@ function montgomery2(curveDef) {
|
|
|
57178
57210
|
function scalarMultBase(scalar) {
|
|
57179
57211
|
return scalarMult(scalar, GuBytes);
|
|
57180
57212
|
}
|
|
57181
|
-
const getPublicKey = scalarMultBase;
|
|
57182
|
-
const getSharedSecret = scalarMult;
|
|
57183
57213
|
function cswap(swap, x_2, x_3) {
|
|
57184
57214
|
const dummy = modP(swap * (x_2 - x_3));
|
|
57185
57215
|
x_2 = modP(x_2 - dummy);
|
|
@@ -57229,26 +57259,32 @@ function montgomery2(curveDef) {
|
|
|
57229
57259
|
seed: fieldLen
|
|
57230
57260
|
};
|
|
57231
57261
|
const randomSecretKey = (seed = randomBytes_(fieldLen)) => {
|
|
57232
|
-
abytes3(seed, lengths.seed
|
|
57262
|
+
abytes3(seed, lengths.seed);
|
|
57233
57263
|
return seed;
|
|
57234
57264
|
};
|
|
57235
|
-
|
|
57236
|
-
|
|
57237
|
-
|
|
57238
|
-
|
|
57239
|
-
|
|
57265
|
+
function keygen(seed) {
|
|
57266
|
+
const secretKey = randomSecretKey(seed);
|
|
57267
|
+
return { secretKey, publicKey: scalarMultBase(secretKey) };
|
|
57268
|
+
}
|
|
57269
|
+
const utils = {
|
|
57270
|
+
randomSecretKey,
|
|
57271
|
+
randomPrivateKey: randomSecretKey
|
|
57272
|
+
};
|
|
57273
|
+
return {
|
|
57274
|
+
keygen,
|
|
57275
|
+
getSharedSecret: (secretKey, publicKey) => scalarMult(secretKey, publicKey),
|
|
57276
|
+
getPublicKey: (secretKey) => scalarMultBase(secretKey),
|
|
57240
57277
|
scalarMult,
|
|
57241
57278
|
scalarMultBase,
|
|
57242
57279
|
utils,
|
|
57243
57280
|
GuBytes: GuBytes.slice(),
|
|
57244
57281
|
lengths
|
|
57245
|
-
}
|
|
57282
|
+
};
|
|
57246
57283
|
}
|
|
57247
57284
|
var _0n6, _1n6, _2n4;
|
|
57248
57285
|
var init_montgomery2 = __esm({
|
|
57249
|
-
"
|
|
57286
|
+
"../../node_modules/@noble/curves/esm/abstract/montgomery.js"() {
|
|
57250
57287
|
init_utils3();
|
|
57251
|
-
init_curve2();
|
|
57252
57288
|
init_modular2();
|
|
57253
57289
|
_0n6 = BigInt(0);
|
|
57254
57290
|
_1n6 = BigInt(1);
|
|
@@ -57256,260 +57292,24 @@ var init_montgomery2 = __esm({
|
|
|
57256
57292
|
}
|
|
57257
57293
|
});
|
|
57258
57294
|
|
|
57259
|
-
//
|
|
57260
|
-
function createORPF(opts) {
|
|
57261
|
-
validateObject2(opts, {
|
|
57262
|
-
name: "string",
|
|
57263
|
-
hash: "function",
|
|
57264
|
-
hashToScalar: "function",
|
|
57265
|
-
hashToGroup: "function"
|
|
57266
|
-
});
|
|
57267
|
-
const { name, Point, hash: hash2 } = opts;
|
|
57268
|
-
const { Fn: Fn3 } = Point;
|
|
57269
|
-
const hashToGroup = (msg, ctx) => opts.hashToGroup(msg, {
|
|
57270
|
-
DST: concatBytes2(asciiToBytes("HashToGroup-"), ctx)
|
|
57271
|
-
});
|
|
57272
|
-
const hashToScalarPrefixed = (msg, ctx) => opts.hashToScalar(msg, { DST: concatBytes2(_DST_scalar, ctx) });
|
|
57273
|
-
const randomScalar = (rng = randomBytes2) => {
|
|
57274
|
-
const t2 = mapHashToField(rng(getMinHashLength(Fn3.ORDER)), Fn3.ORDER, Fn3.isLE);
|
|
57275
|
-
return Fn3.isLE ? bytesToNumberLE2(t2) : bytesToNumberBE(t2);
|
|
57276
|
-
};
|
|
57277
|
-
const msm = (points, scalars) => pippenger(Point, points, scalars);
|
|
57278
|
-
const getCtx = (mode) => concatBytes2(asciiToBytes("OPRFV1-"), new Uint8Array([mode]), asciiToBytes("-" + name));
|
|
57279
|
-
const ctxOPRF = getCtx(0);
|
|
57280
|
-
const ctxVOPRF = getCtx(1);
|
|
57281
|
-
const ctxPOPRF = getCtx(2);
|
|
57282
|
-
function encode4(...args) {
|
|
57283
|
-
const res = [];
|
|
57284
|
-
for (const a2 of args) {
|
|
57285
|
-
if (typeof a2 === "number")
|
|
57286
|
-
res.push(numberToBytesBE2(a2, 2));
|
|
57287
|
-
else if (typeof a2 === "string")
|
|
57288
|
-
res.push(asciiToBytes(a2));
|
|
57289
|
-
else {
|
|
57290
|
-
abytes3(a2);
|
|
57291
|
-
res.push(numberToBytesBE2(a2.length, 2), a2);
|
|
57292
|
-
}
|
|
57293
|
-
}
|
|
57294
|
-
return concatBytes2(...res);
|
|
57295
|
-
}
|
|
57296
|
-
const hashInput = (...bytes) => hash2(encode4(...bytes, "Finalize"));
|
|
57297
|
-
function getTranscripts(B2, C2, D2, ctx) {
|
|
57298
|
-
const Bm = B2.toBytes();
|
|
57299
|
-
const seed = hash2(encode4(Bm, concatBytes2(asciiToBytes("Seed-"), ctx)));
|
|
57300
|
-
const res = [];
|
|
57301
|
-
for (let i2 = 0; i2 < C2.length; i2++) {
|
|
57302
|
-
const Ci = C2[i2].toBytes();
|
|
57303
|
-
const Di = D2[i2].toBytes();
|
|
57304
|
-
const di = hashToScalarPrefixed(encode4(seed, i2, Ci, Di, "Composite"), ctx);
|
|
57305
|
-
res.push(di);
|
|
57306
|
-
}
|
|
57307
|
-
return res;
|
|
57308
|
-
}
|
|
57309
|
-
function computeComposites(B2, C2, D2, ctx) {
|
|
57310
|
-
const T2 = getTranscripts(B2, C2, D2, ctx);
|
|
57311
|
-
const M2 = msm(C2, T2);
|
|
57312
|
-
const Z2 = msm(D2, T2);
|
|
57313
|
-
return { M: M2, Z: Z2 };
|
|
57314
|
-
}
|
|
57315
|
-
function computeCompositesFast(k2, B2, C2, D2, ctx) {
|
|
57316
|
-
const T2 = getTranscripts(B2, C2, D2, ctx);
|
|
57317
|
-
const M2 = msm(C2, T2);
|
|
57318
|
-
const Z2 = M2.multiply(k2);
|
|
57319
|
-
return { M: M2, Z: Z2 };
|
|
57320
|
-
}
|
|
57321
|
-
function challengeTranscript(B2, M2, Z2, t2, t3, ctx) {
|
|
57322
|
-
const [Bm, a0, a1, a2, a3] = [B2, M2, Z2, t2, t3].map((i2) => i2.toBytes());
|
|
57323
|
-
return hashToScalarPrefixed(encode4(Bm, a0, a1, a2, a3, "Challenge"), ctx);
|
|
57324
|
-
}
|
|
57325
|
-
function generateProof(ctx, k2, B2, C2, D2, rng) {
|
|
57326
|
-
const { M: M2, Z: Z2 } = computeCompositesFast(k2, B2, C2, D2, ctx);
|
|
57327
|
-
const r2 = randomScalar(rng);
|
|
57328
|
-
const t2 = Point.BASE.multiply(r2);
|
|
57329
|
-
const t3 = M2.multiply(r2);
|
|
57330
|
-
const c2 = challengeTranscript(B2, M2, Z2, t2, t3, ctx);
|
|
57331
|
-
const s2 = Fn3.sub(r2, Fn3.mul(c2, k2));
|
|
57332
|
-
return concatBytes2(...[c2, s2].map((i2) => Fn3.toBytes(i2)));
|
|
57333
|
-
}
|
|
57334
|
-
function verifyProof(ctx, B2, C2, D2, proof) {
|
|
57335
|
-
abytes3(proof, 2 * Fn3.BYTES);
|
|
57336
|
-
const { M: M2, Z: Z2 } = computeComposites(B2, C2, D2, ctx);
|
|
57337
|
-
const [c2, s2] = [proof.subarray(0, Fn3.BYTES), proof.subarray(Fn3.BYTES)].map((f2) => Fn3.fromBytes(f2));
|
|
57338
|
-
const t2 = Point.BASE.multiply(s2).add(B2.multiply(c2));
|
|
57339
|
-
const t3 = M2.multiply(s2).add(Z2.multiply(c2));
|
|
57340
|
-
const expectedC = challengeTranscript(B2, M2, Z2, t2, t3, ctx);
|
|
57341
|
-
if (!Fn3.eql(c2, expectedC))
|
|
57342
|
-
throw new Error("proof verification failed");
|
|
57343
|
-
}
|
|
57344
|
-
function generateKeyPair() {
|
|
57345
|
-
const skS = randomScalar();
|
|
57346
|
-
const pkS = Point.BASE.multiply(skS);
|
|
57347
|
-
return { secretKey: Fn3.toBytes(skS), publicKey: pkS.toBytes() };
|
|
57348
|
-
}
|
|
57349
|
-
function deriveKeyPair(ctx, seed, info) {
|
|
57350
|
-
const dst = concatBytes2(asciiToBytes("DeriveKeyPair"), ctx);
|
|
57351
|
-
const msg = concatBytes2(seed, encode4(info), Uint8Array.of(0));
|
|
57352
|
-
for (let counter = 0; counter <= 255; counter++) {
|
|
57353
|
-
msg[msg.length - 1] = counter;
|
|
57354
|
-
const skS = opts.hashToScalar(msg, { DST: dst });
|
|
57355
|
-
if (Fn3.is0(skS))
|
|
57356
|
-
continue;
|
|
57357
|
-
return { secretKey: Fn3.toBytes(skS), publicKey: Point.BASE.multiply(skS).toBytes() };
|
|
57358
|
-
}
|
|
57359
|
-
throw new Error("Cannot derive key");
|
|
57360
|
-
}
|
|
57361
|
-
function blind(ctx, input, rng = randomBytes2) {
|
|
57362
|
-
const blind2 = randomScalar(rng);
|
|
57363
|
-
const inputPoint = hashToGroup(input, ctx);
|
|
57364
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57365
|
-
throw new Error("Input point at infinity");
|
|
57366
|
-
const blinded = inputPoint.multiply(blind2);
|
|
57367
|
-
return { blind: Fn3.toBytes(blind2), blinded: blinded.toBytes() };
|
|
57368
|
-
}
|
|
57369
|
-
function evaluate(ctx, secretKey, input) {
|
|
57370
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57371
|
-
const inputPoint = hashToGroup(input, ctx);
|
|
57372
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57373
|
-
throw new Error("Input point at infinity");
|
|
57374
|
-
const unblinded = inputPoint.multiply(skS).toBytes();
|
|
57375
|
-
return hashInput(input, unblinded);
|
|
57376
|
-
}
|
|
57377
|
-
const oprf = {
|
|
57378
|
-
generateKeyPair,
|
|
57379
|
-
deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxOPRF, seed, keyInfo),
|
|
57380
|
-
blind: (input, rng = randomBytes2) => blind(ctxOPRF, input, rng),
|
|
57381
|
-
blindEvaluate(secretKey, blindedPoint) {
|
|
57382
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57383
|
-
const elm = Point.fromBytes(blindedPoint);
|
|
57384
|
-
return elm.multiply(skS).toBytes();
|
|
57385
|
-
},
|
|
57386
|
-
finalize(input, blindBytes, evaluatedBytes) {
|
|
57387
|
-
const blind2 = Fn3.fromBytes(blindBytes);
|
|
57388
|
-
const evalPoint = Point.fromBytes(evaluatedBytes);
|
|
57389
|
-
const unblinded = evalPoint.multiply(Fn3.inv(blind2)).toBytes();
|
|
57390
|
-
return hashInput(input, unblinded);
|
|
57391
|
-
},
|
|
57392
|
-
evaluate: (secretKey, input) => evaluate(ctxOPRF, secretKey, input)
|
|
57393
|
-
};
|
|
57394
|
-
const voprf = {
|
|
57395
|
-
generateKeyPair,
|
|
57396
|
-
deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxVOPRF, seed, keyInfo),
|
|
57397
|
-
blind: (input, rng = randomBytes2) => blind(ctxVOPRF, input, rng),
|
|
57398
|
-
blindEvaluateBatch(secretKey, publicKey, blinded, rng = randomBytes2) {
|
|
57399
|
-
if (!Array.isArray(blinded))
|
|
57400
|
-
throw new Error("expected array");
|
|
57401
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57402
|
-
const pkS = Point.fromBytes(publicKey);
|
|
57403
|
-
const blindedPoints = blinded.map(Point.fromBytes);
|
|
57404
|
-
const evaluated = blindedPoints.map((i2) => i2.multiply(skS));
|
|
57405
|
-
const proof = generateProof(ctxVOPRF, skS, pkS, blindedPoints, evaluated, rng);
|
|
57406
|
-
return { evaluated: evaluated.map((i2) => i2.toBytes()), proof };
|
|
57407
|
-
},
|
|
57408
|
-
blindEvaluate(secretKey, publicKey, blinded, rng = randomBytes2) {
|
|
57409
|
-
const res = this.blindEvaluateBatch(secretKey, publicKey, [blinded], rng);
|
|
57410
|
-
return { evaluated: res.evaluated[0], proof: res.proof };
|
|
57411
|
-
},
|
|
57412
|
-
finalizeBatch(items, publicKey, proof) {
|
|
57413
|
-
if (!Array.isArray(items))
|
|
57414
|
-
throw new Error("expected array");
|
|
57415
|
-
const pkS = Point.fromBytes(publicKey);
|
|
57416
|
-
const blindedPoints = items.map((i2) => i2.blinded).map(Point.fromBytes);
|
|
57417
|
-
const evalPoints = items.map((i2) => i2.evaluated).map(Point.fromBytes);
|
|
57418
|
-
verifyProof(ctxVOPRF, pkS, blindedPoints, evalPoints, proof);
|
|
57419
|
-
return items.map((i2) => oprf.finalize(i2.input, i2.blind, i2.evaluated));
|
|
57420
|
-
},
|
|
57421
|
-
finalize(input, blind2, evaluated, blinded, publicKey, proof) {
|
|
57422
|
-
return this.finalizeBatch([{ input, blind: blind2, evaluated, blinded }], publicKey, proof)[0];
|
|
57423
|
-
},
|
|
57424
|
-
evaluate: (secretKey, input) => evaluate(ctxVOPRF, secretKey, input)
|
|
57425
|
-
};
|
|
57426
|
-
const poprf = (info) => {
|
|
57427
|
-
const m2 = hashToScalarPrefixed(encode4("Info", info), ctxPOPRF);
|
|
57428
|
-
const T2 = Point.BASE.multiply(m2);
|
|
57429
|
-
return {
|
|
57430
|
-
generateKeyPair,
|
|
57431
|
-
deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxPOPRF, seed, keyInfo),
|
|
57432
|
-
blind(input, publicKey, rng = randomBytes2) {
|
|
57433
|
-
const pkS = Point.fromBytes(publicKey);
|
|
57434
|
-
const tweakedKey = T2.add(pkS);
|
|
57435
|
-
if (tweakedKey.equals(Point.ZERO))
|
|
57436
|
-
throw new Error("tweakedKey point at infinity");
|
|
57437
|
-
const blind2 = randomScalar(rng);
|
|
57438
|
-
const inputPoint = hashToGroup(input, ctxPOPRF);
|
|
57439
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57440
|
-
throw new Error("Input point at infinity");
|
|
57441
|
-
const blindedPoint = inputPoint.multiply(blind2);
|
|
57442
|
-
return {
|
|
57443
|
-
blind: Fn3.toBytes(blind2),
|
|
57444
|
-
blinded: blindedPoint.toBytes(),
|
|
57445
|
-
tweakedKey: tweakedKey.toBytes()
|
|
57446
|
-
};
|
|
57447
|
-
},
|
|
57448
|
-
blindEvaluateBatch(secretKey, blinded, rng = randomBytes2) {
|
|
57449
|
-
if (!Array.isArray(blinded))
|
|
57450
|
-
throw new Error("expected array");
|
|
57451
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57452
|
-
const t2 = Fn3.add(skS, m2);
|
|
57453
|
-
const invT = Fn3.inv(t2);
|
|
57454
|
-
const blindedPoints = blinded.map(Point.fromBytes);
|
|
57455
|
-
const evalPoints = blindedPoints.map((i2) => i2.multiply(invT));
|
|
57456
|
-
const tweakedKey = Point.BASE.multiply(t2);
|
|
57457
|
-
const proof = generateProof(ctxPOPRF, t2, tweakedKey, evalPoints, blindedPoints, rng);
|
|
57458
|
-
return { evaluated: evalPoints.map((i2) => i2.toBytes()), proof };
|
|
57459
|
-
},
|
|
57460
|
-
blindEvaluate(secretKey, blinded, rng = randomBytes2) {
|
|
57461
|
-
const res = this.blindEvaluateBatch(secretKey, [blinded], rng);
|
|
57462
|
-
return { evaluated: res.evaluated[0], proof: res.proof };
|
|
57463
|
-
},
|
|
57464
|
-
finalizeBatch(items, proof, tweakedKey) {
|
|
57465
|
-
if (!Array.isArray(items))
|
|
57466
|
-
throw new Error("expected array");
|
|
57467
|
-
const evalPoints = items.map((i2) => i2.evaluated).map(Point.fromBytes);
|
|
57468
|
-
verifyProof(ctxPOPRF, Point.fromBytes(tweakedKey), evalPoints, items.map((i2) => i2.blinded).map(Point.fromBytes), proof);
|
|
57469
|
-
return items.map((i2, j2) => {
|
|
57470
|
-
const blind2 = Fn3.fromBytes(i2.blind);
|
|
57471
|
-
const point = evalPoints[j2].multiply(Fn3.inv(blind2)).toBytes();
|
|
57472
|
-
return hashInput(i2.input, info, point);
|
|
57473
|
-
});
|
|
57474
|
-
},
|
|
57475
|
-
finalize(input, blind2, evaluated, blinded, proof, tweakedKey) {
|
|
57476
|
-
return this.finalizeBatch([{ input, blind: blind2, evaluated, blinded }], proof, tweakedKey)[0];
|
|
57477
|
-
},
|
|
57478
|
-
evaluate(secretKey, input) {
|
|
57479
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57480
|
-
const inputPoint = hashToGroup(input, ctxPOPRF);
|
|
57481
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57482
|
-
throw new Error("Input point at infinity");
|
|
57483
|
-
const t2 = Fn3.add(skS, m2);
|
|
57484
|
-
const invT = Fn3.inv(t2);
|
|
57485
|
-
const unblinded = inputPoint.multiply(invT).toBytes();
|
|
57486
|
-
return hashInput(input, info, unblinded);
|
|
57487
|
-
}
|
|
57488
|
-
};
|
|
57489
|
-
};
|
|
57490
|
-
return Object.freeze({ name, oprf, voprf, poprf, __tests: { Fn: Fn3 } });
|
|
57491
|
-
}
|
|
57492
|
-
var init_oprf = __esm({
|
|
57493
|
-
"../crypto/node_modules/@noble/curves/abstract/oprf.js"() {
|
|
57494
|
-
init_utils3();
|
|
57495
|
-
init_curve2();
|
|
57496
|
-
init_hash_to_curve();
|
|
57497
|
-
init_modular2();
|
|
57498
|
-
}
|
|
57499
|
-
});
|
|
57500
|
-
|
|
57501
|
-
// ../crypto/node_modules/@noble/curves/ed25519.js
|
|
57295
|
+
// ../../node_modules/@noble/curves/esm/ed25519.js
|
|
57502
57296
|
var ed25519_exports = {};
|
|
57503
57297
|
__export(ed25519_exports, {
|
|
57504
57298
|
ED25519_TORSION_SUBGROUP: () => ED25519_TORSION_SUBGROUP,
|
|
57505
|
-
|
|
57299
|
+
RistrettoPoint: () => RistrettoPoint,
|
|
57506
57300
|
ed25519: () => ed25519,
|
|
57507
57301
|
ed25519_hasher: () => ed25519_hasher,
|
|
57508
57302
|
ed25519ctx: () => ed25519ctx,
|
|
57509
57303
|
ed25519ph: () => ed25519ph,
|
|
57304
|
+
edwardsToMontgomery: () => edwardsToMontgomery,
|
|
57305
|
+
edwardsToMontgomeryPriv: () => edwardsToMontgomeryPriv,
|
|
57306
|
+
edwardsToMontgomeryPub: () => edwardsToMontgomeryPub,
|
|
57307
|
+
encodeToCurve: () => encodeToCurve,
|
|
57308
|
+
hashToCurve: () => hashToCurve,
|
|
57309
|
+
hashToRistretto255: () => hashToRistretto255,
|
|
57310
|
+
hash_to_ristretto255: () => hash_to_ristretto255,
|
|
57510
57311
|
ristretto255: () => ristretto255,
|
|
57511
57312
|
ristretto255_hasher: () => ristretto255_hasher,
|
|
57512
|
-
ristretto255_oprf: () => ristretto255_oprf,
|
|
57513
57313
|
x25519: () => x25519
|
|
57514
57314
|
});
|
|
57515
57315
|
function ed25519_pow_2_252_3(x2) {
|
|
@@ -57558,12 +57358,9 @@ function uvRatio(u2, v2) {
|
|
|
57558
57358
|
function ed25519_domain(data, ctx, phflag) {
|
|
57559
57359
|
if (ctx.length > 255)
|
|
57560
57360
|
throw new Error("Context is too big");
|
|
57561
|
-
return concatBytes2(
|
|
57562
|
-
}
|
|
57563
|
-
function ed(opts) {
|
|
57564
|
-
return eddsa(ed25519_Point, sha5122, Object.assign({ adjustScalarBytes }, opts));
|
|
57361
|
+
return concatBytes2(utf8ToBytes("SigEd25519 no Ed25519 collisions"), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
57565
57362
|
}
|
|
57566
|
-
function
|
|
57363
|
+
function map_to_curve_elligator2_curve25519(u2) {
|
|
57567
57364
|
const ELL2_C4 = (ed25519_CURVE_p - _5n2) / _8n3;
|
|
57568
57365
|
const ELL2_J2 = BigInt(486662);
|
|
57569
57366
|
let tv1 = Fp.sqr(u2);
|
|
@@ -57607,7 +57404,7 @@ function _map_to_curve_elligator2_curve25519(u2) {
|
|
|
57607
57404
|
return { xMn: xn, xMd: xd, yMn: y3, yMd: _1n7 };
|
|
57608
57405
|
}
|
|
57609
57406
|
function map_to_curve_elligator2_edwards25519(u2) {
|
|
57610
|
-
const { xMn, xMd, yMn, yMd } =
|
|
57407
|
+
const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u2);
|
|
57611
57408
|
let xn = Fp.mul(xMn, yMd);
|
|
57612
57409
|
xn = Fp.mul(xn, ELL2_C1_EDWARDS);
|
|
57613
57410
|
let xd = Fp.mul(xMd, yMn);
|
|
@@ -57644,23 +57441,37 @@ function calcElligatorRistrettoMap(r0) {
|
|
|
57644
57441
|
const W1 = mod4(Nt * SQRT_AD_MINUS_ONE);
|
|
57645
57442
|
const W2 = mod4(_1n7 - s22);
|
|
57646
57443
|
const W3 = mod4(_1n7 + s22);
|
|
57647
|
-
return new
|
|
57444
|
+
return new ed25519.Point(mod4(W0 * W3), mod4(W2 * W1), mod4(W1 * W3), mod4(W0 * W2));
|
|
57445
|
+
}
|
|
57446
|
+
function ristretto255_map(bytes) {
|
|
57447
|
+
abytes3(bytes, 64);
|
|
57448
|
+
const r1 = bytes255ToNumberLE(bytes.subarray(0, 32));
|
|
57449
|
+
const R1 = calcElligatorRistrettoMap(r1);
|
|
57450
|
+
const r2 = bytes255ToNumberLE(bytes.subarray(32, 64));
|
|
57451
|
+
const R2 = calcElligatorRistrettoMap(r2);
|
|
57452
|
+
return new _RistrettoPoint(R1.add(R2));
|
|
57453
|
+
}
|
|
57454
|
+
function edwardsToMontgomeryPub(edwardsPub) {
|
|
57455
|
+
return ed25519.utils.toMontgomery(ensureBytes("pub", edwardsPub));
|
|
57648
57456
|
}
|
|
57649
|
-
|
|
57457
|
+
function edwardsToMontgomeryPriv(edwardsPriv) {
|
|
57458
|
+
return ed25519.utils.toMontgomerySecret(ensureBytes("pub", edwardsPriv));
|
|
57459
|
+
}
|
|
57460
|
+
var _0n7, _1n7, _2n5, _3n2, _5n2, _8n3, ed25519_CURVE_p, ed25519_CURVE, ED25519_SQRT_M1, Fp, Fn, ed25519Defaults, ed25519, ed25519ctx, ed25519ph, x25519, ELL2_C1, ELL2_C2, ELL2_C3, ELL2_C1_EDWARDS, ed25519_hasher, SQRT_M1, SQRT_AD_MINUS_ONE, INVSQRT_A_MINUS_D, ONE_MINUS_D_SQ, D_MINUS_ONE_SQ, invertSqrt, MAX_255B, bytes255ToNumberLE, _RistrettoPoint, ristretto255, ristretto255_hasher, ED25519_TORSION_SUBGROUP, edwardsToMontgomery, RistrettoPoint, hashToCurve, encodeToCurve, hashToRistretto255, hash_to_ristretto255;
|
|
57650
57461
|
var init_ed25519 = __esm({
|
|
57651
|
-
"
|
|
57462
|
+
"../../node_modules/@noble/curves/esm/ed25519.js"() {
|
|
57652
57463
|
init_sha22();
|
|
57653
57464
|
init_utils2();
|
|
57465
|
+
init_curve2();
|
|
57654
57466
|
init_edwards();
|
|
57655
57467
|
init_hash_to_curve();
|
|
57656
57468
|
init_modular2();
|
|
57657
57469
|
init_montgomery2();
|
|
57658
|
-
init_oprf();
|
|
57659
57470
|
init_utils3();
|
|
57660
57471
|
_0n7 = /* @__PURE__ */ BigInt(0);
|
|
57661
57472
|
_1n7 = BigInt(1);
|
|
57662
57473
|
_2n5 = BigInt(2);
|
|
57663
|
-
_3n2 =
|
|
57474
|
+
_3n2 = BigInt(3);
|
|
57664
57475
|
_5n2 = BigInt(5);
|
|
57665
57476
|
_8n3 = BigInt(8);
|
|
57666
57477
|
ed25519_CURVE_p = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");
|
|
@@ -57674,14 +57485,29 @@ var init_ed25519 = __esm({
|
|
|
57674
57485
|
Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
|
|
57675
57486
|
}))();
|
|
57676
57487
|
ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
57677
|
-
|
|
57678
|
-
|
|
57679
|
-
|
|
57680
|
-
|
|
57681
|
-
|
|
57682
|
-
|
|
57488
|
+
Fp = /* @__PURE__ */ (() => Field(ed25519_CURVE.p, { isLE: true }))();
|
|
57489
|
+
Fn = /* @__PURE__ */ (() => Field(ed25519_CURVE.n, { isLE: true }))();
|
|
57490
|
+
ed25519Defaults = /* @__PURE__ */ (() => ({
|
|
57491
|
+
...ed25519_CURVE,
|
|
57492
|
+
Fp,
|
|
57493
|
+
hash: sha5122,
|
|
57494
|
+
adjustScalarBytes,
|
|
57495
|
+
// dom2
|
|
57496
|
+
// Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.
|
|
57497
|
+
// Constant-time, u/√v
|
|
57498
|
+
uvRatio
|
|
57499
|
+
}))();
|
|
57500
|
+
ed25519 = /* @__PURE__ */ (() => twistedEdwards(ed25519Defaults))();
|
|
57501
|
+
ed25519ctx = /* @__PURE__ */ (() => twistedEdwards({
|
|
57502
|
+
...ed25519Defaults,
|
|
57503
|
+
domain: ed25519_domain
|
|
57504
|
+
}))();
|
|
57505
|
+
ed25519ph = /* @__PURE__ */ (() => twistedEdwards(Object.assign({}, ed25519Defaults, {
|
|
57506
|
+
domain: ed25519_domain,
|
|
57507
|
+
prehash: sha5122
|
|
57508
|
+
})))();
|
|
57683
57509
|
x25519 = /* @__PURE__ */ (() => {
|
|
57684
|
-
const P2 =
|
|
57510
|
+
const P2 = Fp.ORDER;
|
|
57685
57511
|
return montgomery2({
|
|
57686
57512
|
P: P2,
|
|
57687
57513
|
type: "x25519",
|
|
@@ -57696,7 +57522,7 @@ var init_ed25519 = __esm({
|
|
|
57696
57522
|
ELL2_C2 = /* @__PURE__ */ (() => Fp.pow(_2n5, ELL2_C1))();
|
|
57697
57523
|
ELL2_C3 = /* @__PURE__ */ (() => Fp.sqrt(Fp.neg(Fp.ONE)))();
|
|
57698
57524
|
ELL2_C1_EDWARDS = /* @__PURE__ */ (() => FpSqrtEven(Fp, Fp.neg(BigInt(486664))))();
|
|
57699
|
-
ed25519_hasher = /* @__PURE__ */ (() => createHasher3(
|
|
57525
|
+
ed25519_hasher = /* @__PURE__ */ (() => createHasher3(ed25519.Point, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), {
|
|
57700
57526
|
DST: "edwards25519_XMD:SHA-512_ELL2_RO_",
|
|
57701
57527
|
encodeDST: "edwards25519_XMD:SHA-512_ELL2_NU_",
|
|
57702
57528
|
p: ed25519_CURVE_p,
|
|
@@ -57712,23 +57538,13 @@ var init_ed25519 = __esm({
|
|
|
57712
57538
|
D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");
|
|
57713
57539
|
invertSqrt = (number3) => uvRatio(_1n7, number3);
|
|
57714
57540
|
MAX_255B = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
57715
|
-
bytes255ToNumberLE = (bytes) => Fp.create(bytesToNumberLE2(bytes) & MAX_255B);
|
|
57541
|
+
bytes255ToNumberLE = (bytes) => ed25519.Point.Fp.create(bytesToNumberLE2(bytes) & MAX_255B);
|
|
57716
57542
|
_RistrettoPoint = class __RistrettoPoint extends PrimeEdwardsPoint {
|
|
57717
|
-
// Do NOT change syntax: the following gymnastics is done,
|
|
57718
|
-
// because typescript strips comments, which makes bundlers disable tree-shaking.
|
|
57719
|
-
// prettier-ignore
|
|
57720
|
-
static BASE = /* @__PURE__ */ (() => new __RistrettoPoint(ed25519_Point.BASE))();
|
|
57721
|
-
// prettier-ignore
|
|
57722
|
-
static ZERO = /* @__PURE__ */ (() => new __RistrettoPoint(ed25519_Point.ZERO))();
|
|
57723
|
-
// prettier-ignore
|
|
57724
|
-
static Fp = /* @__PURE__ */ (() => Fp)();
|
|
57725
|
-
// prettier-ignore
|
|
57726
|
-
static Fn = /* @__PURE__ */ (() => Fn)();
|
|
57727
57543
|
constructor(ep) {
|
|
57728
57544
|
super(ep);
|
|
57729
57545
|
}
|
|
57730
57546
|
static fromAffine(ap) {
|
|
57731
|
-
return new __RistrettoPoint(
|
|
57547
|
+
return new __RistrettoPoint(ed25519.Point.fromAffine(ap));
|
|
57732
57548
|
}
|
|
57733
57549
|
assertSame(other) {
|
|
57734
57550
|
if (!(other instanceof __RistrettoPoint))
|
|
@@ -57737,6 +57553,10 @@ var init_ed25519 = __esm({
|
|
|
57737
57553
|
init(ep) {
|
|
57738
57554
|
return new __RistrettoPoint(ep);
|
|
57739
57555
|
}
|
|
57556
|
+
/** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
|
|
57557
|
+
static hashToCurve(hex3) {
|
|
57558
|
+
return ristretto255_map(ensureBytes("ristrettoHash", hex3, 64));
|
|
57559
|
+
}
|
|
57740
57560
|
static fromBytes(bytes) {
|
|
57741
57561
|
abytes3(bytes, 32);
|
|
57742
57562
|
const { a: a2, d: d2 } = ed25519_CURVE;
|
|
@@ -57761,7 +57581,7 @@ var init_ed25519 = __esm({
|
|
|
57761
57581
|
const t2 = mod4(x2 * y2);
|
|
57762
57582
|
if (!isValid2 || isNegativeLE(t2, P2) || y2 === _0n7)
|
|
57763
57583
|
throw new Error("invalid ristretto255 encoding 2");
|
|
57764
|
-
return new __RistrettoPoint(new
|
|
57584
|
+
return new __RistrettoPoint(new ed25519.Point(x2, y2, _1n7, t2));
|
|
57765
57585
|
}
|
|
57766
57586
|
/**
|
|
57767
57587
|
* Converts ristretto-encoded string to ristretto point.
|
|
@@ -57769,7 +57589,10 @@ var init_ed25519 = __esm({
|
|
|
57769
57589
|
* @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
|
|
57770
57590
|
*/
|
|
57771
57591
|
static fromHex(hex3) {
|
|
57772
|
-
return __RistrettoPoint.fromBytes(
|
|
57592
|
+
return __RistrettoPoint.fromBytes(ensureBytes("ristrettoHex", hex3, 32));
|
|
57593
|
+
}
|
|
57594
|
+
static msm(points, scalars) {
|
|
57595
|
+
return pippenger(__RistrettoPoint, ed25519.Point.Fn, points, scalars);
|
|
57773
57596
|
}
|
|
57774
57597
|
/**
|
|
57775
57598
|
* Encodes ristretto point to Uint8Array.
|
|
@@ -57820,53 +57643,22 @@ var init_ed25519 = __esm({
|
|
|
57820
57643
|
return this.equals(__RistrettoPoint.ZERO);
|
|
57821
57644
|
}
|
|
57822
57645
|
};
|
|
57646
|
+
_RistrettoPoint.BASE = /* @__PURE__ */ (() => new _RistrettoPoint(ed25519.Point.BASE))();
|
|
57647
|
+
_RistrettoPoint.ZERO = /* @__PURE__ */ (() => new _RistrettoPoint(ed25519.Point.ZERO))();
|
|
57648
|
+
_RistrettoPoint.Fp = /* @__PURE__ */ (() => Fp)();
|
|
57649
|
+
_RistrettoPoint.Fn = /* @__PURE__ */ (() => Fn)();
|
|
57823
57650
|
ristretto255 = { Point: _RistrettoPoint };
|
|
57824
57651
|
ristretto255_hasher = {
|
|
57825
|
-
Point: _RistrettoPoint,
|
|
57826
|
-
/**
|
|
57827
|
-
* Spec: https://www.rfc-editor.org/rfc/rfc9380.html#name-hashing-to-ristretto255. Caveats:
|
|
57828
|
-
* * There are no test vectors
|
|
57829
|
-
* * encodeToCurve / mapToCurve is undefined
|
|
57830
|
-
* * mapToCurve would be `calcElligatorRistrettoMap(scalars[0])`, not ristretto255_map!
|
|
57831
|
-
* * hashToScalar is undefined too, so we just use OPRF implementation
|
|
57832
|
-
* * We cannot re-use 'createHasher', because ristretto255_map is different algorithm/RFC
|
|
57833
|
-
(os2ip -> bytes255ToNumberLE)
|
|
57834
|
-
* * mapToCurve == calcElligatorRistrettoMap, hashToCurve == ristretto255_map
|
|
57835
|
-
* * hashToScalar is undefined in RFC9380 for ristretto, we are using version from OPRF here, using bytes255ToNumblerLE will create different result if we use bytes255ToNumberLE as os2ip
|
|
57836
|
-
* * current version is closest to spec.
|
|
57837
|
-
*/
|
|
57838
57652
|
hashToCurve(msg, options) {
|
|
57839
57653
|
const DST = options?.DST || "ristretto255_XMD:SHA-512_R255MAP_RO_";
|
|
57840
57654
|
const xmd = expand_message_xmd(msg, DST, 64, sha5122);
|
|
57841
|
-
return
|
|
57655
|
+
return ristretto255_map(xmd);
|
|
57842
57656
|
},
|
|
57843
57657
|
hashToScalar(msg, options = { DST: _DST_scalar }) {
|
|
57844
57658
|
const xmd = expand_message_xmd(msg, options.DST, 64, sha5122);
|
|
57845
57659
|
return Fn.create(bytesToNumberLE2(xmd));
|
|
57846
|
-
}
|
|
57847
|
-
|
|
57848
|
-
* HashToCurve-like construction based on RFC 9496 (Element Derivation).
|
|
57849
|
-
* Converts 64 uniform random bytes into a curve point.
|
|
57850
|
-
*
|
|
57851
|
-
* WARNING: This represents an older hash-to-curve construction, preceding the finalization of RFC 9380.
|
|
57852
|
-
* It was later reused as a component in the newer `hash_to_ristretto255` function defined in RFC 9380.
|
|
57853
|
-
*/
|
|
57854
|
-
deriveToCurve(bytes) {
|
|
57855
|
-
abytes3(bytes, 64);
|
|
57856
|
-
const r1 = bytes255ToNumberLE(bytes.subarray(0, 32));
|
|
57857
|
-
const R1 = calcElligatorRistrettoMap(r1);
|
|
57858
|
-
const r2 = bytes255ToNumberLE(bytes.subarray(32, 64));
|
|
57859
|
-
const R2 = calcElligatorRistrettoMap(r2);
|
|
57860
|
-
return new _RistrettoPoint(R1.add(R2));
|
|
57861
|
-
}
|
|
57862
|
-
};
|
|
57863
|
-
ristretto255_oprf = /* @__PURE__ */ (() => createORPF({
|
|
57864
|
-
name: "ristretto255-SHA512",
|
|
57865
|
-
Point: _RistrettoPoint,
|
|
57866
|
-
hash: sha5122,
|
|
57867
|
-
hashToGroup: ristretto255_hasher.hashToCurve,
|
|
57868
|
-
hashToScalar: ristretto255_hasher.hashToScalar
|
|
57869
|
-
}))();
|
|
57660
|
+
}
|
|
57661
|
+
};
|
|
57870
57662
|
ED25519_TORSION_SUBGROUP = [
|
|
57871
57663
|
"0100000000000000000000000000000000000000000000000000000000000000",
|
|
57872
57664
|
"c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a",
|
|
@@ -57877,10 +57669,16 @@ var init_ed25519 = __esm({
|
|
|
57877
57669
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
57878
57670
|
"c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"
|
|
57879
57671
|
];
|
|
57672
|
+
edwardsToMontgomery = edwardsToMontgomeryPub;
|
|
57673
|
+
RistrettoPoint = _RistrettoPoint;
|
|
57674
|
+
hashToCurve = /* @__PURE__ */ (() => ed25519_hasher.hashToCurve)();
|
|
57675
|
+
encodeToCurve = /* @__PURE__ */ (() => ed25519_hasher.encodeToCurve)();
|
|
57676
|
+
hashToRistretto255 = /* @__PURE__ */ (() => ristretto255_hasher.hashToCurve)();
|
|
57677
|
+
hash_to_ristretto255 = /* @__PURE__ */ (() => ristretto255_hasher.hashToCurve)();
|
|
57880
57678
|
}
|
|
57881
57679
|
});
|
|
57882
57680
|
|
|
57883
|
-
//
|
|
57681
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js
|
|
57884
57682
|
function keccakP(s2, rounds = 24) {
|
|
57885
57683
|
const B2 = new Uint32Array(5 * 2);
|
|
57886
57684
|
for (let round = 24 - rounds; round < 24; round++) {
|
|
@@ -57923,7 +57721,7 @@ function keccakP(s2, rounds = 24) {
|
|
|
57923
57721
|
}
|
|
57924
57722
|
var _0n8, _1n8, _2n6, _7n3, _256n2, _0x71n2, SHA3_PI2, SHA3_ROTL2, _SHA3_IOTA2, IOTAS2, SHA3_IOTA_H2, SHA3_IOTA_L2, rotlH, rotlL, Keccak, genShake, shake2562;
|
|
57925
57723
|
var init_sha32 = __esm({
|
|
57926
|
-
"
|
|
57724
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js"() {
|
|
57927
57725
|
init_u642();
|
|
57928
57726
|
init_utils2();
|
|
57929
57727
|
_0n8 = BigInt(0);
|
|
@@ -57943,7 +57741,7 @@ var init_sha32 = __esm({
|
|
|
57943
57741
|
for (let j2 = 0; j2 < 7; j2++) {
|
|
57944
57742
|
R2 = (R2 << _1n8 ^ (R2 >> _7n3) * _0x71n2) % _256n2;
|
|
57945
57743
|
if (R2 & _2n6)
|
|
57946
|
-
t2 ^= _1n8 << (_1n8 << BigInt(j2)) - _1n8;
|
|
57744
|
+
t2 ^= _1n8 << (_1n8 << /* @__PURE__ */ BigInt(j2)) - _1n8;
|
|
57947
57745
|
}
|
|
57948
57746
|
_SHA3_IOTA2.push(t2);
|
|
57949
57747
|
}
|
|
@@ -57952,26 +57750,21 @@ var init_sha32 = __esm({
|
|
|
57952
57750
|
SHA3_IOTA_L2 = IOTAS2[1];
|
|
57953
57751
|
rotlH = (h2, l2, s2) => s2 > 32 ? rotlBH2(h2, l2, s2) : rotlSH2(h2, l2, s2);
|
|
57954
57752
|
rotlL = (h2, l2, s2) => s2 > 32 ? rotlBL2(h2, l2, s2) : rotlSL2(h2, l2, s2);
|
|
57955
|
-
Keccak = class _Keccak {
|
|
57956
|
-
state;
|
|
57957
|
-
pos = 0;
|
|
57958
|
-
posOut = 0;
|
|
57959
|
-
finished = false;
|
|
57960
|
-
state32;
|
|
57961
|
-
destroyed = false;
|
|
57962
|
-
blockLen;
|
|
57963
|
-
suffix;
|
|
57964
|
-
outputLen;
|
|
57965
|
-
enableXOF = false;
|
|
57966
|
-
rounds;
|
|
57753
|
+
Keccak = class _Keccak extends Hash {
|
|
57967
57754
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
57968
57755
|
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
57756
|
+
super();
|
|
57757
|
+
this.pos = 0;
|
|
57758
|
+
this.posOut = 0;
|
|
57759
|
+
this.finished = false;
|
|
57760
|
+
this.destroyed = false;
|
|
57761
|
+
this.enableXOF = false;
|
|
57969
57762
|
this.blockLen = blockLen;
|
|
57970
57763
|
this.suffix = suffix;
|
|
57971
57764
|
this.outputLen = outputLen;
|
|
57972
57765
|
this.enableXOF = enableXOF;
|
|
57973
57766
|
this.rounds = rounds;
|
|
57974
|
-
anumber3(outputLen
|
|
57767
|
+
anumber3(outputLen);
|
|
57975
57768
|
if (!(0 < blockLen && blockLen < 200))
|
|
57976
57769
|
throw new Error("only keccak-f1600 function is supported");
|
|
57977
57770
|
this.state = new Uint8Array(200);
|
|
@@ -57989,6 +57782,7 @@ var init_sha32 = __esm({
|
|
|
57989
57782
|
}
|
|
57990
57783
|
update(data) {
|
|
57991
57784
|
aexists3(this);
|
|
57785
|
+
data = toBytes(data);
|
|
57992
57786
|
abytes3(data);
|
|
57993
57787
|
const { blockLen, state } = this;
|
|
57994
57788
|
const len = data.length;
|
|
@@ -58054,7 +57848,7 @@ var init_sha32 = __esm({
|
|
|
58054
57848
|
}
|
|
58055
57849
|
_cloneInto(to) {
|
|
58056
57850
|
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
58057
|
-
to
|
|
57851
|
+
to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
58058
57852
|
to.state32.set(this.state32);
|
|
58059
57853
|
to.pos = this.pos;
|
|
58060
57854
|
to.posOut = this.posOut;
|
|
@@ -58067,26 +57861,32 @@ var init_sha32 = __esm({
|
|
|
58067
57861
|
return to;
|
|
58068
57862
|
}
|
|
58069
57863
|
};
|
|
58070
|
-
genShake = (suffix, blockLen, outputLen
|
|
58071
|
-
shake2562 = /* @__PURE__ */ genShake(31, 136,
|
|
57864
|
+
genShake = (suffix, blockLen, outputLen) => createXOFer((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
|
|
57865
|
+
shake2562 = /* @__PURE__ */ (() => genShake(31, 136, 256 / 8))();
|
|
58072
57866
|
}
|
|
58073
57867
|
});
|
|
58074
57868
|
|
|
58075
|
-
//
|
|
57869
|
+
// ../../node_modules/@noble/curves/esm/ed448.js
|
|
58076
57870
|
var ed448_exports = {};
|
|
58077
57871
|
__export(ed448_exports, {
|
|
57872
|
+
DecafPoint: () => DecafPoint,
|
|
58078
57873
|
E448: () => E448,
|
|
58079
57874
|
ED448_TORSION_SUBGROUP: () => ED448_TORSION_SUBGROUP,
|
|
58080
57875
|
decaf448: () => decaf448,
|
|
58081
57876
|
decaf448_hasher: () => decaf448_hasher,
|
|
58082
|
-
decaf448_oprf: () => decaf448_oprf,
|
|
58083
57877
|
ed448: () => ed448,
|
|
58084
57878
|
ed448_hasher: () => ed448_hasher,
|
|
58085
57879
|
ed448ph: () => ed448ph,
|
|
57880
|
+
edwardsToMontgomery: () => edwardsToMontgomery2,
|
|
57881
|
+
edwardsToMontgomeryPub: () => edwardsToMontgomeryPub2,
|
|
57882
|
+
encodeToCurve: () => encodeToCurve2,
|
|
57883
|
+
hashToCurve: () => hashToCurve2,
|
|
57884
|
+
hashToDecaf448: () => hashToDecaf448,
|
|
57885
|
+
hash_to_decaf448: () => hash_to_decaf448,
|
|
58086
57886
|
x448: () => x448
|
|
58087
57887
|
});
|
|
58088
57888
|
function ed448_pow_Pminus3div4(x2) {
|
|
58089
|
-
const P2 =
|
|
57889
|
+
const P2 = ed448_CURVE.p;
|
|
58090
57890
|
const b2 = x2 * x2 * x2 % P2;
|
|
58091
57891
|
const b3 = b2 * b2 * x2 % P2;
|
|
58092
57892
|
const b6 = pow22(b3, _3n3, P2) * b3 % P2;
|
|
@@ -58108,7 +57908,7 @@ function adjustScalarBytes2(bytes) {
|
|
|
58108
57908
|
return bytes;
|
|
58109
57909
|
}
|
|
58110
57910
|
function uvRatio2(u2, v2) {
|
|
58111
|
-
const P2 =
|
|
57911
|
+
const P2 = ed448_CURVE.p;
|
|
58112
57912
|
const u2v = mod3(u2 * u2 * v2, P2);
|
|
58113
57913
|
const u3v = mod3(u2v * u2, P2);
|
|
58114
57914
|
const u5v3 = mod3(u3v * u2v * v2, P2);
|
|
@@ -58122,9 +57922,6 @@ function dom4(data, ctx, phflag) {
|
|
|
58122
57922
|
throw new Error("context must be smaller than 255, got: " + ctx.length);
|
|
58123
57923
|
return concatBytes2(asciiToBytes("SigEd448"), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
58124
57924
|
}
|
|
58125
|
-
function ed4(opts) {
|
|
58126
|
-
return eddsa(ed448_Point, shake256_114, Object.assign({ adjustScalarBytes: adjustScalarBytes2, domain: dom4 }, opts));
|
|
58127
|
-
}
|
|
58128
57925
|
function map_to_curve_elligator2_curve448(u2) {
|
|
58129
57926
|
let tv1 = Fp2.sqr(u2);
|
|
58130
57927
|
let e1 = Fp2.eql(tv1, Fp2.ONE);
|
|
@@ -58196,8 +57993,9 @@ function map_to_curve_elligator2_edwards448(u2) {
|
|
|
58196
57993
|
return { x: Fp2.mul(xEn, inv[0]), y: Fp2.mul(yEn, inv[1]) };
|
|
58197
57994
|
}
|
|
58198
57995
|
function calcElligatorDecafMap(r0) {
|
|
58199
|
-
const { d: d2
|
|
58200
|
-
const
|
|
57996
|
+
const { d: d2 } = ed448_CURVE;
|
|
57997
|
+
const P2 = Fp2.ORDER;
|
|
57998
|
+
const mod4 = (n2) => Fp2.create(n2);
|
|
58201
57999
|
const r2 = mod4(-(r0 * r0));
|
|
58202
58000
|
const u0 = mod4(d2 * (r2 - _1n9));
|
|
58203
58001
|
const u1 = mod4((u0 + _1n9) * (u0 - r2));
|
|
@@ -58217,55 +58015,78 @@ function calcElligatorDecafMap(r0) {
|
|
|
58217
58015
|
const W1 = mod4(s22 + _1n9);
|
|
58218
58016
|
const W2 = mod4(s22 - _1n9);
|
|
58219
58017
|
const W3 = mod4(v_prime * s2 * (r2 - _1n9) * ONE_MINUS_TWO_D + sgn);
|
|
58220
|
-
return new
|
|
58018
|
+
return new ed448.Point(mod4(W0 * W3), mod4(W2 * W1), mod4(W1 * W3), mod4(W0 * W2));
|
|
58019
|
+
}
|
|
58020
|
+
function decaf448_map(bytes) {
|
|
58021
|
+
abytes3(bytes, 112);
|
|
58022
|
+
const skipValidation = true;
|
|
58023
|
+
const r1 = Fp448.create(Fp448.fromBytes(bytes.subarray(0, 56), skipValidation));
|
|
58024
|
+
const R1 = calcElligatorDecafMap(r1);
|
|
58025
|
+
const r2 = Fp448.create(Fp448.fromBytes(bytes.subarray(56, 112), skipValidation));
|
|
58026
|
+
const R2 = calcElligatorDecafMap(r2);
|
|
58027
|
+
return new _DecafPoint(R1.add(R2));
|
|
58221
58028
|
}
|
|
58222
|
-
|
|
58029
|
+
function edwardsToMontgomeryPub2(edwardsPub) {
|
|
58030
|
+
return ed448.utils.toMontgomery(ensureBytes("pub", edwardsPub));
|
|
58031
|
+
}
|
|
58032
|
+
var ed448_CURVE, E448_CURVE, shake256_114, shake256_64, _1n9, _2n7, _3n3, _4n2, _11n, _22n, _44n, _88n, _223n, Fp2, Fn2, Fp448, Fn448, ED448_DEF, ed448, ed448ph, E448, x448, ELL2_C12, ELL2_J, ed448_hasher, ONE_MINUS_D, ONE_MINUS_TWO_D, SQRT_MINUS_D, INVSQRT_MINUS_D, invertSqrt2, _DecafPoint, decaf448, decaf448_hasher, ED448_TORSION_SUBGROUP, DecafPoint, hashToCurve2, encodeToCurve2, hashToDecaf448, hash_to_decaf448, edwardsToMontgomery2;
|
|
58223
58033
|
var init_ed448 = __esm({
|
|
58224
|
-
"
|
|
58034
|
+
"../../node_modules/@noble/curves/esm/ed448.js"() {
|
|
58225
58035
|
init_sha32();
|
|
58226
58036
|
init_utils2();
|
|
58037
|
+
init_curve2();
|
|
58227
58038
|
init_edwards();
|
|
58228
58039
|
init_hash_to_curve();
|
|
58229
58040
|
init_modular2();
|
|
58230
58041
|
init_montgomery2();
|
|
58231
|
-
init_oprf();
|
|
58232
58042
|
init_utils3();
|
|
58233
|
-
|
|
58234
|
-
|
|
58235
|
-
p: ed448_CURVE_p,
|
|
58043
|
+
ed448_CURVE = {
|
|
58044
|
+
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
|
58236
58045
|
n: BigInt("0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3"),
|
|
58237
58046
|
h: BigInt(4),
|
|
58238
58047
|
a: BigInt(1),
|
|
58239
58048
|
d: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffff6756"),
|
|
58240
58049
|
Gx: BigInt("0x4f1970c66bed0ded221d15a622bf36da9e146570470f1767ea6de324a3d3a46412ae1af72ab66511433b80e18b00938e2626a82bc70cc05e"),
|
|
58241
58050
|
Gy: BigInt("0x693f46716eb6bc248876203756c9c7624bea73736ca3984087789c1e05a0c2d73ad3ff1ce67c39c4fdbd132c4ed7c8ad9808795bf230fa14")
|
|
58242
|
-
}
|
|
58243
|
-
E448_CURVE =
|
|
58051
|
+
};
|
|
58052
|
+
E448_CURVE = Object.assign({}, ed448_CURVE, {
|
|
58244
58053
|
d: BigInt("0xd78b4bdc7f0daf19f24f38c29373a2ccad46157242a50f37809b1da3412a12e79ccc9c81264cfe9ad080997058fb61c4243cc32dbaa156b9"),
|
|
58245
58054
|
Gx: BigInt("0x79a70b2b70400553ae7c9df416c792c61128751ac92969240c25a07d728bdc93e21f7787ed6972249de732f38496cd11698713093e9c04fc"),
|
|
58246
58055
|
Gy: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000000000000000000000000000000000001")
|
|
58247
|
-
})
|
|
58056
|
+
});
|
|
58248
58057
|
shake256_114 = /* @__PURE__ */ createHasher2(() => shake2562.create({ dkLen: 114 }));
|
|
58249
58058
|
shake256_64 = /* @__PURE__ */ createHasher2(() => shake2562.create({ dkLen: 64 }));
|
|
58250
58059
|
_1n9 = BigInt(1);
|
|
58251
58060
|
_2n7 = BigInt(2);
|
|
58252
58061
|
_3n3 = BigInt(3);
|
|
58253
|
-
_4n2 =
|
|
58062
|
+
_4n2 = BigInt(4);
|
|
58254
58063
|
_11n = BigInt(11);
|
|
58255
58064
|
_22n = BigInt(22);
|
|
58256
58065
|
_44n = BigInt(44);
|
|
58257
58066
|
_88n = BigInt(88);
|
|
58258
58067
|
_223n = BigInt(223);
|
|
58259
|
-
Fp2 = /* @__PURE__ */ (() => Field(
|
|
58068
|
+
Fp2 = /* @__PURE__ */ (() => Field(ed448_CURVE.p, { BITS: 456, isLE: true }))();
|
|
58260
58069
|
Fn2 = /* @__PURE__ */ (() => Field(ed448_CURVE.n, { BITS: 456, isLE: true }))();
|
|
58261
|
-
Fp448 = /* @__PURE__ */ (() => Field(
|
|
58070
|
+
Fp448 = /* @__PURE__ */ (() => Field(ed448_CURVE.p, { BITS: 448, isLE: true }))();
|
|
58262
58071
|
Fn448 = /* @__PURE__ */ (() => Field(ed448_CURVE.n, { BITS: 448, isLE: true }))();
|
|
58263
|
-
|
|
58264
|
-
|
|
58265
|
-
|
|
58266
|
-
|
|
58072
|
+
ED448_DEF = /* @__PURE__ */ (() => ({
|
|
58073
|
+
...ed448_CURVE,
|
|
58074
|
+
Fp: Fp2,
|
|
58075
|
+
Fn: Fn2,
|
|
58076
|
+
nBitLength: Fn2.BITS,
|
|
58077
|
+
hash: shake256_114,
|
|
58078
|
+
adjustScalarBytes: adjustScalarBytes2,
|
|
58079
|
+
domain: dom4,
|
|
58080
|
+
uvRatio: uvRatio2
|
|
58081
|
+
}))();
|
|
58082
|
+
ed448 = twistedEdwards(ED448_DEF);
|
|
58083
|
+
ed448ph = /* @__PURE__ */ (() => twistedEdwards({
|
|
58084
|
+
...ED448_DEF,
|
|
58085
|
+
prehash: shake256_64
|
|
58086
|
+
}))();
|
|
58087
|
+
E448 = edwards(E448_CURVE);
|
|
58267
58088
|
x448 = /* @__PURE__ */ (() => {
|
|
58268
|
-
const P2 =
|
|
58089
|
+
const P2 = ed448_CURVE.p;
|
|
58269
58090
|
return montgomery2({
|
|
58270
58091
|
P: P2,
|
|
58271
58092
|
type: "x448",
|
|
@@ -58277,12 +58098,12 @@ var init_ed448 = __esm({
|
|
|
58277
58098
|
adjustScalarBytes: adjustScalarBytes2
|
|
58278
58099
|
});
|
|
58279
58100
|
})();
|
|
58280
|
-
ELL2_C12 = /* @__PURE__ */ (() => (
|
|
58101
|
+
ELL2_C12 = /* @__PURE__ */ (() => (Fp2.ORDER - BigInt(3)) / BigInt(4))();
|
|
58281
58102
|
ELL2_J = /* @__PURE__ */ BigInt(156326);
|
|
58282
|
-
ed448_hasher = /* @__PURE__ */ (() => createHasher3(
|
|
58103
|
+
ed448_hasher = /* @__PURE__ */ (() => createHasher3(ed448.Point, (scalars) => map_to_curve_elligator2_edwards448(scalars[0]), {
|
|
58283
58104
|
DST: "edwards448_XOF:SHAKE256_ELL2_RO_",
|
|
58284
58105
|
encodeDST: "edwards448_XOF:SHAKE256_ELL2_NU_",
|
|
58285
|
-
p:
|
|
58106
|
+
p: Fp2.ORDER,
|
|
58286
58107
|
m: 1,
|
|
58287
58108
|
k: 224,
|
|
58288
58109
|
expand: "xof",
|
|
@@ -58294,20 +58115,11 @@ var init_ed448 = __esm({
|
|
|
58294
58115
|
INVSQRT_MINUS_D = /* @__PURE__ */ BigInt("315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716");
|
|
58295
58116
|
invertSqrt2 = (number3) => uvRatio2(_1n9, number3);
|
|
58296
58117
|
_DecafPoint = class __DecafPoint extends PrimeEdwardsPoint {
|
|
58297
|
-
// The following gymnastics is done because typescript strips comments otherwise
|
|
58298
|
-
// prettier-ignore
|
|
58299
|
-
static BASE = /* @__PURE__ */ (() => new __DecafPoint(ed448_Point.BASE).multiplyUnsafe(_2n7))();
|
|
58300
|
-
// prettier-ignore
|
|
58301
|
-
static ZERO = /* @__PURE__ */ (() => new __DecafPoint(ed448_Point.ZERO))();
|
|
58302
|
-
// prettier-ignore
|
|
58303
|
-
static Fp = /* @__PURE__ */ (() => Fp448)();
|
|
58304
|
-
// prettier-ignore
|
|
58305
|
-
static Fn = /* @__PURE__ */ (() => Fn448)();
|
|
58306
58118
|
constructor(ep) {
|
|
58307
58119
|
super(ep);
|
|
58308
58120
|
}
|
|
58309
58121
|
static fromAffine(ap) {
|
|
58310
|
-
return new __DecafPoint(
|
|
58122
|
+
return new __DecafPoint(ed448.Point.fromAffine(ap));
|
|
58311
58123
|
}
|
|
58312
58124
|
assertSame(other) {
|
|
58313
58125
|
if (!(other instanceof __DecafPoint))
|
|
@@ -58316,9 +58128,14 @@ var init_ed448 = __esm({
|
|
|
58316
58128
|
init(ep) {
|
|
58317
58129
|
return new __DecafPoint(ep);
|
|
58318
58130
|
}
|
|
58131
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
58132
|
+
static hashToCurve(hex3) {
|
|
58133
|
+
return decaf448_map(ensureBytes("decafHash", hex3, 112));
|
|
58134
|
+
}
|
|
58319
58135
|
static fromBytes(bytes) {
|
|
58320
58136
|
abytes3(bytes, 56);
|
|
58321
|
-
const { d: d2
|
|
58137
|
+
const { d: d2 } = ed448_CURVE;
|
|
58138
|
+
const P2 = Fp2.ORDER;
|
|
58322
58139
|
const mod4 = (n2) => Fp448.create(n2);
|
|
58323
58140
|
const s2 = Fp448.fromBytes(bytes);
|
|
58324
58141
|
if (!equalBytes2(Fn448.toBytes(s2), bytes) || isNegativeLE(s2, P2))
|
|
@@ -58336,7 +58153,7 @@ var init_ed448 = __esm({
|
|
|
58336
58153
|
const t2 = mod4(x2 * y2);
|
|
58337
58154
|
if (!isValid2)
|
|
58338
58155
|
throw new Error("invalid decaf448 encoding 2");
|
|
58339
|
-
return new __DecafPoint(new
|
|
58156
|
+
return new __DecafPoint(new ed448.Point(x2, y2, _1n9, t2));
|
|
58340
58157
|
}
|
|
58341
58158
|
/**
|
|
58342
58159
|
* Converts decaf-encoded string to decaf point.
|
|
@@ -58344,7 +58161,11 @@ var init_ed448 = __esm({
|
|
|
58344
58161
|
* @param hex Decaf-encoded 56 bytes. Not every 56-byte string is valid decaf encoding
|
|
58345
58162
|
*/
|
|
58346
58163
|
static fromHex(hex3) {
|
|
58347
|
-
return __DecafPoint.fromBytes(
|
|
58164
|
+
return __DecafPoint.fromBytes(ensureBytes("decafHex", hex3, 56));
|
|
58165
|
+
}
|
|
58166
|
+
/** @deprecated use `import { pippenger } from '@noble/curves/abstract/curve.js';` */
|
|
58167
|
+
static msm(points, scalars) {
|
|
58168
|
+
return pippenger(__DecafPoint, Fn2, points, scalars);
|
|
58348
58169
|
}
|
|
58349
58170
|
/**
|
|
58350
58171
|
* Encodes decaf point to Uint8Array.
|
|
@@ -58352,8 +58173,8 @@ var init_ed448 = __esm({
|
|
|
58352
58173
|
*/
|
|
58353
58174
|
toBytes() {
|
|
58354
58175
|
const { X: X2, Z: Z2, T: T2 } = this.ep;
|
|
58355
|
-
const P2 =
|
|
58356
|
-
const mod4 = (n2) =>
|
|
58176
|
+
const P2 = Fp2.ORDER;
|
|
58177
|
+
const mod4 = (n2) => Fp2.create(n2);
|
|
58357
58178
|
const u1 = mod4(mod4(X2 + T2) * mod4(X2 - T2));
|
|
58358
58179
|
const x2 = mod4(X2 * X2);
|
|
58359
58180
|
const { value: invsqrt } = invertSqrt2(mod4(u1 * ONE_MINUS_D * x2));
|
|
@@ -58374,76 +58195,57 @@ var init_ed448 = __esm({
|
|
|
58374
58195
|
this.assertSame(other);
|
|
58375
58196
|
const { X: X1, Y: Y1 } = this.ep;
|
|
58376
58197
|
const { X: X2, Y: Y2 } = other.ep;
|
|
58377
|
-
return
|
|
58198
|
+
return Fp2.create(X1 * Y2) === Fp2.create(Y1 * X2);
|
|
58378
58199
|
}
|
|
58379
58200
|
is0() {
|
|
58380
58201
|
return this.equals(__DecafPoint.ZERO);
|
|
58381
58202
|
}
|
|
58382
58203
|
};
|
|
58204
|
+
_DecafPoint.BASE = /* @__PURE__ */ (() => new _DecafPoint(ed448.Point.BASE).multiplyUnsafe(_2n7))();
|
|
58205
|
+
_DecafPoint.ZERO = /* @__PURE__ */ (() => new _DecafPoint(ed448.Point.ZERO))();
|
|
58206
|
+
_DecafPoint.Fp = /* @__PURE__ */ (() => Fp448)();
|
|
58207
|
+
_DecafPoint.Fn = /* @__PURE__ */ (() => Fn448)();
|
|
58383
58208
|
decaf448 = { Point: _DecafPoint };
|
|
58384
58209
|
decaf448_hasher = {
|
|
58385
|
-
Point: _DecafPoint,
|
|
58386
58210
|
hashToCurve(msg, options) {
|
|
58387
58211
|
const DST = options?.DST || "decaf448_XOF:SHAKE256_D448MAP_RO_";
|
|
58388
|
-
return
|
|
58212
|
+
return decaf448_map(expand_message_xof(msg, DST, 112, 224, shake2562));
|
|
58389
58213
|
},
|
|
58390
|
-
|
|
58391
|
-
|
|
58392
|
-
|
|
58393
|
-
* it must use 84-byte xof (56+56/2), not 64.
|
|
58394
|
-
*/
|
|
58214
|
+
// Warning: has big modulo bias of 2^-64.
|
|
58215
|
+
// RFC is invalid. RFC says "use 64-byte xof", while for 2^-112 bias
|
|
58216
|
+
// it must use 84-byte xof (56+56/2), not 64.
|
|
58395
58217
|
hashToScalar(msg, options = { DST: _DST_scalar }) {
|
|
58396
58218
|
const xof = expand_message_xof(msg, options.DST, 64, 256, shake2562);
|
|
58397
58219
|
return Fn448.create(bytesToNumberLE2(xof));
|
|
58398
|
-
}
|
|
58399
|
-
|
|
58400
|
-
* HashToCurve-like construction based on RFC 9496 (Element Derivation).
|
|
58401
|
-
* Converts 112 uniform random bytes into a curve point.
|
|
58402
|
-
*
|
|
58403
|
-
* WARNING: This represents an older hash-to-curve construction, preceding the finalization of RFC 9380.
|
|
58404
|
-
* It was later reused as a component in the newer `hash_to_ristretto255` function defined in RFC 9380.
|
|
58405
|
-
*/
|
|
58406
|
-
deriveToCurve(bytes) {
|
|
58407
|
-
abytes3(bytes, 112);
|
|
58408
|
-
const skipValidation = true;
|
|
58409
|
-
const r1 = Fp448.create(Fp448.fromBytes(bytes.subarray(0, 56), skipValidation));
|
|
58410
|
-
const R1 = calcElligatorDecafMap(r1);
|
|
58411
|
-
const r2 = Fp448.create(Fp448.fromBytes(bytes.subarray(56, 112), skipValidation));
|
|
58412
|
-
const R2 = calcElligatorDecafMap(r2);
|
|
58413
|
-
return new _DecafPoint(R1.add(R2));
|
|
58414
|
-
}
|
|
58415
|
-
};
|
|
58416
|
-
decaf448_oprf = /* @__PURE__ */ (() => createORPF({
|
|
58417
|
-
name: "decaf448-SHAKE256",
|
|
58418
|
-
Point: _DecafPoint,
|
|
58419
|
-
hash: (msg) => shake2562(msg, { dkLen: 64 }),
|
|
58420
|
-
hashToGroup: decaf448_hasher.hashToCurve,
|
|
58421
|
-
hashToScalar: decaf448_hasher.hashToScalar
|
|
58422
|
-
}))();
|
|
58220
|
+
}
|
|
58221
|
+
};
|
|
58423
58222
|
ED448_TORSION_SUBGROUP = [
|
|
58424
58223
|
"010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
58425
58224
|
"fefffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffff00",
|
|
58426
58225
|
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
58427
58226
|
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080"
|
|
58428
58227
|
];
|
|
58228
|
+
DecafPoint = _DecafPoint;
|
|
58229
|
+
hashToCurve2 = /* @__PURE__ */ (() => ed448_hasher.hashToCurve)();
|
|
58230
|
+
encodeToCurve2 = /* @__PURE__ */ (() => ed448_hasher.encodeToCurve)();
|
|
58231
|
+
hashToDecaf448 = /* @__PURE__ */ (() => decaf448_hasher.hashToCurve)();
|
|
58232
|
+
hash_to_decaf448 = /* @__PURE__ */ (() => decaf448_hasher.hashToCurve)();
|
|
58233
|
+
edwardsToMontgomery2 = edwardsToMontgomeryPub2;
|
|
58429
58234
|
}
|
|
58430
58235
|
});
|
|
58431
58236
|
|
|
58432
|
-
//
|
|
58433
|
-
var
|
|
58237
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js
|
|
58238
|
+
var HMAC, hmac2;
|
|
58434
58239
|
var init_hmac2 = __esm({
|
|
58435
|
-
"
|
|
58240
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js"() {
|
|
58436
58241
|
init_utils2();
|
|
58437
|
-
|
|
58438
|
-
|
|
58439
|
-
|
|
58440
|
-
|
|
58441
|
-
|
|
58442
|
-
finished = false;
|
|
58443
|
-
destroyed = false;
|
|
58444
|
-
constructor(hash2, key) {
|
|
58242
|
+
HMAC = class extends Hash {
|
|
58243
|
+
constructor(hash2, _key) {
|
|
58244
|
+
super();
|
|
58245
|
+
this.finished = false;
|
|
58246
|
+
this.destroyed = false;
|
|
58445
58247
|
ahash2(hash2);
|
|
58446
|
-
|
|
58248
|
+
const key = toBytes(_key);
|
|
58447
58249
|
this.iHash = hash2.create();
|
|
58448
58250
|
if (typeof this.iHash.update !== "function")
|
|
58449
58251
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
@@ -58468,7 +58270,7 @@ var init_hmac2 = __esm({
|
|
|
58468
58270
|
}
|
|
58469
58271
|
digestInto(out) {
|
|
58470
58272
|
aexists3(this);
|
|
58471
|
-
abytes3(out, this.outputLen
|
|
58273
|
+
abytes3(out, this.outputLen);
|
|
58472
58274
|
this.finished = true;
|
|
58473
58275
|
this.iHash.digestInto(out);
|
|
58474
58276
|
this.oHash.update(out);
|
|
@@ -58481,7 +58283,7 @@ var init_hmac2 = __esm({
|
|
|
58481
58283
|
return out;
|
|
58482
58284
|
}
|
|
58483
58285
|
_cloneInto(to) {
|
|
58484
|
-
to
|
|
58286
|
+
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
58485
58287
|
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
58486
58288
|
to = to;
|
|
58487
58289
|
to.finished = finished;
|
|
@@ -58501,12 +58303,12 @@ var init_hmac2 = __esm({
|
|
|
58501
58303
|
this.iHash.destroy();
|
|
58502
58304
|
}
|
|
58503
58305
|
};
|
|
58504
|
-
hmac2 = (hash2, key, message) => new
|
|
58505
|
-
hmac2.create = (hash2, key) => new
|
|
58306
|
+
hmac2 = (hash2, key, message) => new HMAC(hash2, key).update(message).digest();
|
|
58307
|
+
hmac2.create = (hash2, key) => new HMAC(hash2, key);
|
|
58506
58308
|
}
|
|
58507
58309
|
});
|
|
58508
58310
|
|
|
58509
|
-
//
|
|
58311
|
+
// ../../node_modules/@noble/curves/esm/abstract/weierstrass.js
|
|
58510
58312
|
function _splitEndoScalar(k2, basis, n2) {
|
|
58511
58313
|
const [[a1, b1], [a2, b2]] = basis;
|
|
58512
58314
|
const c1 = divNearest(b2 * k2, n2);
|
|
@@ -58535,24 +58337,42 @@ function validateSigOpts(opts, def) {
|
|
|
58535
58337
|
for (let optName of Object.keys(def)) {
|
|
58536
58338
|
optsn[optName] = opts[optName] === void 0 ? def[optName] : opts[optName];
|
|
58537
58339
|
}
|
|
58538
|
-
|
|
58539
|
-
|
|
58340
|
+
_abool2(optsn.lowS, "lowS");
|
|
58341
|
+
_abool2(optsn.prehash, "prehash");
|
|
58540
58342
|
if (optsn.format !== void 0)
|
|
58541
58343
|
validateSigFormat(optsn.format);
|
|
58542
58344
|
return optsn;
|
|
58543
58345
|
}
|
|
58544
|
-
function
|
|
58545
|
-
const
|
|
58346
|
+
function _normFnElement(Fn3, key) {
|
|
58347
|
+
const { BYTES: expected } = Fn3;
|
|
58348
|
+
let num;
|
|
58349
|
+
if (typeof key === "bigint") {
|
|
58350
|
+
num = key;
|
|
58351
|
+
} else {
|
|
58352
|
+
let bytes = ensureBytes("private key", key);
|
|
58353
|
+
try {
|
|
58354
|
+
num = Fn3.fromBytes(bytes);
|
|
58355
|
+
} catch (error2) {
|
|
58356
|
+
throw new Error(`invalid private key: expected ui8a of size ${expected}, got ${typeof key}`);
|
|
58357
|
+
}
|
|
58358
|
+
}
|
|
58359
|
+
if (!Fn3.isValidNot0(num))
|
|
58360
|
+
throw new Error("invalid private key: out of range [1..N-1]");
|
|
58361
|
+
return num;
|
|
58362
|
+
}
|
|
58363
|
+
function weierstrassN(params, extraOpts = {}) {
|
|
58364
|
+
const validated = _createCurveFields("weierstrass", params, extraOpts);
|
|
58546
58365
|
const { Fp: Fp3, Fn: Fn3 } = validated;
|
|
58547
58366
|
let CURVE = validated.CURVE;
|
|
58548
58367
|
const { h: cofactor, n: CURVE_ORDER } = CURVE;
|
|
58549
|
-
|
|
58368
|
+
_validateObject(extraOpts, {}, {
|
|
58550
58369
|
allowInfinityPoint: "boolean",
|
|
58551
58370
|
clearCofactor: "function",
|
|
58552
58371
|
isTorsionFree: "function",
|
|
58553
58372
|
fromBytes: "function",
|
|
58554
58373
|
toBytes: "function",
|
|
58555
|
-
endo: "object"
|
|
58374
|
+
endo: "object",
|
|
58375
|
+
wrapPrivateKey: "boolean"
|
|
58556
58376
|
});
|
|
58557
58377
|
const { endo } = extraOpts;
|
|
58558
58378
|
if (endo) {
|
|
@@ -58568,7 +58388,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58568
58388
|
function pointToBytes(_c, point, isCompressed) {
|
|
58569
58389
|
const { x: x2, y: y2 } = point.toAffine();
|
|
58570
58390
|
const bx = Fp3.toBytes(x2);
|
|
58571
|
-
|
|
58391
|
+
_abool2(isCompressed, "isCompressed");
|
|
58572
58392
|
if (isCompressed) {
|
|
58573
58393
|
assertCompressionIsSupported();
|
|
58574
58394
|
const hasEvenY = !Fp3.isOdd(y2);
|
|
@@ -58578,7 +58398,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58578
58398
|
}
|
|
58579
58399
|
}
|
|
58580
58400
|
function pointFromBytes(bytes) {
|
|
58581
|
-
|
|
58401
|
+
_abytes2(bytes, void 0, "Point");
|
|
58582
58402
|
const { publicKey: comp, publicKeyUncompressed: uncomp } = lengths;
|
|
58583
58403
|
const length = bytes.length;
|
|
58584
58404
|
const head = bytes[0];
|
|
@@ -58596,9 +58416,9 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58596
58416
|
throw new Error("bad point: is not on curve, sqrt error" + err);
|
|
58597
58417
|
}
|
|
58598
58418
|
assertCompressionIsSupported();
|
|
58599
|
-
const
|
|
58600
|
-
const
|
|
58601
|
-
if (
|
|
58419
|
+
const isYOdd = Fp3.isOdd(y3);
|
|
58420
|
+
const isHeadOdd = (head & 1) === 1;
|
|
58421
|
+
if (isHeadOdd !== isYOdd)
|
|
58602
58422
|
y3 = Fp3.neg(y3);
|
|
58603
58423
|
return { x: x2, y: y3 };
|
|
58604
58424
|
} else if (length === uncomp && head === 4) {
|
|
@@ -58637,7 +58457,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58637
58457
|
}
|
|
58638
58458
|
function aprjpoint(other) {
|
|
58639
58459
|
if (!(other instanceof Point))
|
|
58640
|
-
throw new Error("
|
|
58460
|
+
throw new Error("ProjectivePoint expected");
|
|
58641
58461
|
}
|
|
58642
58462
|
function splitEndoScalarN(k2) {
|
|
58643
58463
|
if (!endo || !endo.basises)
|
|
@@ -58682,18 +58502,6 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58682
58502
|
return k1p.add(k2p);
|
|
58683
58503
|
}
|
|
58684
58504
|
class Point {
|
|
58685
|
-
// base / generator point
|
|
58686
|
-
static BASE = new Point(CURVE.Gx, CURVE.Gy, Fp3.ONE);
|
|
58687
|
-
// zero / infinity / identity point
|
|
58688
|
-
static ZERO = new Point(Fp3.ZERO, Fp3.ONE, Fp3.ZERO);
|
|
58689
|
-
// 0, 1, 0
|
|
58690
|
-
// math field
|
|
58691
|
-
static Fp = Fp3;
|
|
58692
|
-
// scalar field
|
|
58693
|
-
static Fn = Fn3;
|
|
58694
|
-
X;
|
|
58695
|
-
Y;
|
|
58696
|
-
Z;
|
|
58697
58505
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
58698
58506
|
constructor(X2, Y2, Z2) {
|
|
58699
58507
|
this.X = acoord("x", X2);
|
|
@@ -58716,12 +58524,12 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58716
58524
|
return new Point(x2, y2, Fp3.ONE);
|
|
58717
58525
|
}
|
|
58718
58526
|
static fromBytes(bytes) {
|
|
58719
|
-
const P2 = Point.fromAffine(decodePoint(
|
|
58527
|
+
const P2 = Point.fromAffine(decodePoint(_abytes2(bytes, void 0, "point")));
|
|
58720
58528
|
P2.assertValidity();
|
|
58721
58529
|
return P2;
|
|
58722
58530
|
}
|
|
58723
58531
|
static fromHex(hex3) {
|
|
58724
|
-
return Point.fromBytes(
|
|
58532
|
+
return Point.fromBytes(ensureBytes("pointHex", hex3));
|
|
58725
58533
|
}
|
|
58726
58534
|
get x() {
|
|
58727
58535
|
return this.toAffine().x;
|
|
@@ -58918,6 +58726,10 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58918
58726
|
return wnaf.unsafe(p2, sc);
|
|
58919
58727
|
}
|
|
58920
58728
|
}
|
|
58729
|
+
multiplyAndAddUnsafe(Q2, a2, b2) {
|
|
58730
|
+
const sum = this.multiplyUnsafe(a2).add(Q2.multiplyUnsafe(b2));
|
|
58731
|
+
return sum.is0() ? void 0 : sum;
|
|
58732
|
+
}
|
|
58921
58733
|
/**
|
|
58922
58734
|
* Converts Projective point to affine (x, y) coordinates.
|
|
58923
58735
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
@@ -58949,7 +58761,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58949
58761
|
return this.multiplyUnsafe(cofactor).is0();
|
|
58950
58762
|
}
|
|
58951
58763
|
toBytes(isCompressed = true) {
|
|
58952
|
-
|
|
58764
|
+
_abool2(isCompressed, "isCompressed");
|
|
58953
58765
|
this.assertValidity();
|
|
58954
58766
|
return encodePoint(Point, this, isCompressed);
|
|
58955
58767
|
}
|
|
@@ -58959,7 +58771,36 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58959
58771
|
toString() {
|
|
58960
58772
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
58961
58773
|
}
|
|
58774
|
+
// TODO: remove
|
|
58775
|
+
get px() {
|
|
58776
|
+
return this.X;
|
|
58777
|
+
}
|
|
58778
|
+
get py() {
|
|
58779
|
+
return this.X;
|
|
58780
|
+
}
|
|
58781
|
+
get pz() {
|
|
58782
|
+
return this.Z;
|
|
58783
|
+
}
|
|
58784
|
+
toRawBytes(isCompressed = true) {
|
|
58785
|
+
return this.toBytes(isCompressed);
|
|
58786
|
+
}
|
|
58787
|
+
_setWindowSize(windowSize) {
|
|
58788
|
+
this.precompute(windowSize);
|
|
58789
|
+
}
|
|
58790
|
+
static normalizeZ(points) {
|
|
58791
|
+
return normalizeZ(Point, points);
|
|
58792
|
+
}
|
|
58793
|
+
static msm(points, scalars) {
|
|
58794
|
+
return pippenger(Point, Fn3, points, scalars);
|
|
58795
|
+
}
|
|
58796
|
+
static fromPrivateKey(privateKey) {
|
|
58797
|
+
return Point.BASE.multiply(_normFnElement(Fn3, privateKey));
|
|
58798
|
+
}
|
|
58962
58799
|
}
|
|
58800
|
+
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp3.ONE);
|
|
58801
|
+
Point.ZERO = new Point(Fp3.ZERO, Fp3.ONE, Fp3.ZERO);
|
|
58802
|
+
Point.Fp = Fp3;
|
|
58803
|
+
Point.Fn = Fn3;
|
|
58963
58804
|
const bits = Fn3.BITS;
|
|
58964
58805
|
const wnaf = new wNAF(Point, extraOpts.endo ? Math.ceil(bits / 2) : bits);
|
|
58965
58806
|
Point.BASE.precompute(8);
|
|
@@ -59084,8 +58925,7 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
59084
58925
|
const lengths = Object.assign(getWLengths(Point.Fp, Fn3), { seed: getMinHashLength(Fn3.ORDER) });
|
|
59085
58926
|
function isValidSecretKey(secretKey) {
|
|
59086
58927
|
try {
|
|
59087
|
-
|
|
59088
|
-
return Fn3.isValidNot0(num);
|
|
58928
|
+
return !!_normFnElement(Fn3, secretKey);
|
|
59089
58929
|
} catch (error2) {
|
|
59090
58930
|
return false;
|
|
59091
58931
|
}
|
|
@@ -59104,18 +58944,24 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
59104
58944
|
}
|
|
59105
58945
|
}
|
|
59106
58946
|
function randomSecretKey(seed = randomBytes_(lengths.seed)) {
|
|
59107
|
-
return mapHashToField(
|
|
58947
|
+
return mapHashToField(_abytes2(seed, lengths.seed, "seed"), Fn3.ORDER);
|
|
59108
58948
|
}
|
|
59109
58949
|
function getPublicKey(secretKey, isCompressed = true) {
|
|
59110
|
-
return Point.BASE.multiply(Fn3
|
|
58950
|
+
return Point.BASE.multiply(_normFnElement(Fn3, secretKey)).toBytes(isCompressed);
|
|
58951
|
+
}
|
|
58952
|
+
function keygen(seed) {
|
|
58953
|
+
const secretKey = randomSecretKey(seed);
|
|
58954
|
+
return { secretKey, publicKey: getPublicKey(secretKey) };
|
|
59111
58955
|
}
|
|
59112
58956
|
function isProbPub(item) {
|
|
58957
|
+
if (typeof item === "bigint")
|
|
58958
|
+
return false;
|
|
58959
|
+
if (item instanceof Point)
|
|
58960
|
+
return true;
|
|
59113
58961
|
const { secretKey, publicKey, publicKeyUncompressed } = lengths;
|
|
59114
|
-
if (
|
|
59115
|
-
return void 0;
|
|
59116
|
-
if ("_lengths" in Fn3 && Fn3._lengths || secretKey === publicKey)
|
|
58962
|
+
if (Fn3.allowedLengths || secretKey === publicKey)
|
|
59117
58963
|
return void 0;
|
|
59118
|
-
const l2 =
|
|
58964
|
+
const l2 = ensureBytes("key", item).length;
|
|
59119
58965
|
return l2 === publicKey || l2 === publicKeyUncompressed;
|
|
59120
58966
|
}
|
|
59121
58967
|
function getSharedSecret(secretKeyA, publicKeyB, isCompressed = true) {
|
|
@@ -59123,40 +58969,46 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
59123
58969
|
throw new Error("first arg must be private key");
|
|
59124
58970
|
if (isProbPub(publicKeyB) === false)
|
|
59125
58971
|
throw new Error("second arg must be public key");
|
|
59126
|
-
const s2 = Fn3
|
|
59127
|
-
const b2 = Point.
|
|
58972
|
+
const s2 = _normFnElement(Fn3, secretKeyA);
|
|
58973
|
+
const b2 = Point.fromHex(publicKeyB);
|
|
59128
58974
|
return b2.multiply(s2).toBytes(isCompressed);
|
|
59129
58975
|
}
|
|
59130
58976
|
const utils = {
|
|
59131
58977
|
isValidSecretKey,
|
|
59132
58978
|
isValidPublicKey,
|
|
59133
|
-
randomSecretKey
|
|
58979
|
+
randomSecretKey,
|
|
58980
|
+
// TODO: remove
|
|
58981
|
+
isValidPrivateKey: isValidSecretKey,
|
|
58982
|
+
randomPrivateKey: randomSecretKey,
|
|
58983
|
+
normPrivateKeyToScalar: (key) => _normFnElement(Fn3, key),
|
|
58984
|
+
precompute(windowSize = 8, point = Point.BASE) {
|
|
58985
|
+
return point.precompute(windowSize, false);
|
|
58986
|
+
}
|
|
59134
58987
|
};
|
|
59135
|
-
const keygen = createKeygen2(randomSecretKey, getPublicKey);
|
|
59136
58988
|
return Object.freeze({ getPublicKey, getSharedSecret, keygen, Point, utils, lengths });
|
|
59137
58989
|
}
|
|
59138
58990
|
function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
59139
58991
|
ahash2(hash2);
|
|
59140
|
-
|
|
58992
|
+
_validateObject(ecdsaOpts, {}, {
|
|
59141
58993
|
hmac: "function",
|
|
59142
58994
|
lowS: "boolean",
|
|
59143
58995
|
randomBytes: "function",
|
|
59144
58996
|
bits2int: "function",
|
|
59145
58997
|
bits2int_modN: "function"
|
|
59146
58998
|
});
|
|
59147
|
-
ecdsaOpts = Object.assign({}, ecdsaOpts);
|
|
59148
58999
|
const randomBytes3 = ecdsaOpts.randomBytes || randomBytes2;
|
|
59149
|
-
const
|
|
59000
|
+
const hmac4 = ecdsaOpts.hmac || ((key, ...msgs) => hmac2(hash2, key, concatBytes2(...msgs)));
|
|
59150
59001
|
const { Fp: Fp3, Fn: Fn3 } = Point;
|
|
59151
59002
|
const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn3;
|
|
59152
59003
|
const { keygen, getPublicKey, getSharedSecret, utils, lengths } = ecdh(Point, ecdsaOpts);
|
|
59153
59004
|
const defaultSigOpts = {
|
|
59154
|
-
prehash:
|
|
59155
|
-
lowS: typeof ecdsaOpts.lowS === "boolean" ? ecdsaOpts.lowS :
|
|
59156
|
-
format:
|
|
59005
|
+
prehash: false,
|
|
59006
|
+
lowS: typeof ecdsaOpts.lowS === "boolean" ? ecdsaOpts.lowS : false,
|
|
59007
|
+
format: void 0,
|
|
59008
|
+
//'compact' as ECDSASigFormat,
|
|
59157
59009
|
extraEntropy: false
|
|
59158
59010
|
};
|
|
59159
|
-
const
|
|
59011
|
+
const defaultSigOpts_format = "compact";
|
|
59160
59012
|
function isBiggerThanHalfOrder(number3) {
|
|
59161
59013
|
const HALF = CURVE_ORDER >> _1n10;
|
|
59162
59014
|
return number3 > HALF;
|
|
@@ -59166,36 +59018,25 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59166
59018
|
throw new Error(`invalid signature ${title}: out of range 1..Point.Fn.ORDER`);
|
|
59167
59019
|
return num;
|
|
59168
59020
|
}
|
|
59169
|
-
function assertSmallCofactor() {
|
|
59170
|
-
if (hasLargeCofactor)
|
|
59171
|
-
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
59172
|
-
}
|
|
59173
59021
|
function validateSigLength(bytes, format) {
|
|
59174
59022
|
validateSigFormat(format);
|
|
59175
59023
|
const size = lengths.signature;
|
|
59176
59024
|
const sizer = format === "compact" ? size : format === "recovered" ? size + 1 : void 0;
|
|
59177
|
-
return
|
|
59025
|
+
return _abytes2(bytes, sizer, `${format} signature`);
|
|
59178
59026
|
}
|
|
59179
59027
|
class Signature {
|
|
59180
|
-
r;
|
|
59181
|
-
s;
|
|
59182
|
-
recovery;
|
|
59183
59028
|
constructor(r2, s2, recovery) {
|
|
59184
59029
|
this.r = validateRS("r", r2);
|
|
59185
59030
|
this.s = validateRS("s", s2);
|
|
59186
|
-
if (recovery != null)
|
|
59187
|
-
assertSmallCofactor();
|
|
59188
|
-
if (![0, 1, 2, 3].includes(recovery))
|
|
59189
|
-
throw new Error("invalid recovery id");
|
|
59031
|
+
if (recovery != null)
|
|
59190
59032
|
this.recovery = recovery;
|
|
59191
|
-
}
|
|
59192
59033
|
Object.freeze(this);
|
|
59193
59034
|
}
|
|
59194
|
-
static fromBytes(bytes, format =
|
|
59035
|
+
static fromBytes(bytes, format = defaultSigOpts_format) {
|
|
59195
59036
|
validateSigLength(bytes, format);
|
|
59196
59037
|
let recid;
|
|
59197
59038
|
if (format === "der") {
|
|
59198
|
-
const { r: r3, s: s3 } = DER.toSig(
|
|
59039
|
+
const { r: r3, s: s3 } = DER.toSig(_abytes2(bytes));
|
|
59199
59040
|
return new Signature(r3, s3);
|
|
59200
59041
|
}
|
|
59201
59042
|
if (format === "recovered") {
|
|
@@ -59203,7 +59044,7 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59203
59044
|
format = "compact";
|
|
59204
59045
|
bytes = bytes.subarray(1);
|
|
59205
59046
|
}
|
|
59206
|
-
const L2 =
|
|
59047
|
+
const L2 = Fn3.BYTES;
|
|
59207
59048
|
const r2 = bytes.subarray(0, L2);
|
|
59208
59049
|
const s2 = bytes.subarray(L2, L2 * 2);
|
|
59209
59050
|
return new Signature(Fn3.fromBytes(r2), Fn3.fromBytes(s2), recid);
|
|
@@ -59211,30 +59052,29 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59211
59052
|
static fromHex(hex3, format) {
|
|
59212
59053
|
return this.fromBytes(hexToBytes3(hex3), format);
|
|
59213
59054
|
}
|
|
59214
|
-
assertRecovery() {
|
|
59215
|
-
const { recovery } = this;
|
|
59216
|
-
if (recovery == null)
|
|
59217
|
-
throw new Error("invalid recovery id: must be present");
|
|
59218
|
-
return recovery;
|
|
59219
|
-
}
|
|
59220
59055
|
addRecoveryBit(recovery) {
|
|
59221
59056
|
return new Signature(this.r, this.s, recovery);
|
|
59222
59057
|
}
|
|
59223
59058
|
recoverPublicKey(messageHash) {
|
|
59224
|
-
const
|
|
59225
|
-
const recovery = this
|
|
59226
|
-
|
|
59059
|
+
const FIELD_ORDER = Fp3.ORDER;
|
|
59060
|
+
const { r: r2, s: s2, recovery: rec } = this;
|
|
59061
|
+
if (rec == null || ![0, 1, 2, 3].includes(rec))
|
|
59062
|
+
throw new Error("recovery id invalid");
|
|
59063
|
+
const hasCofactor = CURVE_ORDER * _2n8 < FIELD_ORDER;
|
|
59064
|
+
if (hasCofactor && rec > 1)
|
|
59065
|
+
throw new Error("recovery id is ambiguous for h>1 curve");
|
|
59066
|
+
const radj = rec === 2 || rec === 3 ? r2 + CURVE_ORDER : r2;
|
|
59227
59067
|
if (!Fp3.isValid(radj))
|
|
59228
|
-
throw new Error("
|
|
59068
|
+
throw new Error("recovery id 2 or 3 invalid");
|
|
59229
59069
|
const x2 = Fp3.toBytes(radj);
|
|
59230
|
-
const R2 = Point.fromBytes(concatBytes2(pprefix((
|
|
59070
|
+
const R2 = Point.fromBytes(concatBytes2(pprefix((rec & 1) === 0), x2));
|
|
59231
59071
|
const ir2 = Fn3.inv(radj);
|
|
59232
|
-
const h2 = bits2int_modN(
|
|
59072
|
+
const h2 = bits2int_modN(ensureBytes("msgHash", messageHash));
|
|
59233
59073
|
const u1 = Fn3.create(-h2 * ir2);
|
|
59234
59074
|
const u2 = Fn3.create(s2 * ir2);
|
|
59235
59075
|
const Q2 = Point.BASE.multiplyUnsafe(u1).add(R2.multiplyUnsafe(u2));
|
|
59236
59076
|
if (Q2.is0())
|
|
59237
|
-
throw new Error("
|
|
59077
|
+
throw new Error("point at infinify");
|
|
59238
59078
|
Q2.assertValidity();
|
|
59239
59079
|
return Q2;
|
|
59240
59080
|
}
|
|
@@ -59242,22 +59082,46 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59242
59082
|
hasHighS() {
|
|
59243
59083
|
return isBiggerThanHalfOrder(this.s);
|
|
59244
59084
|
}
|
|
59245
|
-
toBytes(format =
|
|
59085
|
+
toBytes(format = defaultSigOpts_format) {
|
|
59246
59086
|
validateSigFormat(format);
|
|
59247
59087
|
if (format === "der")
|
|
59248
59088
|
return hexToBytes3(DER.hexFromSig(this));
|
|
59249
|
-
const
|
|
59250
|
-
const
|
|
59251
|
-
const sb = Fn3.toBytes(s2);
|
|
59089
|
+
const r2 = Fn3.toBytes(this.r);
|
|
59090
|
+
const s2 = Fn3.toBytes(this.s);
|
|
59252
59091
|
if (format === "recovered") {
|
|
59253
|
-
|
|
59254
|
-
|
|
59092
|
+
if (this.recovery == null)
|
|
59093
|
+
throw new Error("recovery bit must be present");
|
|
59094
|
+
return concatBytes2(Uint8Array.of(this.recovery), r2, s2);
|
|
59255
59095
|
}
|
|
59256
|
-
return concatBytes2(
|
|
59096
|
+
return concatBytes2(r2, s2);
|
|
59257
59097
|
}
|
|
59258
59098
|
toHex(format) {
|
|
59259
59099
|
return bytesToHex3(this.toBytes(format));
|
|
59260
59100
|
}
|
|
59101
|
+
// TODO: remove
|
|
59102
|
+
assertValidity() {
|
|
59103
|
+
}
|
|
59104
|
+
static fromCompact(hex3) {
|
|
59105
|
+
return Signature.fromBytes(ensureBytes("sig", hex3), "compact");
|
|
59106
|
+
}
|
|
59107
|
+
static fromDER(hex3) {
|
|
59108
|
+
return Signature.fromBytes(ensureBytes("sig", hex3), "der");
|
|
59109
|
+
}
|
|
59110
|
+
normalizeS() {
|
|
59111
|
+
return this.hasHighS() ? new Signature(this.r, Fn3.neg(this.s), this.recovery) : this;
|
|
59112
|
+
}
|
|
59113
|
+
toDERRawBytes() {
|
|
59114
|
+
return this.toBytes("der");
|
|
59115
|
+
}
|
|
59116
|
+
toDERHex() {
|
|
59117
|
+
return bytesToHex3(this.toBytes("der"));
|
|
59118
|
+
}
|
|
59119
|
+
toCompactRawBytes() {
|
|
59120
|
+
return this.toBytes("compact");
|
|
59121
|
+
}
|
|
59122
|
+
toCompactHex() {
|
|
59123
|
+
return bytesToHex3(this.toBytes("compact"));
|
|
59124
|
+
}
|
|
59261
59125
|
}
|
|
59262
59126
|
const bits2int = ecdsaOpts.bits2int || function bits2int_def(bytes) {
|
|
59263
59127
|
if (bytes.length > 8192)
|
|
@@ -59275,20 +59139,20 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59275
59139
|
return Fn3.toBytes(num);
|
|
59276
59140
|
}
|
|
59277
59141
|
function validateMsgAndHash(message, prehash) {
|
|
59278
|
-
|
|
59279
|
-
return prehash ?
|
|
59142
|
+
_abytes2(message, void 0, "message");
|
|
59143
|
+
return prehash ? _abytes2(hash2(message), void 0, "prehashed message") : message;
|
|
59280
59144
|
}
|
|
59281
|
-
function prepSig(message,
|
|
59145
|
+
function prepSig(message, privateKey, opts) {
|
|
59146
|
+
if (["recovered", "canonical"].some((k2) => k2 in opts))
|
|
59147
|
+
throw new Error("sign() legacy options not supported");
|
|
59282
59148
|
const { lowS, prehash, extraEntropy } = validateSigOpts(opts, defaultSigOpts);
|
|
59283
59149
|
message = validateMsgAndHash(message, prehash);
|
|
59284
59150
|
const h1int = bits2int_modN(message);
|
|
59285
|
-
const d2 = Fn3
|
|
59286
|
-
if (!Fn3.isValidNot0(d2))
|
|
59287
|
-
throw new Error("invalid private key");
|
|
59151
|
+
const d2 = _normFnElement(Fn3, privateKey);
|
|
59288
59152
|
const seedArgs = [int2octets(d2), int2octets(h1int)];
|
|
59289
59153
|
if (extraEntropy != null && extraEntropy !== false) {
|
|
59290
59154
|
const e = extraEntropy === true ? randomBytes3(lengths.secretKey) : extraEntropy;
|
|
59291
|
-
seedArgs.push(
|
|
59155
|
+
seedArgs.push(ensureBytes("extraEntropy", e));
|
|
59292
59156
|
}
|
|
59293
59157
|
const seed = concatBytes2(...seedArgs);
|
|
59294
59158
|
const m2 = h1int;
|
|
@@ -59310,27 +59174,54 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59310
59174
|
normS = Fn3.neg(s2);
|
|
59311
59175
|
recovery ^= 1;
|
|
59312
59176
|
}
|
|
59313
|
-
return new Signature(r2, normS,
|
|
59177
|
+
return new Signature(r2, normS, recovery);
|
|
59314
59178
|
}
|
|
59315
59179
|
return { seed, k2sig };
|
|
59316
59180
|
}
|
|
59317
59181
|
function sign(message, secretKey, opts = {}) {
|
|
59182
|
+
message = ensureBytes("message", message);
|
|
59318
59183
|
const { seed, k2sig } = prepSig(message, secretKey, opts);
|
|
59319
|
-
const drbg = createHmacDrbg(hash2.outputLen, Fn3.BYTES,
|
|
59184
|
+
const drbg = createHmacDrbg(hash2.outputLen, Fn3.BYTES, hmac4);
|
|
59320
59185
|
const sig = drbg(seed, k2sig);
|
|
59321
|
-
return sig
|
|
59186
|
+
return sig;
|
|
59187
|
+
}
|
|
59188
|
+
function tryParsingSig(sg) {
|
|
59189
|
+
let sig = void 0;
|
|
59190
|
+
const isHex = typeof sg === "string" || isBytes3(sg);
|
|
59191
|
+
const isObj = !isHex && sg !== null && typeof sg === "object" && typeof sg.r === "bigint" && typeof sg.s === "bigint";
|
|
59192
|
+
if (!isHex && !isObj)
|
|
59193
|
+
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
59194
|
+
if (isObj) {
|
|
59195
|
+
sig = new Signature(sg.r, sg.s);
|
|
59196
|
+
} else if (isHex) {
|
|
59197
|
+
try {
|
|
59198
|
+
sig = Signature.fromBytes(ensureBytes("sig", sg), "der");
|
|
59199
|
+
} catch (derError) {
|
|
59200
|
+
if (!(derError instanceof DER.Err))
|
|
59201
|
+
throw derError;
|
|
59202
|
+
}
|
|
59203
|
+
if (!sig) {
|
|
59204
|
+
try {
|
|
59205
|
+
sig = Signature.fromBytes(ensureBytes("sig", sg), "compact");
|
|
59206
|
+
} catch (error2) {
|
|
59207
|
+
return false;
|
|
59208
|
+
}
|
|
59209
|
+
}
|
|
59210
|
+
}
|
|
59211
|
+
if (!sig)
|
|
59212
|
+
return false;
|
|
59213
|
+
return sig;
|
|
59322
59214
|
}
|
|
59323
59215
|
function verify(signature, message, publicKey, opts = {}) {
|
|
59324
59216
|
const { lowS, prehash, format } = validateSigOpts(opts, defaultSigOpts);
|
|
59325
|
-
publicKey =
|
|
59326
|
-
message = validateMsgAndHash(message, prehash);
|
|
59327
|
-
if (
|
|
59328
|
-
|
|
59329
|
-
|
|
59330
|
-
|
|
59331
|
-
|
|
59217
|
+
publicKey = ensureBytes("publicKey", publicKey);
|
|
59218
|
+
message = validateMsgAndHash(ensureBytes("message", message), prehash);
|
|
59219
|
+
if ("strict" in opts)
|
|
59220
|
+
throw new Error("options.strict was renamed to lowS");
|
|
59221
|
+
const sig = format === void 0 ? tryParsingSig(signature) : Signature.fromBytes(ensureBytes("sig", signature), format);
|
|
59222
|
+
if (sig === false)
|
|
59223
|
+
return false;
|
|
59332
59224
|
try {
|
|
59333
|
-
const sig = Signature.fromBytes(signature, format);
|
|
59334
59225
|
const P2 = Point.fromBytes(publicKey);
|
|
59335
59226
|
if (lowS && sig.hasHighS())
|
|
59336
59227
|
return false;
|
|
@@ -59367,9 +59258,62 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59367
59258
|
hash: hash2
|
|
59368
59259
|
});
|
|
59369
59260
|
}
|
|
59261
|
+
function _weierstrass_legacy_opts_to_new(c2) {
|
|
59262
|
+
const CURVE = {
|
|
59263
|
+
a: c2.a,
|
|
59264
|
+
b: c2.b,
|
|
59265
|
+
p: c2.Fp.ORDER,
|
|
59266
|
+
n: c2.n,
|
|
59267
|
+
h: c2.h,
|
|
59268
|
+
Gx: c2.Gx,
|
|
59269
|
+
Gy: c2.Gy
|
|
59270
|
+
};
|
|
59271
|
+
const Fp3 = c2.Fp;
|
|
59272
|
+
let allowedLengths = c2.allowedPrivateKeyLengths ? Array.from(new Set(c2.allowedPrivateKeyLengths.map((l2) => Math.ceil(l2 / 2)))) : void 0;
|
|
59273
|
+
const Fn3 = Field(CURVE.n, {
|
|
59274
|
+
BITS: c2.nBitLength,
|
|
59275
|
+
allowedLengths,
|
|
59276
|
+
modFromBytes: c2.wrapPrivateKey
|
|
59277
|
+
});
|
|
59278
|
+
const curveOpts = {
|
|
59279
|
+
Fp: Fp3,
|
|
59280
|
+
Fn: Fn3,
|
|
59281
|
+
allowInfinityPoint: c2.allowInfinityPoint,
|
|
59282
|
+
endo: c2.endo,
|
|
59283
|
+
isTorsionFree: c2.isTorsionFree,
|
|
59284
|
+
clearCofactor: c2.clearCofactor,
|
|
59285
|
+
fromBytes: c2.fromBytes,
|
|
59286
|
+
toBytes: c2.toBytes
|
|
59287
|
+
};
|
|
59288
|
+
return { CURVE, curveOpts };
|
|
59289
|
+
}
|
|
59290
|
+
function _ecdsa_legacy_opts_to_new(c2) {
|
|
59291
|
+
const { CURVE, curveOpts } = _weierstrass_legacy_opts_to_new(c2);
|
|
59292
|
+
const ecdsaOpts = {
|
|
59293
|
+
hmac: c2.hmac,
|
|
59294
|
+
randomBytes: c2.randomBytes,
|
|
59295
|
+
lowS: c2.lowS,
|
|
59296
|
+
bits2int: c2.bits2int,
|
|
59297
|
+
bits2int_modN: c2.bits2int_modN
|
|
59298
|
+
};
|
|
59299
|
+
return { CURVE, curveOpts, hash: c2.hash, ecdsaOpts };
|
|
59300
|
+
}
|
|
59301
|
+
function _ecdsa_new_output_to_legacy(c2, _ecdsa) {
|
|
59302
|
+
const Point = _ecdsa.Point;
|
|
59303
|
+
return Object.assign({}, _ecdsa, {
|
|
59304
|
+
ProjectivePoint: Point,
|
|
59305
|
+
CURVE: Object.assign({}, c2, nLength(Point.Fn.ORDER, Point.Fn.BITS))
|
|
59306
|
+
});
|
|
59307
|
+
}
|
|
59308
|
+
function weierstrass(c2) {
|
|
59309
|
+
const { CURVE, curveOpts, hash: hash2, ecdsaOpts } = _ecdsa_legacy_opts_to_new(c2);
|
|
59310
|
+
const Point = weierstrassN(CURVE, curveOpts);
|
|
59311
|
+
const signs = ecdsa(Point, hash2, ecdsaOpts);
|
|
59312
|
+
return _ecdsa_new_output_to_legacy(c2, signs);
|
|
59313
|
+
}
|
|
59370
59314
|
var divNearest, DERErr, DER, _0n9, _1n10, _2n8, _3n4, _4n3;
|
|
59371
59315
|
var init_weierstrass = __esm({
|
|
59372
|
-
"
|
|
59316
|
+
"../../node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
|
|
59373
59317
|
init_hmac2();
|
|
59374
59318
|
init_utils2();
|
|
59375
59319
|
init_utils3();
|
|
@@ -59461,9 +59405,9 @@ var init_weierstrass = __esm({
|
|
|
59461
59405
|
return bytesToNumberBE(data);
|
|
59462
59406
|
}
|
|
59463
59407
|
},
|
|
59464
|
-
toSig(
|
|
59408
|
+
toSig(hex3) {
|
|
59465
59409
|
const { Err: E2, _int: int2, _tlv: tlv } = DER;
|
|
59466
|
-
const data =
|
|
59410
|
+
const data = ensureBytes("signature", hex3);
|
|
59467
59411
|
const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
|
|
59468
59412
|
if (seqLeftBytes.length)
|
|
59469
59413
|
throw new E2("invalid signature: left bytes after parsing");
|
|
@@ -59489,32 +59433,43 @@ var init_weierstrass = __esm({
|
|
|
59489
59433
|
}
|
|
59490
59434
|
});
|
|
59491
59435
|
|
|
59492
|
-
//
|
|
59436
|
+
// ../../node_modules/@noble/curves/esm/_shortw_utils.js
|
|
59437
|
+
function createCurve(curveDef, defHash) {
|
|
59438
|
+
const create = (hash2) => weierstrass({ ...curveDef, hash: hash2 });
|
|
59439
|
+
return { ...create(defHash), create };
|
|
59440
|
+
}
|
|
59441
|
+
var init_shortw_utils = __esm({
|
|
59442
|
+
"../../node_modules/@noble/curves/esm/_shortw_utils.js"() {
|
|
59443
|
+
init_weierstrass();
|
|
59444
|
+
}
|
|
59445
|
+
});
|
|
59446
|
+
|
|
59447
|
+
// ../../node_modules/@noble/curves/esm/nist.js
|
|
59493
59448
|
var nist_exports = {};
|
|
59494
59449
|
__export(nist_exports, {
|
|
59495
59450
|
p256: () => p256,
|
|
59496
59451
|
p256_hasher: () => p256_hasher,
|
|
59497
|
-
p256_oprf: () => p256_oprf,
|
|
59498
59452
|
p384: () => p384,
|
|
59499
59453
|
p384_hasher: () => p384_hasher,
|
|
59500
|
-
p384_oprf: () => p384_oprf,
|
|
59501
59454
|
p521: () => p521,
|
|
59502
59455
|
p521_hasher: () => p521_hasher,
|
|
59503
|
-
|
|
59456
|
+
secp256r1: () => secp256r1,
|
|
59457
|
+
secp384r1: () => secp384r1,
|
|
59458
|
+
secp521r1: () => secp521r1
|
|
59504
59459
|
});
|
|
59505
59460
|
function createSWU(Point, opts) {
|
|
59506
59461
|
const map2 = mapToCurveSimpleSWU(Point.Fp, opts);
|
|
59507
59462
|
return (scalars) => map2(scalars[0]);
|
|
59508
59463
|
}
|
|
59509
|
-
var p256_CURVE, p384_CURVE, p521_CURVE,
|
|
59464
|
+
var p256_CURVE, p384_CURVE, p521_CURVE, Fp256, Fp384, Fp521, p256, p256_hasher, p384, p384_hasher, p521, secp256r1, secp384r1, secp521r1, p521_hasher;
|
|
59510
59465
|
var init_nist = __esm({
|
|
59511
|
-
"
|
|
59466
|
+
"../../node_modules/@noble/curves/esm/nist.js"() {
|
|
59512
59467
|
init_sha22();
|
|
59468
|
+
init_shortw_utils();
|
|
59513
59469
|
init_hash_to_curve();
|
|
59514
59470
|
init_modular2();
|
|
59515
|
-
init_oprf();
|
|
59516
59471
|
init_weierstrass();
|
|
59517
|
-
p256_CURVE =
|
|
59472
|
+
p256_CURVE = {
|
|
59518
59473
|
p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
|
|
59519
59474
|
n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
|
|
59520
59475
|
h: BigInt(1),
|
|
@@ -59522,8 +59477,8 @@ var init_nist = __esm({
|
|
|
59522
59477
|
b: BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
|
|
59523
59478
|
Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
|
|
59524
59479
|
Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")
|
|
59525
|
-
}
|
|
59526
|
-
p384_CURVE =
|
|
59480
|
+
};
|
|
59481
|
+
p384_CURVE = {
|
|
59527
59482
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),
|
|
59528
59483
|
n: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),
|
|
59529
59484
|
h: BigInt(1),
|
|
@@ -59531,8 +59486,8 @@ var init_nist = __esm({
|
|
|
59531
59486
|
b: BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),
|
|
59532
59487
|
Gx: BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),
|
|
59533
59488
|
Gy: BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")
|
|
59534
|
-
}
|
|
59535
|
-
p521_CURVE =
|
|
59489
|
+
};
|
|
59490
|
+
p521_CURVE = {
|
|
59536
59491
|
p: BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
|
59537
59492
|
n: BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),
|
|
59538
59493
|
h: BigInt(1),
|
|
@@ -59540,14 +59495,16 @@ var init_nist = __esm({
|
|
|
59540
59495
|
b: BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),
|
|
59541
59496
|
Gx: BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),
|
|
59542
59497
|
Gy: BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")
|
|
59543
|
-
}
|
|
59544
|
-
|
|
59545
|
-
|
|
59498
|
+
};
|
|
59499
|
+
Fp256 = Field(p256_CURVE.p);
|
|
59500
|
+
Fp384 = Field(p384_CURVE.p);
|
|
59501
|
+
Fp521 = Field(p521_CURVE.p);
|
|
59502
|
+
p256 = createCurve({ ...p256_CURVE, Fp: Fp256, lowS: false }, sha2562);
|
|
59546
59503
|
p256_hasher = /* @__PURE__ */ (() => {
|
|
59547
|
-
return createHasher3(
|
|
59504
|
+
return createHasher3(p256.Point, createSWU(p256.Point, {
|
|
59548
59505
|
A: p256_CURVE.a,
|
|
59549
59506
|
B: p256_CURVE.b,
|
|
59550
|
-
Z:
|
|
59507
|
+
Z: p256.Point.Fp.create(BigInt("-10"))
|
|
59551
59508
|
}), {
|
|
59552
59509
|
DST: "P256_XMD:SHA-256_SSWU_RO_",
|
|
59553
59510
|
encodeDST: "P256_XMD:SHA-256_SSWU_NU_",
|
|
@@ -59558,20 +59515,12 @@ var init_nist = __esm({
|
|
|
59558
59515
|
hash: sha2562
|
|
59559
59516
|
});
|
|
59560
59517
|
})();
|
|
59561
|
-
|
|
59562
|
-
name: "P256-SHA256",
|
|
59563
|
-
Point: p256_Point,
|
|
59564
|
-
hash: sha2562,
|
|
59565
|
-
hashToGroup: p256_hasher.hashToCurve,
|
|
59566
|
-
hashToScalar: p256_hasher.hashToScalar
|
|
59567
|
-
}))();
|
|
59568
|
-
p384_Point = /* @__PURE__ */ weierstrass(p384_CURVE);
|
|
59569
|
-
p384 = /* @__PURE__ */ ecdsa(p384_Point, sha3842);
|
|
59518
|
+
p384 = createCurve({ ...p384_CURVE, Fp: Fp384, lowS: false }, sha3842);
|
|
59570
59519
|
p384_hasher = /* @__PURE__ */ (() => {
|
|
59571
|
-
return createHasher3(
|
|
59520
|
+
return createHasher3(p384.Point, createSWU(p384.Point, {
|
|
59572
59521
|
A: p384_CURVE.a,
|
|
59573
59522
|
B: p384_CURVE.b,
|
|
59574
|
-
Z:
|
|
59523
|
+
Z: p384.Point.Fp.create(BigInt("-12"))
|
|
59575
59524
|
}), {
|
|
59576
59525
|
DST: "P384_XMD:SHA-384_SSWU_RO_",
|
|
59577
59526
|
encodeDST: "P384_XMD:SHA-384_SSWU_NU_",
|
|
@@ -59582,21 +59531,15 @@ var init_nist = __esm({
|
|
|
59582
59531
|
hash: sha3842
|
|
59583
59532
|
});
|
|
59584
59533
|
})();
|
|
59585
|
-
|
|
59586
|
-
|
|
59587
|
-
|
|
59588
|
-
|
|
59589
|
-
hashToGroup: p384_hasher.hashToCurve,
|
|
59590
|
-
hashToScalar: p384_hasher.hashToScalar
|
|
59591
|
-
}))();
|
|
59592
|
-
Fn521 = /* @__PURE__ */ (() => Field(p521_CURVE.n, { allowedLengths: [65, 66] }))();
|
|
59593
|
-
p521_Point = /* @__PURE__ */ weierstrass(p521_CURVE, { Fn: Fn521 });
|
|
59594
|
-
p521 = /* @__PURE__ */ ecdsa(p521_Point, sha5122);
|
|
59534
|
+
p521 = createCurve({ ...p521_CURVE, Fp: Fp521, lowS: false, allowedPrivateKeyLengths: [130, 131, 132] }, sha5122);
|
|
59535
|
+
secp256r1 = p256;
|
|
59536
|
+
secp384r1 = p384;
|
|
59537
|
+
secp521r1 = p521;
|
|
59595
59538
|
p521_hasher = /* @__PURE__ */ (() => {
|
|
59596
|
-
return createHasher3(
|
|
59539
|
+
return createHasher3(p521.Point, createSWU(p521.Point, {
|
|
59597
59540
|
A: p521_CURVE.a,
|
|
59598
59541
|
B: p521_CURVE.b,
|
|
59599
|
-
Z:
|
|
59542
|
+
Z: p521.Point.Fp.create(BigInt("-4"))
|
|
59600
59543
|
}), {
|
|
59601
59544
|
DST: "P521_XMD:SHA-512_SSWU_RO_",
|
|
59602
59545
|
encodeDST: "P521_XMD:SHA-512_SSWU_NU_",
|
|
@@ -59607,14 +59550,6 @@ var init_nist = __esm({
|
|
|
59607
59550
|
hash: sha5122
|
|
59608
59551
|
});
|
|
59609
59552
|
})();
|
|
59610
|
-
p521_oprf = /* @__PURE__ */ (() => createORPF({
|
|
59611
|
-
name: "P521-SHA512",
|
|
59612
|
-
Point: p521_Point,
|
|
59613
|
-
hash: sha5122,
|
|
59614
|
-
hashToGroup: p521_hasher.hashToCurve,
|
|
59615
|
-
hashToScalar: p521_hasher.hashToScalar
|
|
59616
|
-
// produces L=98 just like in RFC
|
|
59617
|
-
}))();
|
|
59618
59553
|
}
|
|
59619
59554
|
});
|
|
59620
59555
|
|
|
@@ -59819,17 +59754,748 @@ var init_resumption = __esm({
|
|
|
59819
59754
|
}
|
|
59820
59755
|
});
|
|
59821
59756
|
|
|
59757
|
+
// ../crypto/node_modules/@noble/hashes/utils.js
|
|
59758
|
+
function isBytes4(a2) {
|
|
59759
|
+
return a2 instanceof Uint8Array || ArrayBuffer.isView(a2) && a2.constructor.name === "Uint8Array";
|
|
59760
|
+
}
|
|
59761
|
+
function anumber4(n2, title = "") {
|
|
59762
|
+
if (!Number.isSafeInteger(n2) || n2 < 0) {
|
|
59763
|
+
const prefix = title && `"${title}" `;
|
|
59764
|
+
throw new Error(`${prefix}expected integer >= 0, got ${n2}`);
|
|
59765
|
+
}
|
|
59766
|
+
}
|
|
59767
|
+
function abytes4(value, length, title = "") {
|
|
59768
|
+
const bytes = isBytes4(value);
|
|
59769
|
+
const len = value?.length;
|
|
59770
|
+
const needsLen = length !== void 0;
|
|
59771
|
+
if (!bytes || needsLen && len !== length) {
|
|
59772
|
+
const prefix = title && `"${title}" `;
|
|
59773
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
59774
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
59775
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
59776
|
+
}
|
|
59777
|
+
return value;
|
|
59778
|
+
}
|
|
59779
|
+
function ahash3(h2) {
|
|
59780
|
+
if (typeof h2 !== "function" || typeof h2.create !== "function")
|
|
59781
|
+
throw new Error("Hash must wrapped by utils.createHasher");
|
|
59782
|
+
anumber4(h2.outputLen);
|
|
59783
|
+
anumber4(h2.blockLen);
|
|
59784
|
+
}
|
|
59785
|
+
function aexists4(instance, checkFinished = true) {
|
|
59786
|
+
if (instance.destroyed)
|
|
59787
|
+
throw new Error("Hash instance has been destroyed");
|
|
59788
|
+
if (checkFinished && instance.finished)
|
|
59789
|
+
throw new Error("Hash#digest() has already been called");
|
|
59790
|
+
}
|
|
59791
|
+
function aoutput4(out, instance) {
|
|
59792
|
+
abytes4(out, void 0, "digestInto() output");
|
|
59793
|
+
const min = instance.outputLen;
|
|
59794
|
+
if (out.length < min) {
|
|
59795
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
59796
|
+
}
|
|
59797
|
+
}
|
|
59798
|
+
function clean4(...arrays) {
|
|
59799
|
+
for (let i2 = 0; i2 < arrays.length; i2++) {
|
|
59800
|
+
arrays[i2].fill(0);
|
|
59801
|
+
}
|
|
59802
|
+
}
|
|
59803
|
+
function createView4(arr) {
|
|
59804
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
59805
|
+
}
|
|
59806
|
+
function rotr3(word, shift) {
|
|
59807
|
+
return word << 32 - shift | word >>> shift;
|
|
59808
|
+
}
|
|
59809
|
+
function createHasher4(hashCons, info = {}) {
|
|
59810
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
59811
|
+
const tmp = hashCons(void 0);
|
|
59812
|
+
hashC.outputLen = tmp.outputLen;
|
|
59813
|
+
hashC.blockLen = tmp.blockLen;
|
|
59814
|
+
hashC.create = (opts) => hashCons(opts);
|
|
59815
|
+
Object.assign(hashC, info);
|
|
59816
|
+
return Object.freeze(hashC);
|
|
59817
|
+
}
|
|
59818
|
+
var oidNist2;
|
|
59819
|
+
var init_utils4 = __esm({
|
|
59820
|
+
"../crypto/node_modules/@noble/hashes/utils.js"() {
|
|
59821
|
+
oidNist2 = (suffix) => ({
|
|
59822
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
59823
|
+
});
|
|
59824
|
+
}
|
|
59825
|
+
});
|
|
59826
|
+
|
|
59827
|
+
// ../crypto/node_modules/@noble/hashes/_md.js
|
|
59828
|
+
function Chi3(a2, b2, c2) {
|
|
59829
|
+
return a2 & b2 ^ ~a2 & c2;
|
|
59830
|
+
}
|
|
59831
|
+
function Maj3(a2, b2, c2) {
|
|
59832
|
+
return a2 & b2 ^ a2 & c2 ^ b2 & c2;
|
|
59833
|
+
}
|
|
59834
|
+
var HashMD3, SHA256_IV3, SHA384_IV3, SHA512_IV3;
|
|
59835
|
+
var init_md3 = __esm({
|
|
59836
|
+
"../crypto/node_modules/@noble/hashes/_md.js"() {
|
|
59837
|
+
init_utils4();
|
|
59838
|
+
HashMD3 = class {
|
|
59839
|
+
blockLen;
|
|
59840
|
+
outputLen;
|
|
59841
|
+
padOffset;
|
|
59842
|
+
isLE;
|
|
59843
|
+
// For partial updates less than block size
|
|
59844
|
+
buffer;
|
|
59845
|
+
view;
|
|
59846
|
+
finished = false;
|
|
59847
|
+
length = 0;
|
|
59848
|
+
pos = 0;
|
|
59849
|
+
destroyed = false;
|
|
59850
|
+
constructor(blockLen, outputLen, padOffset, isLE4) {
|
|
59851
|
+
this.blockLen = blockLen;
|
|
59852
|
+
this.outputLen = outputLen;
|
|
59853
|
+
this.padOffset = padOffset;
|
|
59854
|
+
this.isLE = isLE4;
|
|
59855
|
+
this.buffer = new Uint8Array(blockLen);
|
|
59856
|
+
this.view = createView4(this.buffer);
|
|
59857
|
+
}
|
|
59858
|
+
update(data) {
|
|
59859
|
+
aexists4(this);
|
|
59860
|
+
abytes4(data);
|
|
59861
|
+
const { view, buffer, blockLen } = this;
|
|
59862
|
+
const len = data.length;
|
|
59863
|
+
for (let pos = 0; pos < len; ) {
|
|
59864
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
59865
|
+
if (take === blockLen) {
|
|
59866
|
+
const dataView = createView4(data);
|
|
59867
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
59868
|
+
this.process(dataView, pos);
|
|
59869
|
+
continue;
|
|
59870
|
+
}
|
|
59871
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
59872
|
+
this.pos += take;
|
|
59873
|
+
pos += take;
|
|
59874
|
+
if (this.pos === blockLen) {
|
|
59875
|
+
this.process(view, 0);
|
|
59876
|
+
this.pos = 0;
|
|
59877
|
+
}
|
|
59878
|
+
}
|
|
59879
|
+
this.length += data.length;
|
|
59880
|
+
this.roundClean();
|
|
59881
|
+
return this;
|
|
59882
|
+
}
|
|
59883
|
+
digestInto(out) {
|
|
59884
|
+
aexists4(this);
|
|
59885
|
+
aoutput4(out, this);
|
|
59886
|
+
this.finished = true;
|
|
59887
|
+
const { buffer, view, blockLen, isLE: isLE4 } = this;
|
|
59888
|
+
let { pos } = this;
|
|
59889
|
+
buffer[pos++] = 128;
|
|
59890
|
+
clean4(this.buffer.subarray(pos));
|
|
59891
|
+
if (this.padOffset > blockLen - pos) {
|
|
59892
|
+
this.process(view, 0);
|
|
59893
|
+
pos = 0;
|
|
59894
|
+
}
|
|
59895
|
+
for (let i2 = pos; i2 < blockLen; i2++)
|
|
59896
|
+
buffer[i2] = 0;
|
|
59897
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE4);
|
|
59898
|
+
this.process(view, 0);
|
|
59899
|
+
const oview = createView4(out);
|
|
59900
|
+
const len = this.outputLen;
|
|
59901
|
+
if (len % 4)
|
|
59902
|
+
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
59903
|
+
const outLen = len / 4;
|
|
59904
|
+
const state = this.get();
|
|
59905
|
+
if (outLen > state.length)
|
|
59906
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
59907
|
+
for (let i2 = 0; i2 < outLen; i2++)
|
|
59908
|
+
oview.setUint32(4 * i2, state[i2], isLE4);
|
|
59909
|
+
}
|
|
59910
|
+
digest() {
|
|
59911
|
+
const { buffer, outputLen } = this;
|
|
59912
|
+
this.digestInto(buffer);
|
|
59913
|
+
const res = buffer.slice(0, outputLen);
|
|
59914
|
+
this.destroy();
|
|
59915
|
+
return res;
|
|
59916
|
+
}
|
|
59917
|
+
_cloneInto(to) {
|
|
59918
|
+
to ||= new this.constructor();
|
|
59919
|
+
to.set(...this.get());
|
|
59920
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
59921
|
+
to.destroyed = destroyed;
|
|
59922
|
+
to.finished = finished;
|
|
59923
|
+
to.length = length;
|
|
59924
|
+
to.pos = pos;
|
|
59925
|
+
if (length % blockLen)
|
|
59926
|
+
to.buffer.set(buffer);
|
|
59927
|
+
return to;
|
|
59928
|
+
}
|
|
59929
|
+
clone() {
|
|
59930
|
+
return this._cloneInto();
|
|
59931
|
+
}
|
|
59932
|
+
};
|
|
59933
|
+
SHA256_IV3 = /* @__PURE__ */ Uint32Array.from([
|
|
59934
|
+
1779033703,
|
|
59935
|
+
3144134277,
|
|
59936
|
+
1013904242,
|
|
59937
|
+
2773480762,
|
|
59938
|
+
1359893119,
|
|
59939
|
+
2600822924,
|
|
59940
|
+
528734635,
|
|
59941
|
+
1541459225
|
|
59942
|
+
]);
|
|
59943
|
+
SHA384_IV3 = /* @__PURE__ */ Uint32Array.from([
|
|
59944
|
+
3418070365,
|
|
59945
|
+
3238371032,
|
|
59946
|
+
1654270250,
|
|
59947
|
+
914150663,
|
|
59948
|
+
2438529370,
|
|
59949
|
+
812702999,
|
|
59950
|
+
355462360,
|
|
59951
|
+
4144912697,
|
|
59952
|
+
1731405415,
|
|
59953
|
+
4290775857,
|
|
59954
|
+
2394180231,
|
|
59955
|
+
1750603025,
|
|
59956
|
+
3675008525,
|
|
59957
|
+
1694076839,
|
|
59958
|
+
1203062813,
|
|
59959
|
+
3204075428
|
|
59960
|
+
]);
|
|
59961
|
+
SHA512_IV3 = /* @__PURE__ */ Uint32Array.from([
|
|
59962
|
+
1779033703,
|
|
59963
|
+
4089235720,
|
|
59964
|
+
3144134277,
|
|
59965
|
+
2227873595,
|
|
59966
|
+
1013904242,
|
|
59967
|
+
4271175723,
|
|
59968
|
+
2773480762,
|
|
59969
|
+
1595750129,
|
|
59970
|
+
1359893119,
|
|
59971
|
+
2917565137,
|
|
59972
|
+
2600822924,
|
|
59973
|
+
725511199,
|
|
59974
|
+
528734635,
|
|
59975
|
+
4215389547,
|
|
59976
|
+
1541459225,
|
|
59977
|
+
327033209
|
|
59978
|
+
]);
|
|
59979
|
+
}
|
|
59980
|
+
});
|
|
59981
|
+
|
|
59982
|
+
// ../crypto/node_modules/@noble/hashes/_u64.js
|
|
59983
|
+
function fromBig3(n2, le2 = false) {
|
|
59984
|
+
if (le2)
|
|
59985
|
+
return { h: Number(n2 & U32_MASK643), l: Number(n2 >> _32n3 & U32_MASK643) };
|
|
59986
|
+
return { h: Number(n2 >> _32n3 & U32_MASK643) | 0, l: Number(n2 & U32_MASK643) | 0 };
|
|
59987
|
+
}
|
|
59988
|
+
function split3(lst, le2 = false) {
|
|
59989
|
+
const len = lst.length;
|
|
59990
|
+
let Ah = new Uint32Array(len);
|
|
59991
|
+
let Al = new Uint32Array(len);
|
|
59992
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
59993
|
+
const { h: h2, l: l2 } = fromBig3(lst[i2], le2);
|
|
59994
|
+
[Ah[i2], Al[i2]] = [h2, l2];
|
|
59995
|
+
}
|
|
59996
|
+
return [Ah, Al];
|
|
59997
|
+
}
|
|
59998
|
+
function add3(Ah, Al, Bh, Bl) {
|
|
59999
|
+
const l2 = (Al >>> 0) + (Bl >>> 0);
|
|
60000
|
+
return { h: Ah + Bh + (l2 / 2 ** 32 | 0) | 0, l: l2 | 0 };
|
|
60001
|
+
}
|
|
60002
|
+
var U32_MASK643, _32n3, shrSH3, shrSL3, rotrSH3, rotrSL3, rotrBH3, rotrBL3, add3L3, add3H3, add4L3, add4H3, add5L3, add5H3;
|
|
60003
|
+
var init_u643 = __esm({
|
|
60004
|
+
"../crypto/node_modules/@noble/hashes/_u64.js"() {
|
|
60005
|
+
U32_MASK643 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
60006
|
+
_32n3 = /* @__PURE__ */ BigInt(32);
|
|
60007
|
+
shrSH3 = (h2, _l, s2) => h2 >>> s2;
|
|
60008
|
+
shrSL3 = (h2, l2, s2) => h2 << 32 - s2 | l2 >>> s2;
|
|
60009
|
+
rotrSH3 = (h2, l2, s2) => h2 >>> s2 | l2 << 32 - s2;
|
|
60010
|
+
rotrSL3 = (h2, l2, s2) => h2 << 32 - s2 | l2 >>> s2;
|
|
60011
|
+
rotrBH3 = (h2, l2, s2) => h2 << 64 - s2 | l2 >>> s2 - 32;
|
|
60012
|
+
rotrBL3 = (h2, l2, s2) => h2 >>> s2 - 32 | l2 << 64 - s2;
|
|
60013
|
+
add3L3 = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
60014
|
+
add3H3 = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
60015
|
+
add4L3 = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
60016
|
+
add4H3 = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
60017
|
+
add5L3 = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
60018
|
+
add5H3 = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
60019
|
+
}
|
|
60020
|
+
});
|
|
60021
|
+
|
|
60022
|
+
// ../crypto/node_modules/@noble/hashes/sha2.js
|
|
60023
|
+
var SHA256_K2, SHA256_W2, SHA2_32B, _SHA256, K5122, SHA512_Kh2, SHA512_Kl2, SHA512_W_H2, SHA512_W_L2, SHA2_64B, _SHA512, _SHA384, sha2563, sha5123, sha3843;
|
|
60024
|
+
var init_sha23 = __esm({
|
|
60025
|
+
"../crypto/node_modules/@noble/hashes/sha2.js"() {
|
|
60026
|
+
init_md3();
|
|
60027
|
+
init_u643();
|
|
60028
|
+
init_utils4();
|
|
60029
|
+
SHA256_K2 = /* @__PURE__ */ Uint32Array.from([
|
|
60030
|
+
1116352408,
|
|
60031
|
+
1899447441,
|
|
60032
|
+
3049323471,
|
|
60033
|
+
3921009573,
|
|
60034
|
+
961987163,
|
|
60035
|
+
1508970993,
|
|
60036
|
+
2453635748,
|
|
60037
|
+
2870763221,
|
|
60038
|
+
3624381080,
|
|
60039
|
+
310598401,
|
|
60040
|
+
607225278,
|
|
60041
|
+
1426881987,
|
|
60042
|
+
1925078388,
|
|
60043
|
+
2162078206,
|
|
60044
|
+
2614888103,
|
|
60045
|
+
3248222580,
|
|
60046
|
+
3835390401,
|
|
60047
|
+
4022224774,
|
|
60048
|
+
264347078,
|
|
60049
|
+
604807628,
|
|
60050
|
+
770255983,
|
|
60051
|
+
1249150122,
|
|
60052
|
+
1555081692,
|
|
60053
|
+
1996064986,
|
|
60054
|
+
2554220882,
|
|
60055
|
+
2821834349,
|
|
60056
|
+
2952996808,
|
|
60057
|
+
3210313671,
|
|
60058
|
+
3336571891,
|
|
60059
|
+
3584528711,
|
|
60060
|
+
113926993,
|
|
60061
|
+
338241895,
|
|
60062
|
+
666307205,
|
|
60063
|
+
773529912,
|
|
60064
|
+
1294757372,
|
|
60065
|
+
1396182291,
|
|
60066
|
+
1695183700,
|
|
60067
|
+
1986661051,
|
|
60068
|
+
2177026350,
|
|
60069
|
+
2456956037,
|
|
60070
|
+
2730485921,
|
|
60071
|
+
2820302411,
|
|
60072
|
+
3259730800,
|
|
60073
|
+
3345764771,
|
|
60074
|
+
3516065817,
|
|
60075
|
+
3600352804,
|
|
60076
|
+
4094571909,
|
|
60077
|
+
275423344,
|
|
60078
|
+
430227734,
|
|
60079
|
+
506948616,
|
|
60080
|
+
659060556,
|
|
60081
|
+
883997877,
|
|
60082
|
+
958139571,
|
|
60083
|
+
1322822218,
|
|
60084
|
+
1537002063,
|
|
60085
|
+
1747873779,
|
|
60086
|
+
1955562222,
|
|
60087
|
+
2024104815,
|
|
60088
|
+
2227730452,
|
|
60089
|
+
2361852424,
|
|
60090
|
+
2428436474,
|
|
60091
|
+
2756734187,
|
|
60092
|
+
3204031479,
|
|
60093
|
+
3329325298
|
|
60094
|
+
]);
|
|
60095
|
+
SHA256_W2 = /* @__PURE__ */ new Uint32Array(64);
|
|
60096
|
+
SHA2_32B = class extends HashMD3 {
|
|
60097
|
+
constructor(outputLen) {
|
|
60098
|
+
super(64, outputLen, 8, false);
|
|
60099
|
+
}
|
|
60100
|
+
get() {
|
|
60101
|
+
const { A: A2, B: B2, C: C2, D: D2, E: E2, F: F2, G: G2, H: H2 } = this;
|
|
60102
|
+
return [A2, B2, C2, D2, E2, F2, G2, H2];
|
|
60103
|
+
}
|
|
60104
|
+
// prettier-ignore
|
|
60105
|
+
set(A2, B2, C2, D2, E2, F2, G2, H2) {
|
|
60106
|
+
this.A = A2 | 0;
|
|
60107
|
+
this.B = B2 | 0;
|
|
60108
|
+
this.C = C2 | 0;
|
|
60109
|
+
this.D = D2 | 0;
|
|
60110
|
+
this.E = E2 | 0;
|
|
60111
|
+
this.F = F2 | 0;
|
|
60112
|
+
this.G = G2 | 0;
|
|
60113
|
+
this.H = H2 | 0;
|
|
60114
|
+
}
|
|
60115
|
+
process(view, offset) {
|
|
60116
|
+
for (let i2 = 0; i2 < 16; i2++, offset += 4)
|
|
60117
|
+
SHA256_W2[i2] = view.getUint32(offset, false);
|
|
60118
|
+
for (let i2 = 16; i2 < 64; i2++) {
|
|
60119
|
+
const W15 = SHA256_W2[i2 - 15];
|
|
60120
|
+
const W2 = SHA256_W2[i2 - 2];
|
|
60121
|
+
const s0 = rotr3(W15, 7) ^ rotr3(W15, 18) ^ W15 >>> 3;
|
|
60122
|
+
const s1 = rotr3(W2, 17) ^ rotr3(W2, 19) ^ W2 >>> 10;
|
|
60123
|
+
SHA256_W2[i2] = s1 + SHA256_W2[i2 - 7] + s0 + SHA256_W2[i2 - 16] | 0;
|
|
60124
|
+
}
|
|
60125
|
+
let { A: A2, B: B2, C: C2, D: D2, E: E2, F: F2, G: G2, H: H2 } = this;
|
|
60126
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
60127
|
+
const sigma1 = rotr3(E2, 6) ^ rotr3(E2, 11) ^ rotr3(E2, 25);
|
|
60128
|
+
const T1 = H2 + sigma1 + Chi3(E2, F2, G2) + SHA256_K2[i2] + SHA256_W2[i2] | 0;
|
|
60129
|
+
const sigma0 = rotr3(A2, 2) ^ rotr3(A2, 13) ^ rotr3(A2, 22);
|
|
60130
|
+
const T2 = sigma0 + Maj3(A2, B2, C2) | 0;
|
|
60131
|
+
H2 = G2;
|
|
60132
|
+
G2 = F2;
|
|
60133
|
+
F2 = E2;
|
|
60134
|
+
E2 = D2 + T1 | 0;
|
|
60135
|
+
D2 = C2;
|
|
60136
|
+
C2 = B2;
|
|
60137
|
+
B2 = A2;
|
|
60138
|
+
A2 = T1 + T2 | 0;
|
|
60139
|
+
}
|
|
60140
|
+
A2 = A2 + this.A | 0;
|
|
60141
|
+
B2 = B2 + this.B | 0;
|
|
60142
|
+
C2 = C2 + this.C | 0;
|
|
60143
|
+
D2 = D2 + this.D | 0;
|
|
60144
|
+
E2 = E2 + this.E | 0;
|
|
60145
|
+
F2 = F2 + this.F | 0;
|
|
60146
|
+
G2 = G2 + this.G | 0;
|
|
60147
|
+
H2 = H2 + this.H | 0;
|
|
60148
|
+
this.set(A2, B2, C2, D2, E2, F2, G2, H2);
|
|
60149
|
+
}
|
|
60150
|
+
roundClean() {
|
|
60151
|
+
clean4(SHA256_W2);
|
|
60152
|
+
}
|
|
60153
|
+
destroy() {
|
|
60154
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
60155
|
+
clean4(this.buffer);
|
|
60156
|
+
}
|
|
60157
|
+
};
|
|
60158
|
+
_SHA256 = class extends SHA2_32B {
|
|
60159
|
+
// We cannot use array here since array allows indexing by variable
|
|
60160
|
+
// which means optimizer/compiler cannot use registers.
|
|
60161
|
+
A = SHA256_IV3[0] | 0;
|
|
60162
|
+
B = SHA256_IV3[1] | 0;
|
|
60163
|
+
C = SHA256_IV3[2] | 0;
|
|
60164
|
+
D = SHA256_IV3[3] | 0;
|
|
60165
|
+
E = SHA256_IV3[4] | 0;
|
|
60166
|
+
F = SHA256_IV3[5] | 0;
|
|
60167
|
+
G = SHA256_IV3[6] | 0;
|
|
60168
|
+
H = SHA256_IV3[7] | 0;
|
|
60169
|
+
constructor() {
|
|
60170
|
+
super(32);
|
|
60171
|
+
}
|
|
60172
|
+
};
|
|
60173
|
+
K5122 = /* @__PURE__ */ (() => split3([
|
|
60174
|
+
"0x428a2f98d728ae22",
|
|
60175
|
+
"0x7137449123ef65cd",
|
|
60176
|
+
"0xb5c0fbcfec4d3b2f",
|
|
60177
|
+
"0xe9b5dba58189dbbc",
|
|
60178
|
+
"0x3956c25bf348b538",
|
|
60179
|
+
"0x59f111f1b605d019",
|
|
60180
|
+
"0x923f82a4af194f9b",
|
|
60181
|
+
"0xab1c5ed5da6d8118",
|
|
60182
|
+
"0xd807aa98a3030242",
|
|
60183
|
+
"0x12835b0145706fbe",
|
|
60184
|
+
"0x243185be4ee4b28c",
|
|
60185
|
+
"0x550c7dc3d5ffb4e2",
|
|
60186
|
+
"0x72be5d74f27b896f",
|
|
60187
|
+
"0x80deb1fe3b1696b1",
|
|
60188
|
+
"0x9bdc06a725c71235",
|
|
60189
|
+
"0xc19bf174cf692694",
|
|
60190
|
+
"0xe49b69c19ef14ad2",
|
|
60191
|
+
"0xefbe4786384f25e3",
|
|
60192
|
+
"0x0fc19dc68b8cd5b5",
|
|
60193
|
+
"0x240ca1cc77ac9c65",
|
|
60194
|
+
"0x2de92c6f592b0275",
|
|
60195
|
+
"0x4a7484aa6ea6e483",
|
|
60196
|
+
"0x5cb0a9dcbd41fbd4",
|
|
60197
|
+
"0x76f988da831153b5",
|
|
60198
|
+
"0x983e5152ee66dfab",
|
|
60199
|
+
"0xa831c66d2db43210",
|
|
60200
|
+
"0xb00327c898fb213f",
|
|
60201
|
+
"0xbf597fc7beef0ee4",
|
|
60202
|
+
"0xc6e00bf33da88fc2",
|
|
60203
|
+
"0xd5a79147930aa725",
|
|
60204
|
+
"0x06ca6351e003826f",
|
|
60205
|
+
"0x142929670a0e6e70",
|
|
60206
|
+
"0x27b70a8546d22ffc",
|
|
60207
|
+
"0x2e1b21385c26c926",
|
|
60208
|
+
"0x4d2c6dfc5ac42aed",
|
|
60209
|
+
"0x53380d139d95b3df",
|
|
60210
|
+
"0x650a73548baf63de",
|
|
60211
|
+
"0x766a0abb3c77b2a8",
|
|
60212
|
+
"0x81c2c92e47edaee6",
|
|
60213
|
+
"0x92722c851482353b",
|
|
60214
|
+
"0xa2bfe8a14cf10364",
|
|
60215
|
+
"0xa81a664bbc423001",
|
|
60216
|
+
"0xc24b8b70d0f89791",
|
|
60217
|
+
"0xc76c51a30654be30",
|
|
60218
|
+
"0xd192e819d6ef5218",
|
|
60219
|
+
"0xd69906245565a910",
|
|
60220
|
+
"0xf40e35855771202a",
|
|
60221
|
+
"0x106aa07032bbd1b8",
|
|
60222
|
+
"0x19a4c116b8d2d0c8",
|
|
60223
|
+
"0x1e376c085141ab53",
|
|
60224
|
+
"0x2748774cdf8eeb99",
|
|
60225
|
+
"0x34b0bcb5e19b48a8",
|
|
60226
|
+
"0x391c0cb3c5c95a63",
|
|
60227
|
+
"0x4ed8aa4ae3418acb",
|
|
60228
|
+
"0x5b9cca4f7763e373",
|
|
60229
|
+
"0x682e6ff3d6b2b8a3",
|
|
60230
|
+
"0x748f82ee5defb2fc",
|
|
60231
|
+
"0x78a5636f43172f60",
|
|
60232
|
+
"0x84c87814a1f0ab72",
|
|
60233
|
+
"0x8cc702081a6439ec",
|
|
60234
|
+
"0x90befffa23631e28",
|
|
60235
|
+
"0xa4506cebde82bde9",
|
|
60236
|
+
"0xbef9a3f7b2c67915",
|
|
60237
|
+
"0xc67178f2e372532b",
|
|
60238
|
+
"0xca273eceea26619c",
|
|
60239
|
+
"0xd186b8c721c0c207",
|
|
60240
|
+
"0xeada7dd6cde0eb1e",
|
|
60241
|
+
"0xf57d4f7fee6ed178",
|
|
60242
|
+
"0x06f067aa72176fba",
|
|
60243
|
+
"0x0a637dc5a2c898a6",
|
|
60244
|
+
"0x113f9804bef90dae",
|
|
60245
|
+
"0x1b710b35131c471b",
|
|
60246
|
+
"0x28db77f523047d84",
|
|
60247
|
+
"0x32caab7b40c72493",
|
|
60248
|
+
"0x3c9ebe0a15c9bebc",
|
|
60249
|
+
"0x431d67c49c100d4c",
|
|
60250
|
+
"0x4cc5d4becb3e42b6",
|
|
60251
|
+
"0x597f299cfc657e2a",
|
|
60252
|
+
"0x5fcb6fab3ad6faec",
|
|
60253
|
+
"0x6c44198c4a475817"
|
|
60254
|
+
].map((n2) => BigInt(n2))))();
|
|
60255
|
+
SHA512_Kh2 = /* @__PURE__ */ (() => K5122[0])();
|
|
60256
|
+
SHA512_Kl2 = /* @__PURE__ */ (() => K5122[1])();
|
|
60257
|
+
SHA512_W_H2 = /* @__PURE__ */ new Uint32Array(80);
|
|
60258
|
+
SHA512_W_L2 = /* @__PURE__ */ new Uint32Array(80);
|
|
60259
|
+
SHA2_64B = class extends HashMD3 {
|
|
60260
|
+
constructor(outputLen) {
|
|
60261
|
+
super(128, outputLen, 16, false);
|
|
60262
|
+
}
|
|
60263
|
+
// prettier-ignore
|
|
60264
|
+
get() {
|
|
60265
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
60266
|
+
return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
|
|
60267
|
+
}
|
|
60268
|
+
// prettier-ignore
|
|
60269
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
60270
|
+
this.Ah = Ah | 0;
|
|
60271
|
+
this.Al = Al | 0;
|
|
60272
|
+
this.Bh = Bh | 0;
|
|
60273
|
+
this.Bl = Bl | 0;
|
|
60274
|
+
this.Ch = Ch | 0;
|
|
60275
|
+
this.Cl = Cl | 0;
|
|
60276
|
+
this.Dh = Dh | 0;
|
|
60277
|
+
this.Dl = Dl | 0;
|
|
60278
|
+
this.Eh = Eh | 0;
|
|
60279
|
+
this.El = El | 0;
|
|
60280
|
+
this.Fh = Fh | 0;
|
|
60281
|
+
this.Fl = Fl | 0;
|
|
60282
|
+
this.Gh = Gh | 0;
|
|
60283
|
+
this.Gl = Gl | 0;
|
|
60284
|
+
this.Hh = Hh | 0;
|
|
60285
|
+
this.Hl = Hl | 0;
|
|
60286
|
+
}
|
|
60287
|
+
process(view, offset) {
|
|
60288
|
+
for (let i2 = 0; i2 < 16; i2++, offset += 4) {
|
|
60289
|
+
SHA512_W_H2[i2] = view.getUint32(offset);
|
|
60290
|
+
SHA512_W_L2[i2] = view.getUint32(offset += 4);
|
|
60291
|
+
}
|
|
60292
|
+
for (let i2 = 16; i2 < 80; i2++) {
|
|
60293
|
+
const W15h = SHA512_W_H2[i2 - 15] | 0;
|
|
60294
|
+
const W15l = SHA512_W_L2[i2 - 15] | 0;
|
|
60295
|
+
const s0h = rotrSH3(W15h, W15l, 1) ^ rotrSH3(W15h, W15l, 8) ^ shrSH3(W15h, W15l, 7);
|
|
60296
|
+
const s0l = rotrSL3(W15h, W15l, 1) ^ rotrSL3(W15h, W15l, 8) ^ shrSL3(W15h, W15l, 7);
|
|
60297
|
+
const W2h = SHA512_W_H2[i2 - 2] | 0;
|
|
60298
|
+
const W2l = SHA512_W_L2[i2 - 2] | 0;
|
|
60299
|
+
const s1h = rotrSH3(W2h, W2l, 19) ^ rotrBH3(W2h, W2l, 61) ^ shrSH3(W2h, W2l, 6);
|
|
60300
|
+
const s1l = rotrSL3(W2h, W2l, 19) ^ rotrBL3(W2h, W2l, 61) ^ shrSL3(W2h, W2l, 6);
|
|
60301
|
+
const SUMl = add4L3(s0l, s1l, SHA512_W_L2[i2 - 7], SHA512_W_L2[i2 - 16]);
|
|
60302
|
+
const SUMh = add4H3(SUMl, s0h, s1h, SHA512_W_H2[i2 - 7], SHA512_W_H2[i2 - 16]);
|
|
60303
|
+
SHA512_W_H2[i2] = SUMh | 0;
|
|
60304
|
+
SHA512_W_L2[i2] = SUMl | 0;
|
|
60305
|
+
}
|
|
60306
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
60307
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
60308
|
+
const sigma1h = rotrSH3(Eh, El, 14) ^ rotrSH3(Eh, El, 18) ^ rotrBH3(Eh, El, 41);
|
|
60309
|
+
const sigma1l = rotrSL3(Eh, El, 14) ^ rotrSL3(Eh, El, 18) ^ rotrBL3(Eh, El, 41);
|
|
60310
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
60311
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
60312
|
+
const T1ll = add5L3(Hl, sigma1l, CHIl, SHA512_Kl2[i2], SHA512_W_L2[i2]);
|
|
60313
|
+
const T1h = add5H3(T1ll, Hh, sigma1h, CHIh, SHA512_Kh2[i2], SHA512_W_H2[i2]);
|
|
60314
|
+
const T1l = T1ll | 0;
|
|
60315
|
+
const sigma0h = rotrSH3(Ah, Al, 28) ^ rotrBH3(Ah, Al, 34) ^ rotrBH3(Ah, Al, 39);
|
|
60316
|
+
const sigma0l = rotrSL3(Ah, Al, 28) ^ rotrBL3(Ah, Al, 34) ^ rotrBL3(Ah, Al, 39);
|
|
60317
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
60318
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
60319
|
+
Hh = Gh | 0;
|
|
60320
|
+
Hl = Gl | 0;
|
|
60321
|
+
Gh = Fh | 0;
|
|
60322
|
+
Gl = Fl | 0;
|
|
60323
|
+
Fh = Eh | 0;
|
|
60324
|
+
Fl = El | 0;
|
|
60325
|
+
({ h: Eh, l: El } = add3(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
60326
|
+
Dh = Ch | 0;
|
|
60327
|
+
Dl = Cl | 0;
|
|
60328
|
+
Ch = Bh | 0;
|
|
60329
|
+
Cl = Bl | 0;
|
|
60330
|
+
Bh = Ah | 0;
|
|
60331
|
+
Bl = Al | 0;
|
|
60332
|
+
const All = add3L3(T1l, sigma0l, MAJl);
|
|
60333
|
+
Ah = add3H3(All, T1h, sigma0h, MAJh);
|
|
60334
|
+
Al = All | 0;
|
|
60335
|
+
}
|
|
60336
|
+
({ h: Ah, l: Al } = add3(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
60337
|
+
({ h: Bh, l: Bl } = add3(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
60338
|
+
({ h: Ch, l: Cl } = add3(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
60339
|
+
({ h: Dh, l: Dl } = add3(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
60340
|
+
({ h: Eh, l: El } = add3(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
60341
|
+
({ h: Fh, l: Fl } = add3(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
60342
|
+
({ h: Gh, l: Gl } = add3(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
60343
|
+
({ h: Hh, l: Hl } = add3(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
60344
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
60345
|
+
}
|
|
60346
|
+
roundClean() {
|
|
60347
|
+
clean4(SHA512_W_H2, SHA512_W_L2);
|
|
60348
|
+
}
|
|
60349
|
+
destroy() {
|
|
60350
|
+
clean4(this.buffer);
|
|
60351
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
60352
|
+
}
|
|
60353
|
+
};
|
|
60354
|
+
_SHA512 = class extends SHA2_64B {
|
|
60355
|
+
Ah = SHA512_IV3[0] | 0;
|
|
60356
|
+
Al = SHA512_IV3[1] | 0;
|
|
60357
|
+
Bh = SHA512_IV3[2] | 0;
|
|
60358
|
+
Bl = SHA512_IV3[3] | 0;
|
|
60359
|
+
Ch = SHA512_IV3[4] | 0;
|
|
60360
|
+
Cl = SHA512_IV3[5] | 0;
|
|
60361
|
+
Dh = SHA512_IV3[6] | 0;
|
|
60362
|
+
Dl = SHA512_IV3[7] | 0;
|
|
60363
|
+
Eh = SHA512_IV3[8] | 0;
|
|
60364
|
+
El = SHA512_IV3[9] | 0;
|
|
60365
|
+
Fh = SHA512_IV3[10] | 0;
|
|
60366
|
+
Fl = SHA512_IV3[11] | 0;
|
|
60367
|
+
Gh = SHA512_IV3[12] | 0;
|
|
60368
|
+
Gl = SHA512_IV3[13] | 0;
|
|
60369
|
+
Hh = SHA512_IV3[14] | 0;
|
|
60370
|
+
Hl = SHA512_IV3[15] | 0;
|
|
60371
|
+
constructor() {
|
|
60372
|
+
super(64);
|
|
60373
|
+
}
|
|
60374
|
+
};
|
|
60375
|
+
_SHA384 = class extends SHA2_64B {
|
|
60376
|
+
Ah = SHA384_IV3[0] | 0;
|
|
60377
|
+
Al = SHA384_IV3[1] | 0;
|
|
60378
|
+
Bh = SHA384_IV3[2] | 0;
|
|
60379
|
+
Bl = SHA384_IV3[3] | 0;
|
|
60380
|
+
Ch = SHA384_IV3[4] | 0;
|
|
60381
|
+
Cl = SHA384_IV3[5] | 0;
|
|
60382
|
+
Dh = SHA384_IV3[6] | 0;
|
|
60383
|
+
Dl = SHA384_IV3[7] | 0;
|
|
60384
|
+
Eh = SHA384_IV3[8] | 0;
|
|
60385
|
+
El = SHA384_IV3[9] | 0;
|
|
60386
|
+
Fh = SHA384_IV3[10] | 0;
|
|
60387
|
+
Fl = SHA384_IV3[11] | 0;
|
|
60388
|
+
Gh = SHA384_IV3[12] | 0;
|
|
60389
|
+
Gl = SHA384_IV3[13] | 0;
|
|
60390
|
+
Hh = SHA384_IV3[14] | 0;
|
|
60391
|
+
Hl = SHA384_IV3[15] | 0;
|
|
60392
|
+
constructor() {
|
|
60393
|
+
super(48);
|
|
60394
|
+
}
|
|
60395
|
+
};
|
|
60396
|
+
sha2563 = /* @__PURE__ */ createHasher4(
|
|
60397
|
+
() => new _SHA256(),
|
|
60398
|
+
/* @__PURE__ */ oidNist2(1)
|
|
60399
|
+
);
|
|
60400
|
+
sha5123 = /* @__PURE__ */ createHasher4(
|
|
60401
|
+
() => new _SHA512(),
|
|
60402
|
+
/* @__PURE__ */ oidNist2(3)
|
|
60403
|
+
);
|
|
60404
|
+
sha3843 = /* @__PURE__ */ createHasher4(
|
|
60405
|
+
() => new _SHA384(),
|
|
60406
|
+
/* @__PURE__ */ oidNist2(2)
|
|
60407
|
+
);
|
|
60408
|
+
}
|
|
60409
|
+
});
|
|
60410
|
+
|
|
60411
|
+
// ../crypto/node_modules/@noble/hashes/hmac.js
|
|
60412
|
+
var _HMAC2, hmac3;
|
|
60413
|
+
var init_hmac3 = __esm({
|
|
60414
|
+
"../crypto/node_modules/@noble/hashes/hmac.js"() {
|
|
60415
|
+
init_utils4();
|
|
60416
|
+
_HMAC2 = class {
|
|
60417
|
+
oHash;
|
|
60418
|
+
iHash;
|
|
60419
|
+
blockLen;
|
|
60420
|
+
outputLen;
|
|
60421
|
+
finished = false;
|
|
60422
|
+
destroyed = false;
|
|
60423
|
+
constructor(hash2, key) {
|
|
60424
|
+
ahash3(hash2);
|
|
60425
|
+
abytes4(key, void 0, "key");
|
|
60426
|
+
this.iHash = hash2.create();
|
|
60427
|
+
if (typeof this.iHash.update !== "function")
|
|
60428
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
60429
|
+
this.blockLen = this.iHash.blockLen;
|
|
60430
|
+
this.outputLen = this.iHash.outputLen;
|
|
60431
|
+
const blockLen = this.blockLen;
|
|
60432
|
+
const pad = new Uint8Array(blockLen);
|
|
60433
|
+
pad.set(key.length > blockLen ? hash2.create().update(key).digest() : key);
|
|
60434
|
+
for (let i2 = 0; i2 < pad.length; i2++)
|
|
60435
|
+
pad[i2] ^= 54;
|
|
60436
|
+
this.iHash.update(pad);
|
|
60437
|
+
this.oHash = hash2.create();
|
|
60438
|
+
for (let i2 = 0; i2 < pad.length; i2++)
|
|
60439
|
+
pad[i2] ^= 54 ^ 92;
|
|
60440
|
+
this.oHash.update(pad);
|
|
60441
|
+
clean4(pad);
|
|
60442
|
+
}
|
|
60443
|
+
update(buf) {
|
|
60444
|
+
aexists4(this);
|
|
60445
|
+
this.iHash.update(buf);
|
|
60446
|
+
return this;
|
|
60447
|
+
}
|
|
60448
|
+
digestInto(out) {
|
|
60449
|
+
aexists4(this);
|
|
60450
|
+
abytes4(out, this.outputLen, "output");
|
|
60451
|
+
this.finished = true;
|
|
60452
|
+
this.iHash.digestInto(out);
|
|
60453
|
+
this.oHash.update(out);
|
|
60454
|
+
this.oHash.digestInto(out);
|
|
60455
|
+
this.destroy();
|
|
60456
|
+
}
|
|
60457
|
+
digest() {
|
|
60458
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
60459
|
+
this.digestInto(out);
|
|
60460
|
+
return out;
|
|
60461
|
+
}
|
|
60462
|
+
_cloneInto(to) {
|
|
60463
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
60464
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
60465
|
+
to = to;
|
|
60466
|
+
to.finished = finished;
|
|
60467
|
+
to.destroyed = destroyed;
|
|
60468
|
+
to.blockLen = blockLen;
|
|
60469
|
+
to.outputLen = outputLen;
|
|
60470
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
60471
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
60472
|
+
return to;
|
|
60473
|
+
}
|
|
60474
|
+
clone() {
|
|
60475
|
+
return this._cloneInto();
|
|
60476
|
+
}
|
|
60477
|
+
destroy() {
|
|
60478
|
+
this.destroyed = true;
|
|
60479
|
+
this.oHash.destroy();
|
|
60480
|
+
this.iHash.destroy();
|
|
60481
|
+
}
|
|
60482
|
+
};
|
|
60483
|
+
hmac3 = (hash2, key, message) => new _HMAC2(hash2, key).update(message).digest();
|
|
60484
|
+
hmac3.create = (hash2, key) => new _HMAC2(hash2, key);
|
|
60485
|
+
}
|
|
60486
|
+
});
|
|
60487
|
+
|
|
59822
60488
|
// ../crypto/node_modules/ts-mls/dist/src/crypto/implementation/noble/makeHashImpl.js
|
|
59823
60489
|
function makeHashImpl2(h2) {
|
|
59824
60490
|
return {
|
|
59825
60491
|
async digest(data) {
|
|
59826
60492
|
switch (h2) {
|
|
59827
60493
|
case "SHA-256":
|
|
59828
|
-
return
|
|
60494
|
+
return sha2563(data);
|
|
59829
60495
|
case "SHA-384":
|
|
59830
|
-
return
|
|
60496
|
+
return sha3843(data);
|
|
59831
60497
|
case "SHA-512":
|
|
59832
|
-
return
|
|
60498
|
+
return sha5123(data);
|
|
59833
60499
|
default:
|
|
59834
60500
|
throw new Error(`Unsupported hash algorithm: ${h2}`);
|
|
59835
60501
|
}
|
|
@@ -59837,11 +60503,11 @@ function makeHashImpl2(h2) {
|
|
|
59837
60503
|
async mac(key, data) {
|
|
59838
60504
|
switch (h2) {
|
|
59839
60505
|
case "SHA-256":
|
|
59840
|
-
return
|
|
60506
|
+
return hmac3(sha2563, key, data);
|
|
59841
60507
|
case "SHA-384":
|
|
59842
|
-
return
|
|
60508
|
+
return hmac3(sha3843, key, data);
|
|
59843
60509
|
case "SHA-512":
|
|
59844
|
-
return
|
|
60510
|
+
return hmac3(sha5123, key, data);
|
|
59845
60511
|
default:
|
|
59846
60512
|
throw new Error(`Unsupported hash algorithm: ${h2}`);
|
|
59847
60513
|
}
|
|
@@ -59854,8 +60520,8 @@ function makeHashImpl2(h2) {
|
|
|
59854
60520
|
}
|
|
59855
60521
|
var init_makeHashImpl2 = __esm({
|
|
59856
60522
|
"../crypto/node_modules/ts-mls/dist/src/crypto/implementation/noble/makeHashImpl.js"() {
|
|
59857
|
-
|
|
59858
|
-
|
|
60523
|
+
init_sha23();
|
|
60524
|
+
init_hmac3();
|
|
59859
60525
|
init_constantTimeCompare();
|
|
59860
60526
|
}
|
|
59861
60527
|
});
|
|
@@ -61932,6 +62598,8 @@ var init_channel = __esm({
|
|
|
61932
62598
|
_trustTokenInterval = null;
|
|
61933
62599
|
_pendingPollTimer = null;
|
|
61934
62600
|
_syncMessageIds = null;
|
|
62601
|
+
_deliveryHeartbeat = null;
|
|
62602
|
+
_deliveryPulling = false;
|
|
61935
62603
|
/** MLS group managers per room/conversation (roomId or conv:conversationId -> MLSGroupManager) */
|
|
61936
62604
|
_mlsGroups = /* @__PURE__ */ new Map();
|
|
61937
62605
|
/** Cached MLS KeyPackage bundle for this device (regenerated on each connect). */
|
|
@@ -63705,6 +64373,14 @@ var init_channel = __esm({
|
|
|
63705
64373
|
} catch (kpErr) {
|
|
63706
64374
|
console.warn("[SecureChannel] Failed to publish MLS KeyPackage:", kpErr);
|
|
63707
64375
|
}
|
|
64376
|
+
this._pullDeliveryQueue().catch((err) => {
|
|
64377
|
+
console.warn("[SecureChannel] Initial delivery pull failed:", err);
|
|
64378
|
+
});
|
|
64379
|
+
if (this._deliveryHeartbeat) clearInterval(this._deliveryHeartbeat);
|
|
64380
|
+
this._deliveryHeartbeat = setInterval(() => {
|
|
64381
|
+
this._pullDeliveryQueue().catch(() => {
|
|
64382
|
+
});
|
|
64383
|
+
}, 3e4);
|
|
63708
64384
|
for (const [convId, entry] of Object.entries(this._persisted?.mlsConversations ?? {})) {
|
|
63709
64385
|
if (entry.mlsGroupId) {
|
|
63710
64386
|
const mlsGroup = this._mlsGroups.get(`conv:${convId}`);
|
|
@@ -63869,6 +64545,11 @@ var init_channel = __esm({
|
|
|
63869
64545
|
console.error("[SecureChannel] MLS welcome handler failed:", mlsWelcomeErr);
|
|
63870
64546
|
}
|
|
63871
64547
|
}
|
|
64548
|
+
if (data.event === "mls_delivery") {
|
|
64549
|
+
this._pullDeliveryQueue().catch((err) => {
|
|
64550
|
+
console.warn("[SecureChannel] Delivery pull on ping failed:", err);
|
|
64551
|
+
});
|
|
64552
|
+
}
|
|
63872
64553
|
if (data.event === "mls_sync_response") {
|
|
63873
64554
|
try {
|
|
63874
64555
|
await this._handleMlsSyncResponse(data.data || data);
|
|
@@ -64115,6 +64796,10 @@ var init_channel = __esm({
|
|
|
64115
64796
|
this._stopPing();
|
|
64116
64797
|
this._stopWakeDetector();
|
|
64117
64798
|
this._stopPendingPoll();
|
|
64799
|
+
if (this._deliveryHeartbeat) {
|
|
64800
|
+
clearInterval(this._deliveryHeartbeat);
|
|
64801
|
+
this._deliveryHeartbeat = null;
|
|
64802
|
+
}
|
|
64118
64803
|
if (this._stopped) return;
|
|
64119
64804
|
this._setState("disconnected");
|
|
64120
64805
|
this._scheduleReconnect();
|
|
@@ -65312,6 +65997,113 @@ ${messageText}`;
|
|
|
65312
65997
|
console.error(`[SecureChannel] MLS welcome processing failed:`, err);
|
|
65313
65998
|
}
|
|
65314
65999
|
}
|
|
66000
|
+
/**
|
|
66001
|
+
* Pull pending MLS messages from the delivery queue and process them.
|
|
66002
|
+
* Called on WS connect, on mls_delivery ping, and every 30s heartbeat.
|
|
66003
|
+
*/
|
|
66004
|
+
async _pullDeliveryQueue() {
|
|
66005
|
+
if (!this._deviceId || !this._deviceJwt || this._deliveryPulling) return;
|
|
66006
|
+
this._deliveryPulling = true;
|
|
66007
|
+
try {
|
|
66008
|
+
const res = await fetch(
|
|
66009
|
+
`${this.config.apiUrl}/api/v1/mls/delivery?device_id=${this._deviceId}`,
|
|
66010
|
+
{ headers: { Authorization: `Bearer ${this._deviceJwt}` } }
|
|
66011
|
+
);
|
|
66012
|
+
if (!res.ok) {
|
|
66013
|
+
console.warn(`[SecureChannel] Delivery pull failed: ${res.status}`);
|
|
66014
|
+
return;
|
|
66015
|
+
}
|
|
66016
|
+
const { messages } = await res.json();
|
|
66017
|
+
if (!messages || messages.length === 0) return;
|
|
66018
|
+
const order = { welcome: 0, commit: 1, application: 2 };
|
|
66019
|
+
messages.sort((a2, b2) => {
|
|
66020
|
+
const ao = order[a2.message_type] ?? 2;
|
|
66021
|
+
const bo = order[b2.message_type] ?? 2;
|
|
66022
|
+
if (ao !== bo) return ao - bo;
|
|
66023
|
+
return new Date(a2.created_at).getTime() - new Date(b2.created_at).getTime();
|
|
66024
|
+
});
|
|
66025
|
+
const ackedIds = [];
|
|
66026
|
+
for (const msg of messages) {
|
|
66027
|
+
try {
|
|
66028
|
+
if (msg.sender_device_id === this._deviceId) {
|
|
66029
|
+
ackedIds.push(msg.queue_id);
|
|
66030
|
+
continue;
|
|
66031
|
+
}
|
|
66032
|
+
if (msg.message_type === "welcome") {
|
|
66033
|
+
await this._handleMlsWelcome({
|
|
66034
|
+
group_id: msg.group_id,
|
|
66035
|
+
sender_device_id: msg.sender_device_id,
|
|
66036
|
+
payload: msg.payload,
|
|
66037
|
+
room_id: msg.room_id,
|
|
66038
|
+
conversation_id: msg.conversation_id,
|
|
66039
|
+
a2a_channel_id: msg.a2a_channel_id
|
|
66040
|
+
});
|
|
66041
|
+
} else if (msg.message_type === "commit") {
|
|
66042
|
+
await this._handleMlsCommit({
|
|
66043
|
+
group_id: msg.group_id,
|
|
66044
|
+
sender_device_id: msg.sender_device_id,
|
|
66045
|
+
epoch: msg.epoch,
|
|
66046
|
+
payload: msg.payload
|
|
66047
|
+
});
|
|
66048
|
+
} else if (msg.message_type === "application") {
|
|
66049
|
+
if (msg.room_id) {
|
|
66050
|
+
await this._handleRoomMessageMLS({
|
|
66051
|
+
message_id: msg.message_id,
|
|
66052
|
+
group_id: msg.group_id,
|
|
66053
|
+
sender_device_id: msg.sender_device_id,
|
|
66054
|
+
epoch: msg.epoch,
|
|
66055
|
+
payload: msg.payload,
|
|
66056
|
+
room_id: msg.room_id,
|
|
66057
|
+
created_at: msg.created_at
|
|
66058
|
+
});
|
|
66059
|
+
} else if (msg.a2a_channel_id) {
|
|
66060
|
+
await this._handleA2AMessageMLS({
|
|
66061
|
+
message_id: msg.message_id,
|
|
66062
|
+
group_id: msg.group_id,
|
|
66063
|
+
sender_device_id: msg.sender_device_id,
|
|
66064
|
+
epoch: msg.epoch,
|
|
66065
|
+
payload: msg.payload,
|
|
66066
|
+
a2a_channel_id: msg.a2a_channel_id,
|
|
66067
|
+
created_at: msg.created_at
|
|
66068
|
+
});
|
|
66069
|
+
} else if (msg.conversation_id) {
|
|
66070
|
+
await this._handleMessageMLS({
|
|
66071
|
+
message_id: msg.message_id,
|
|
66072
|
+
group_id: msg.group_id,
|
|
66073
|
+
sender_device_id: msg.sender_device_id,
|
|
66074
|
+
epoch: msg.epoch,
|
|
66075
|
+
payload: msg.payload,
|
|
66076
|
+
conversation_id: msg.conversation_id,
|
|
66077
|
+
created_at: msg.created_at
|
|
66078
|
+
});
|
|
66079
|
+
}
|
|
66080
|
+
}
|
|
66081
|
+
ackedIds.push(msg.queue_id);
|
|
66082
|
+
} catch (err) {
|
|
66083
|
+
console.warn(`[SecureChannel] Delivery ${msg.message_type} processing failed:`, err);
|
|
66084
|
+
}
|
|
66085
|
+
}
|
|
66086
|
+
if (ackedIds.length > 0) {
|
|
66087
|
+
try {
|
|
66088
|
+
await fetch(`${this.config.apiUrl}/api/v1/mls/delivery/ack`, {
|
|
66089
|
+
method: "POST",
|
|
66090
|
+
headers: {
|
|
66091
|
+
Authorization: `Bearer ${this._deviceJwt}`,
|
|
66092
|
+
"Content-Type": "application/json"
|
|
66093
|
+
},
|
|
66094
|
+
body: JSON.stringify({ queue_ids: ackedIds, device_id: this._deviceId })
|
|
66095
|
+
});
|
|
66096
|
+
console.log(`[SecureChannel] Delivery acked ${ackedIds.length}/${messages.length}`);
|
|
66097
|
+
} catch (ackErr) {
|
|
66098
|
+
console.warn("[SecureChannel] Delivery ack failed:", ackErr);
|
|
66099
|
+
}
|
|
66100
|
+
}
|
|
66101
|
+
} catch (err) {
|
|
66102
|
+
console.warn("[SecureChannel] Delivery pull error:", err);
|
|
66103
|
+
} finally {
|
|
66104
|
+
this._deliveryPulling = false;
|
|
66105
|
+
}
|
|
66106
|
+
}
|
|
65315
66107
|
async _handleMlsSyncResponse(data) {
|
|
65316
66108
|
const action = data.action;
|
|
65317
66109
|
const groupId = data.group_id;
|
|
@@ -90468,7 +91260,7 @@ var init_mcp = __esm({
|
|
|
90468
91260
|
import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
|
|
90469
91261
|
import { Http2ServerRequest } from "http2";
|
|
90470
91262
|
import { Readable as Readable2 } from "stream";
|
|
90471
|
-
import
|
|
91263
|
+
import crypto3 from "crypto";
|
|
90472
91264
|
async function readWithoutBlocking(readPromise) {
|
|
90473
91265
|
return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
|
|
90474
91266
|
}
|
|
@@ -90786,7 +91578,7 @@ var init_dist2 = __esm({
|
|
|
90786
91578
|
};
|
|
90787
91579
|
X_ALREADY_SENT = "x-hono-already-sent";
|
|
90788
91580
|
if (typeof global.crypto === "undefined") {
|
|
90789
|
-
global.crypto =
|
|
91581
|
+
global.crypto = crypto3;
|
|
90790
91582
|
}
|
|
90791
91583
|
outgoingEnded = /* @__PURE__ */ Symbol("outgoingEnded");
|
|
90792
91584
|
handleRequestError = () => new Response(null, {
|
|
@@ -92521,21 +93313,22 @@ export {
|
|
|
92521
93313
|
|
|
92522
93314
|
@hpke/common/esm/src/curve/modular.js:
|
|
92523
93315
|
@hpke/common/esm/src/curve/montgomery.js:
|
|
92524
|
-
@noble/curves/utils.js:
|
|
92525
|
-
@noble/curves/abstract/modular.js:
|
|
92526
|
-
@noble/curves/abstract/curve.js:
|
|
92527
|
-
@noble/curves/abstract/edwards.js:
|
|
92528
|
-
@noble/curves/abstract/montgomery.js:
|
|
92529
|
-
@noble/curves/
|
|
92530
|
-
@noble/curves/
|
|
92531
|
-
@noble/curves/
|
|
92532
|
-
@noble/curves/
|
|
92533
|
-
@noble/curves/nist.js:
|
|
93316
|
+
@noble/curves/esm/utils.js:
|
|
93317
|
+
@noble/curves/esm/abstract/modular.js:
|
|
93318
|
+
@noble/curves/esm/abstract/curve.js:
|
|
93319
|
+
@noble/curves/esm/abstract/edwards.js:
|
|
93320
|
+
@noble/curves/esm/abstract/montgomery.js:
|
|
93321
|
+
@noble/curves/esm/ed25519.js:
|
|
93322
|
+
@noble/curves/esm/ed448.js:
|
|
93323
|
+
@noble/curves/esm/abstract/weierstrass.js:
|
|
93324
|
+
@noble/curves/esm/_shortw_utils.js:
|
|
93325
|
+
@noble/curves/esm/nist.js:
|
|
92534
93326
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
92535
93327
|
|
|
92536
93328
|
@noble/ciphers/utils.js:
|
|
92537
93329
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
92538
93330
|
|
|
93331
|
+
@noble/hashes/esm/utils.js:
|
|
92539
93332
|
@noble/hashes/utils.js:
|
|
92540
93333
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
92541
93334
|
*/
|