@agentvault/agentvault 0.19.50 → 0.19.52
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 +1831 -1023
- package/dist/cli.js.map +4 -4
- package/dist/index.js +1837 -1029
- package/dist/index.js.map +4 -4
- package/openclaw.plugin.json +1 -1
- 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/cli.js
CHANGED
|
@@ -39,7 +39,7 @@ var __toESM = (mod4, isNodeMode, target) => (target = mod4 != null ? __create(__
|
|
|
39
39
|
));
|
|
40
40
|
|
|
41
41
|
// ../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs
|
|
42
|
-
var __filename, __dirname, url2, path, Module, Module, root, window_, crypto_, randomValuesStandard,
|
|
42
|
+
var __filename, __dirname, url2, path, Module, Module, root, window_, crypto_, randomValuesStandard, crypto4, randomValueNodeJS, _Module, libsodium_sumo_default;
|
|
43
43
|
var init_libsodium_sumo = __esm({
|
|
44
44
|
async "../../node_modules/libsodium-sumo/dist/modules-sumo-esm/libsodium-sumo.mjs"() {
|
|
45
45
|
try {
|
|
@@ -103,9 +103,9 @@ var init_libsodium_sumo = __esm({
|
|
|
103
103
|
Module.getRandomValue = randomValuesStandard;
|
|
104
104
|
} catch (e) {
|
|
105
105
|
try {
|
|
106
|
-
|
|
106
|
+
crypto4 = null;
|
|
107
107
|
randomValueNodeJS = function() {
|
|
108
|
-
var buf =
|
|
108
|
+
var buf = crypto4["randomBytes"](4);
|
|
109
109
|
return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0;
|
|
110
110
|
};
|
|
111
111
|
randomValueNodeJS();
|
|
@@ -20938,7 +20938,7 @@ var init_libsodium_sumo = __esm({
|
|
|
20938
20938
|
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;
|
|
20939
20939
|
l2 = T2 - 48 | 0;
|
|
20940
20940
|
T2 = l2;
|
|
20941
|
-
c3 =
|
|
20941
|
+
c3 = nc2(a3);
|
|
20942
20942
|
a: {
|
|
20943
20943
|
if (c3) {
|
|
20944
20944
|
break a;
|
|
@@ -25901,7 +25901,7 @@ var init_libsodium_sumo = __esm({
|
|
|
25901
25901
|
c3 = -11;
|
|
25902
25902
|
b3 = 11;
|
|
25903
25903
|
}
|
|
25904
|
-
a3 =
|
|
25904
|
+
a3 = nc2(i4);
|
|
25905
25905
|
if (a3) {
|
|
25906
25906
|
break d;
|
|
25907
25907
|
}
|
|
@@ -33339,7 +33339,7 @@ var init_libsodium_sumo = __esm({
|
|
|
33339
33339
|
}
|
|
33340
33340
|
y2[a3 + 4 >> 2] = y2[e + 12 >> 2];
|
|
33341
33341
|
b3 = y2[e + 8 >> 2];
|
|
33342
|
-
h2 =
|
|
33342
|
+
h2 = nc2(a3);
|
|
33343
33343
|
if (h2) {
|
|
33344
33344
|
break a;
|
|
33345
33345
|
}
|
|
@@ -35952,7 +35952,7 @@ var init_libsodium_sumo = __esm({
|
|
|
35952
35952
|
T2 = f2 + 256 | 0;
|
|
35953
35953
|
return a3 | 0;
|
|
35954
35954
|
}
|
|
35955
|
-
function
|
|
35955
|
+
function nc2(a3) {
|
|
35956
35956
|
var b3 = 0, c3 = 0, d2 = 0;
|
|
35957
35957
|
if (!a3) {
|
|
35958
35958
|
return -25;
|
|
@@ -36564,7 +36564,7 @@ var init_libsodium_sumo = __esm({
|
|
|
36564
36564
|
b3 = a3 ^ 127;
|
|
36565
36565
|
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;
|
|
36566
36566
|
}
|
|
36567
|
-
function
|
|
36567
|
+
function ed(a3, b3, c3, d2, e, f2) {
|
|
36568
36568
|
a3 = a3 | 0;
|
|
36569
36569
|
b3 = b3 | 0;
|
|
36570
36570
|
c3 = c3 | 0;
|
|
@@ -40031,7 +40031,7 @@ var init_libsodium_sumo = __esm({
|
|
|
40031
40031
|
}
|
|
40032
40032
|
return { e: Object.create(Object.prototype, { grow: { value: ba2 }, buffer: { get: function() {
|
|
40033
40033
|
return v2;
|
|
40034
|
-
} } }), 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:
|
|
40034
|
+
} } }), 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 };
|
|
40035
40035
|
}
|
|
40036
40036
|
return da2(ea2);
|
|
40037
40037
|
})(info);
|
|
@@ -40308,7 +40308,7 @@ var init_libsodium_sumo = __esm({
|
|
|
40308
40308
|
try {
|
|
40309
40309
|
var window_ = "object" === typeof window ? window : self;
|
|
40310
40310
|
var crypto_ = typeof window_.crypto !== "undefined" ? window_.crypto : window_.msCrypto;
|
|
40311
|
-
crypto_ = crypto_ === void 0 ?
|
|
40311
|
+
crypto_ = crypto_ === void 0 ? crypto4 : crypto_;
|
|
40312
40312
|
var randomValuesStandard = function() {
|
|
40313
40313
|
var buf = new Uint32Array(1);
|
|
40314
40314
|
crypto_.getRandomValues(buf);
|
|
@@ -40318,9 +40318,9 @@ var init_libsodium_sumo = __esm({
|
|
|
40318
40318
|
Module3.getRandomValue = randomValuesStandard;
|
|
40319
40319
|
} catch (e) {
|
|
40320
40320
|
try {
|
|
40321
|
-
var
|
|
40321
|
+
var crypto4 = null;
|
|
40322
40322
|
var randomValueNodeJS = function() {
|
|
40323
|
-
var buf =
|
|
40323
|
+
var buf = crypto4["randomBytes"](4);
|
|
40324
40324
|
return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0;
|
|
40325
40325
|
};
|
|
40326
40326
|
randomValueNodeJS();
|
|
@@ -41368,7 +41368,7 @@ var init_libsodium_sumo = __esm({
|
|
|
41368
41368
|
try {
|
|
41369
41369
|
var window_ = "object" === typeof window ? window : self;
|
|
41370
41370
|
var crypto_ = typeof window_.crypto !== "undefined" ? window_.crypto : window_.msCrypto;
|
|
41371
|
-
crypto_ = crypto_ === void 0 ?
|
|
41371
|
+
crypto_ = crypto_ === void 0 ? crypto4 : crypto_;
|
|
41372
41372
|
var randomValuesStandard = function() {
|
|
41373
41373
|
var buf = new Uint32Array(1);
|
|
41374
41374
|
crypto_.getRandomValues(buf);
|
|
@@ -41378,9 +41378,9 @@ var init_libsodium_sumo = __esm({
|
|
|
41378
41378
|
Module2.getRandomValue = randomValuesStandard;
|
|
41379
41379
|
} catch (e) {
|
|
41380
41380
|
try {
|
|
41381
|
-
var
|
|
41381
|
+
var crypto4 = null;
|
|
41382
41382
|
var randomValueNodeJS = function() {
|
|
41383
|
-
var buf =
|
|
41383
|
+
var buf = crypto4["randomBytes"](4);
|
|
41384
41384
|
return (buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3]) >>> 0;
|
|
41385
41385
|
};
|
|
41386
41386
|
randomValueNodeJS();
|
|
@@ -47412,7 +47412,7 @@ var init_proposal = __esm({
|
|
|
47412
47412
|
}
|
|
47413
47413
|
};
|
|
47414
47414
|
encodeProposal = encode(proposalEncoder);
|
|
47415
|
-
decodeProposalAdd = mapDecoder(decodeAdd, (
|
|
47415
|
+
decodeProposalAdd = mapDecoder(decodeAdd, (add4) => ({ proposalType: "add", add: add4 }));
|
|
47416
47416
|
decodeProposalUpdate = mapDecoder(decodeUpdate, (update) => ({
|
|
47417
47417
|
proposalType: "update",
|
|
47418
47418
|
update
|
|
@@ -50923,8 +50923,8 @@ async function loadSubtleCrypto() {
|
|
|
50923
50923
|
return globalThis.crypto.subtle;
|
|
50924
50924
|
}
|
|
50925
50925
|
try {
|
|
50926
|
-
const { webcrypto } = await import("crypto");
|
|
50927
|
-
return
|
|
50926
|
+
const { webcrypto: webcrypto2 } = await import("crypto");
|
|
50927
|
+
return webcrypto2.subtle;
|
|
50928
50928
|
} catch (e) {
|
|
50929
50929
|
throw new NotSupportedError(e);
|
|
50930
50930
|
}
|
|
@@ -53978,9 +53978,9 @@ function createCipher(core, opts) {
|
|
|
53978
53978
|
if (nonceNcLen !== nonce.length)
|
|
53979
53979
|
throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`);
|
|
53980
53980
|
if (nonceNcLen !== 12) {
|
|
53981
|
-
const
|
|
53982
|
-
|
|
53983
|
-
nonce =
|
|
53981
|
+
const nc2 = new Uint8Array(12);
|
|
53982
|
+
nc2.set(nonce, counterRight ? 0 : 12 - nonce.length);
|
|
53983
|
+
nonce = nc2;
|
|
53984
53984
|
toClean.push(nonce);
|
|
53985
53985
|
}
|
|
53986
53986
|
const n32 = u322(nonce);
|
|
@@ -54817,31 +54817,32 @@ var init_rng = __esm({
|
|
|
54817
54817
|
}
|
|
54818
54818
|
});
|
|
54819
54819
|
|
|
54820
|
-
//
|
|
54820
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
54821
|
+
import * as nc from "node:crypto";
|
|
54822
|
+
var crypto2;
|
|
54823
|
+
var init_cryptoNode = __esm({
|
|
54824
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js"() {
|
|
54825
|
+
crypto2 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
54826
|
+
}
|
|
54827
|
+
});
|
|
54828
|
+
|
|
54829
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js
|
|
54821
54830
|
function isBytes3(a2) {
|
|
54822
54831
|
return a2 instanceof Uint8Array || ArrayBuffer.isView(a2) && a2.constructor.name === "Uint8Array";
|
|
54823
54832
|
}
|
|
54824
|
-
function anumber3(n2
|
|
54825
|
-
if (!Number.isSafeInteger(n2) || n2 < 0)
|
|
54826
|
-
|
|
54827
|
-
throw new Error(`${prefix}expected integer >= 0, got ${n2}`);
|
|
54828
|
-
}
|
|
54833
|
+
function anumber3(n2) {
|
|
54834
|
+
if (!Number.isSafeInteger(n2) || n2 < 0)
|
|
54835
|
+
throw new Error("positive integer expected, got " + n2);
|
|
54829
54836
|
}
|
|
54830
|
-
function abytes3(
|
|
54831
|
-
|
|
54832
|
-
|
|
54833
|
-
|
|
54834
|
-
|
|
54835
|
-
const prefix = title && `"${title}" `;
|
|
54836
|
-
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
54837
|
-
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
54838
|
-
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
54839
|
-
}
|
|
54840
|
-
return value;
|
|
54837
|
+
function abytes3(b2, ...lengths) {
|
|
54838
|
+
if (!isBytes3(b2))
|
|
54839
|
+
throw new Error("Uint8Array expected");
|
|
54840
|
+
if (lengths.length > 0 && !lengths.includes(b2.length))
|
|
54841
|
+
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b2.length);
|
|
54841
54842
|
}
|
|
54842
54843
|
function ahash2(h2) {
|
|
54843
54844
|
if (typeof h2 !== "function" || typeof h2.create !== "function")
|
|
54844
|
-
throw new Error("Hash
|
|
54845
|
+
throw new Error("Hash should be wrapped by utils.createHasher");
|
|
54845
54846
|
anumber3(h2.outputLen);
|
|
54846
54847
|
anumber3(h2.blockLen);
|
|
54847
54848
|
}
|
|
@@ -54852,10 +54853,10 @@ function aexists3(instance, checkFinished = true) {
|
|
|
54852
54853
|
throw new Error("Hash#digest() has already been called");
|
|
54853
54854
|
}
|
|
54854
54855
|
function aoutput3(out, instance) {
|
|
54855
|
-
abytes3(out
|
|
54856
|
+
abytes3(out);
|
|
54856
54857
|
const min = instance.outputLen;
|
|
54857
54858
|
if (out.length < min) {
|
|
54858
|
-
throw new Error(
|
|
54859
|
+
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
54859
54860
|
}
|
|
54860
54861
|
}
|
|
54861
54862
|
function u323(arr) {
|
|
@@ -54921,6 +54922,17 @@ function hexToBytes3(hex3) {
|
|
|
54921
54922
|
}
|
|
54922
54923
|
return array2;
|
|
54923
54924
|
}
|
|
54925
|
+
function utf8ToBytes(str) {
|
|
54926
|
+
if (typeof str !== "string")
|
|
54927
|
+
throw new Error("string expected");
|
|
54928
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
54929
|
+
}
|
|
54930
|
+
function toBytes(data) {
|
|
54931
|
+
if (typeof data === "string")
|
|
54932
|
+
data = utf8ToBytes(data);
|
|
54933
|
+
abytes3(data);
|
|
54934
|
+
return data;
|
|
54935
|
+
}
|
|
54924
54936
|
function concatBytes2(...arrays) {
|
|
54925
54937
|
let sum = 0;
|
|
54926
54938
|
for (let i2 = 0; i2 < arrays.length; i2++) {
|
|
@@ -54936,24 +54948,35 @@ function concatBytes2(...arrays) {
|
|
|
54936
54948
|
}
|
|
54937
54949
|
return res;
|
|
54938
54950
|
}
|
|
54939
|
-
function createHasher2(hashCons
|
|
54940
|
-
const hashC = (msg
|
|
54941
|
-
const tmp = hashCons(
|
|
54951
|
+
function createHasher2(hashCons) {
|
|
54952
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
54953
|
+
const tmp = hashCons();
|
|
54954
|
+
hashC.outputLen = tmp.outputLen;
|
|
54955
|
+
hashC.blockLen = tmp.blockLen;
|
|
54956
|
+
hashC.create = () => hashCons();
|
|
54957
|
+
return hashC;
|
|
54958
|
+
}
|
|
54959
|
+
function createXOFer(hashCons) {
|
|
54960
|
+
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
54961
|
+
const tmp = hashCons({});
|
|
54942
54962
|
hashC.outputLen = tmp.outputLen;
|
|
54943
54963
|
hashC.blockLen = tmp.blockLen;
|
|
54944
54964
|
hashC.create = (opts) => hashCons(opts);
|
|
54945
|
-
|
|
54946
|
-
return Object.freeze(hashC);
|
|
54965
|
+
return hashC;
|
|
54947
54966
|
}
|
|
54948
54967
|
function randomBytes2(bytesLength = 32) {
|
|
54949
|
-
|
|
54950
|
-
|
|
54951
|
-
|
|
54952
|
-
|
|
54968
|
+
if (crypto2 && typeof crypto2.getRandomValues === "function") {
|
|
54969
|
+
return crypto2.getRandomValues(new Uint8Array(bytesLength));
|
|
54970
|
+
}
|
|
54971
|
+
if (crypto2 && typeof crypto2.randomBytes === "function") {
|
|
54972
|
+
return Uint8Array.from(crypto2.randomBytes(bytesLength));
|
|
54973
|
+
}
|
|
54974
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
54953
54975
|
}
|
|
54954
|
-
var isLE3, swap32IfBE2, hasHexBuiltin, hexes, asciis,
|
|
54976
|
+
var isLE3, swap32IfBE2, hasHexBuiltin, hexes, asciis, Hash;
|
|
54955
54977
|
var init_utils2 = __esm({
|
|
54956
|
-
"
|
|
54978
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js"() {
|
|
54979
|
+
init_cryptoNode();
|
|
54957
54980
|
isLE3 = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
54958
54981
|
swap32IfBE2 = isLE3 ? (u2) => u2 : byteSwap32;
|
|
54959
54982
|
hasHexBuiltin = /* @__PURE__ */ (() => (
|
|
@@ -54962,13 +54985,24 @@ var init_utils2 = __esm({
|
|
|
54962
54985
|
))();
|
|
54963
54986
|
hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_2, i2) => i2.toString(16).padStart(2, "0"));
|
|
54964
54987
|
asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
54965
|
-
|
|
54966
|
-
|
|
54967
|
-
});
|
|
54988
|
+
Hash = class {
|
|
54989
|
+
};
|
|
54968
54990
|
}
|
|
54969
54991
|
});
|
|
54970
54992
|
|
|
54971
|
-
//
|
|
54993
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js
|
|
54994
|
+
function setBigUint64(view, byteOffset, value, isLE4) {
|
|
54995
|
+
if (typeof view.setBigUint64 === "function")
|
|
54996
|
+
return view.setBigUint64(byteOffset, value, isLE4);
|
|
54997
|
+
const _32n4 = BigInt(32);
|
|
54998
|
+
const _u32_max = BigInt(4294967295);
|
|
54999
|
+
const wh = Number(value >> _32n4 & _u32_max);
|
|
55000
|
+
const wl = Number(value & _u32_max);
|
|
55001
|
+
const h2 = isLE4 ? 4 : 0;
|
|
55002
|
+
const l2 = isLE4 ? 0 : 4;
|
|
55003
|
+
view.setUint32(byteOffset + h2, wh, isLE4);
|
|
55004
|
+
view.setUint32(byteOffset + l2, wl, isLE4);
|
|
55005
|
+
}
|
|
54972
55006
|
function Chi2(a2, b2, c2) {
|
|
54973
55007
|
return a2 & b2 ^ ~a2 & c2;
|
|
54974
55008
|
}
|
|
@@ -54977,21 +55011,15 @@ function Maj2(a2, b2, c2) {
|
|
|
54977
55011
|
}
|
|
54978
55012
|
var HashMD2, SHA256_IV2, SHA384_IV2, SHA512_IV2;
|
|
54979
55013
|
var init_md2 = __esm({
|
|
54980
|
-
"
|
|
55014
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js"() {
|
|
54981
55015
|
init_utils2();
|
|
54982
|
-
HashMD2 = class {
|
|
54983
|
-
blockLen;
|
|
54984
|
-
outputLen;
|
|
54985
|
-
padOffset;
|
|
54986
|
-
isLE;
|
|
54987
|
-
// For partial updates less than block size
|
|
54988
|
-
buffer;
|
|
54989
|
-
view;
|
|
54990
|
-
finished = false;
|
|
54991
|
-
length = 0;
|
|
54992
|
-
pos = 0;
|
|
54993
|
-
destroyed = false;
|
|
55016
|
+
HashMD2 = class extends Hash {
|
|
54994
55017
|
constructor(blockLen, outputLen, padOffset, isLE4) {
|
|
55018
|
+
super();
|
|
55019
|
+
this.finished = false;
|
|
55020
|
+
this.length = 0;
|
|
55021
|
+
this.pos = 0;
|
|
55022
|
+
this.destroyed = false;
|
|
54995
55023
|
this.blockLen = blockLen;
|
|
54996
55024
|
this.outputLen = outputLen;
|
|
54997
55025
|
this.padOffset = padOffset;
|
|
@@ -55001,6 +55029,7 @@ var init_md2 = __esm({
|
|
|
55001
55029
|
}
|
|
55002
55030
|
update(data) {
|
|
55003
55031
|
aexists3(this);
|
|
55032
|
+
data = toBytes(data);
|
|
55004
55033
|
abytes3(data);
|
|
55005
55034
|
const { view, buffer, blockLen } = this;
|
|
55006
55035
|
const len = data.length;
|
|
@@ -55038,12 +55067,12 @@ var init_md2 = __esm({
|
|
|
55038
55067
|
}
|
|
55039
55068
|
for (let i2 = pos; i2 < blockLen; i2++)
|
|
55040
55069
|
buffer[i2] = 0;
|
|
55041
|
-
|
|
55070
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE4);
|
|
55042
55071
|
this.process(view, 0);
|
|
55043
55072
|
const oview = createView3(out);
|
|
55044
55073
|
const len = this.outputLen;
|
|
55045
55074
|
if (len % 4)
|
|
55046
|
-
throw new Error("_sha2: outputLen
|
|
55075
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
55047
55076
|
const outLen = len / 4;
|
|
55048
55077
|
const state = this.get();
|
|
55049
55078
|
if (outLen > state.length)
|
|
@@ -55059,7 +55088,7 @@ var init_md2 = __esm({
|
|
|
55059
55088
|
return res;
|
|
55060
55089
|
}
|
|
55061
55090
|
_cloneInto(to) {
|
|
55062
|
-
to
|
|
55091
|
+
to || (to = new this.constructor());
|
|
55063
55092
|
to.set(...this.get());
|
|
55064
55093
|
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
55065
55094
|
to.destroyed = destroyed;
|
|
@@ -55123,7 +55152,7 @@ var init_md2 = __esm({
|
|
|
55123
55152
|
}
|
|
55124
55153
|
});
|
|
55125
55154
|
|
|
55126
|
-
//
|
|
55155
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js
|
|
55127
55156
|
function fromBig2(n2, le2 = false) {
|
|
55128
55157
|
if (le2)
|
|
55129
55158
|
return { h: Number(n2 & U32_MASK642), l: Number(n2 >> _32n2 & U32_MASK642) };
|
|
@@ -55145,7 +55174,7 @@ function add2(Ah, Al, Bh, Bl) {
|
|
|
55145
55174
|
}
|
|
55146
55175
|
var U32_MASK642, _32n2, shrSH2, shrSL2, rotrSH2, rotrSL2, rotrBH2, rotrBL2, rotlSH2, rotlSL2, rotlBH2, rotlBL2, add3L2, add3H2, add4L2, add4H2, add5L2, add5H2;
|
|
55147
55176
|
var init_u642 = __esm({
|
|
55148
|
-
"
|
|
55177
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/_u64.js"() {
|
|
55149
55178
|
U32_MASK642 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
55150
55179
|
_32n2 = /* @__PURE__ */ BigInt(32);
|
|
55151
55180
|
shrSH2 = (h2, _l, s2) => h2 >>> s2;
|
|
@@ -55167,10 +55196,10 @@ var init_u642 = __esm({
|
|
|
55167
55196
|
}
|
|
55168
55197
|
});
|
|
55169
55198
|
|
|
55170
|
-
//
|
|
55171
|
-
var SHA256_K, SHA256_W,
|
|
55199
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha2.js
|
|
55200
|
+
var SHA256_K, SHA256_W, SHA256, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA512, SHA384, sha2562, sha5122, sha3842;
|
|
55172
55201
|
var init_sha22 = __esm({
|
|
55173
|
-
"
|
|
55202
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha2.js"() {
|
|
55174
55203
|
init_md2();
|
|
55175
55204
|
init_u642();
|
|
55176
55205
|
init_utils2();
|
|
@@ -55241,9 +55270,17 @@ var init_sha22 = __esm({
|
|
|
55241
55270
|
3329325298
|
|
55242
55271
|
]);
|
|
55243
55272
|
SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
55244
|
-
|
|
55245
|
-
constructor(outputLen) {
|
|
55273
|
+
SHA256 = class extends HashMD2 {
|
|
55274
|
+
constructor(outputLen = 32) {
|
|
55246
55275
|
super(64, outputLen, 8, false);
|
|
55276
|
+
this.A = SHA256_IV2[0] | 0;
|
|
55277
|
+
this.B = SHA256_IV2[1] | 0;
|
|
55278
|
+
this.C = SHA256_IV2[2] | 0;
|
|
55279
|
+
this.D = SHA256_IV2[3] | 0;
|
|
55280
|
+
this.E = SHA256_IV2[4] | 0;
|
|
55281
|
+
this.F = SHA256_IV2[5] | 0;
|
|
55282
|
+
this.G = SHA256_IV2[6] | 0;
|
|
55283
|
+
this.H = SHA256_IV2[7] | 0;
|
|
55247
55284
|
}
|
|
55248
55285
|
get() {
|
|
55249
55286
|
const { A: A2, B: B2, C: C2, D: D2, E: E2, F: F2, G: G2, H: H2 } = this;
|
|
@@ -55303,21 +55340,6 @@ var init_sha22 = __esm({
|
|
|
55303
55340
|
clean3(this.buffer);
|
|
55304
55341
|
}
|
|
55305
55342
|
};
|
|
55306
|
-
_SHA256 = class extends SHA2_32B {
|
|
55307
|
-
// We cannot use array here since array allows indexing by variable
|
|
55308
|
-
// which means optimizer/compiler cannot use registers.
|
|
55309
|
-
A = SHA256_IV2[0] | 0;
|
|
55310
|
-
B = SHA256_IV2[1] | 0;
|
|
55311
|
-
C = SHA256_IV2[2] | 0;
|
|
55312
|
-
D = SHA256_IV2[3] | 0;
|
|
55313
|
-
E = SHA256_IV2[4] | 0;
|
|
55314
|
-
F = SHA256_IV2[5] | 0;
|
|
55315
|
-
G = SHA256_IV2[6] | 0;
|
|
55316
|
-
H = SHA256_IV2[7] | 0;
|
|
55317
|
-
constructor() {
|
|
55318
|
-
super(32);
|
|
55319
|
-
}
|
|
55320
|
-
};
|
|
55321
55343
|
K512 = /* @__PURE__ */ (() => split2([
|
|
55322
55344
|
"0x428a2f98d728ae22",
|
|
55323
55345
|
"0x7137449123ef65cd",
|
|
@@ -55404,9 +55426,25 @@ var init_sha22 = __esm({
|
|
|
55404
55426
|
SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
|
|
55405
55427
|
SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
55406
55428
|
SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
55407
|
-
|
|
55408
|
-
constructor(outputLen) {
|
|
55429
|
+
SHA512 = class extends HashMD2 {
|
|
55430
|
+
constructor(outputLen = 64) {
|
|
55409
55431
|
super(128, outputLen, 16, false);
|
|
55432
|
+
this.Ah = SHA512_IV2[0] | 0;
|
|
55433
|
+
this.Al = SHA512_IV2[1] | 0;
|
|
55434
|
+
this.Bh = SHA512_IV2[2] | 0;
|
|
55435
|
+
this.Bl = SHA512_IV2[3] | 0;
|
|
55436
|
+
this.Ch = SHA512_IV2[4] | 0;
|
|
55437
|
+
this.Cl = SHA512_IV2[5] | 0;
|
|
55438
|
+
this.Dh = SHA512_IV2[6] | 0;
|
|
55439
|
+
this.Dl = SHA512_IV2[7] | 0;
|
|
55440
|
+
this.Eh = SHA512_IV2[8] | 0;
|
|
55441
|
+
this.El = SHA512_IV2[9] | 0;
|
|
55442
|
+
this.Fh = SHA512_IV2[10] | 0;
|
|
55443
|
+
this.Fl = SHA512_IV2[11] | 0;
|
|
55444
|
+
this.Gh = SHA512_IV2[12] | 0;
|
|
55445
|
+
this.Gl = SHA512_IV2[13] | 0;
|
|
55446
|
+
this.Hh = SHA512_IV2[14] | 0;
|
|
55447
|
+
this.Hl = SHA512_IV2[15] | 0;
|
|
55410
55448
|
}
|
|
55411
55449
|
// prettier-ignore
|
|
55412
55450
|
get() {
|
|
@@ -55499,87 +55537,55 @@ var init_sha22 = __esm({
|
|
|
55499
55537
|
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
55500
55538
|
}
|
|
55501
55539
|
};
|
|
55502
|
-
|
|
55503
|
-
Ah = SHA512_IV2[0] | 0;
|
|
55504
|
-
Al = SHA512_IV2[1] | 0;
|
|
55505
|
-
Bh = SHA512_IV2[2] | 0;
|
|
55506
|
-
Bl = SHA512_IV2[3] | 0;
|
|
55507
|
-
Ch = SHA512_IV2[4] | 0;
|
|
55508
|
-
Cl = SHA512_IV2[5] | 0;
|
|
55509
|
-
Dh = SHA512_IV2[6] | 0;
|
|
55510
|
-
Dl = SHA512_IV2[7] | 0;
|
|
55511
|
-
Eh = SHA512_IV2[8] | 0;
|
|
55512
|
-
El = SHA512_IV2[9] | 0;
|
|
55513
|
-
Fh = SHA512_IV2[10] | 0;
|
|
55514
|
-
Fl = SHA512_IV2[11] | 0;
|
|
55515
|
-
Gh = SHA512_IV2[12] | 0;
|
|
55516
|
-
Gl = SHA512_IV2[13] | 0;
|
|
55517
|
-
Hh = SHA512_IV2[14] | 0;
|
|
55518
|
-
Hl = SHA512_IV2[15] | 0;
|
|
55519
|
-
constructor() {
|
|
55520
|
-
super(64);
|
|
55521
|
-
}
|
|
55522
|
-
};
|
|
55523
|
-
_SHA384 = class extends SHA2_64B {
|
|
55524
|
-
Ah = SHA384_IV2[0] | 0;
|
|
55525
|
-
Al = SHA384_IV2[1] | 0;
|
|
55526
|
-
Bh = SHA384_IV2[2] | 0;
|
|
55527
|
-
Bl = SHA384_IV2[3] | 0;
|
|
55528
|
-
Ch = SHA384_IV2[4] | 0;
|
|
55529
|
-
Cl = SHA384_IV2[5] | 0;
|
|
55530
|
-
Dh = SHA384_IV2[6] | 0;
|
|
55531
|
-
Dl = SHA384_IV2[7] | 0;
|
|
55532
|
-
Eh = SHA384_IV2[8] | 0;
|
|
55533
|
-
El = SHA384_IV2[9] | 0;
|
|
55534
|
-
Fh = SHA384_IV2[10] | 0;
|
|
55535
|
-
Fl = SHA384_IV2[11] | 0;
|
|
55536
|
-
Gh = SHA384_IV2[12] | 0;
|
|
55537
|
-
Gl = SHA384_IV2[13] | 0;
|
|
55538
|
-
Hh = SHA384_IV2[14] | 0;
|
|
55539
|
-
Hl = SHA384_IV2[15] | 0;
|
|
55540
|
+
SHA384 = class extends SHA512 {
|
|
55540
55541
|
constructor() {
|
|
55541
55542
|
super(48);
|
|
55543
|
+
this.Ah = SHA384_IV2[0] | 0;
|
|
55544
|
+
this.Al = SHA384_IV2[1] | 0;
|
|
55545
|
+
this.Bh = SHA384_IV2[2] | 0;
|
|
55546
|
+
this.Bl = SHA384_IV2[3] | 0;
|
|
55547
|
+
this.Ch = SHA384_IV2[4] | 0;
|
|
55548
|
+
this.Cl = SHA384_IV2[5] | 0;
|
|
55549
|
+
this.Dh = SHA384_IV2[6] | 0;
|
|
55550
|
+
this.Dl = SHA384_IV2[7] | 0;
|
|
55551
|
+
this.Eh = SHA384_IV2[8] | 0;
|
|
55552
|
+
this.El = SHA384_IV2[9] | 0;
|
|
55553
|
+
this.Fh = SHA384_IV2[10] | 0;
|
|
55554
|
+
this.Fl = SHA384_IV2[11] | 0;
|
|
55555
|
+
this.Gh = SHA384_IV2[12] | 0;
|
|
55556
|
+
this.Gl = SHA384_IV2[13] | 0;
|
|
55557
|
+
this.Hh = SHA384_IV2[14] | 0;
|
|
55558
|
+
this.Hl = SHA384_IV2[15] | 0;
|
|
55542
55559
|
}
|
|
55543
55560
|
};
|
|
55544
|
-
sha2562 = /* @__PURE__ */ createHasher2(
|
|
55545
|
-
|
|
55546
|
-
|
|
55547
|
-
);
|
|
55548
|
-
sha5122 = /* @__PURE__ */ createHasher2(
|
|
55549
|
-
() => new _SHA512(),
|
|
55550
|
-
/* @__PURE__ */ oidNist2(3)
|
|
55551
|
-
);
|
|
55552
|
-
sha3842 = /* @__PURE__ */ createHasher2(
|
|
55553
|
-
() => new _SHA384(),
|
|
55554
|
-
/* @__PURE__ */ oidNist2(2)
|
|
55555
|
-
);
|
|
55561
|
+
sha2562 = /* @__PURE__ */ createHasher2(() => new SHA256());
|
|
55562
|
+
sha5122 = /* @__PURE__ */ createHasher2(() => new SHA512());
|
|
55563
|
+
sha3842 = /* @__PURE__ */ createHasher2(() => new SHA384());
|
|
55556
55564
|
}
|
|
55557
55565
|
});
|
|
55558
55566
|
|
|
55559
|
-
//
|
|
55560
|
-
function
|
|
55567
|
+
// ../../node_modules/@noble/curves/esm/utils.js
|
|
55568
|
+
function _abool2(value, title = "") {
|
|
55561
55569
|
if (typeof value !== "boolean") {
|
|
55562
|
-
const prefix = title && `"${title}"
|
|
55570
|
+
const prefix = title && `"${title}"`;
|
|
55563
55571
|
throw new Error(prefix + "expected boolean, got type=" + typeof value);
|
|
55564
55572
|
}
|
|
55565
55573
|
return value;
|
|
55566
55574
|
}
|
|
55567
|
-
function
|
|
55568
|
-
|
|
55569
|
-
|
|
55570
|
-
|
|
55571
|
-
|
|
55572
|
-
anumber3(n2);
|
|
55573
|
-
return n2;
|
|
55574
|
-
}
|
|
55575
|
-
function asafenumber(value, title = "") {
|
|
55576
|
-
if (!Number.isSafeInteger(value)) {
|
|
55575
|
+
function _abytes2(value, length, title = "") {
|
|
55576
|
+
const bytes = isBytes3(value);
|
|
55577
|
+
const len = value?.length;
|
|
55578
|
+
const needsLen = length !== void 0;
|
|
55579
|
+
if (!bytes || needsLen && len !== length) {
|
|
55577
55580
|
const prefix = title && `"${title}" `;
|
|
55578
|
-
|
|
55581
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
55582
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
55583
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
55579
55584
|
}
|
|
55585
|
+
return value;
|
|
55580
55586
|
}
|
|
55581
55587
|
function numberToHexUnpadded(num) {
|
|
55582
|
-
const hex3 =
|
|
55588
|
+
const hex3 = num.toString(16);
|
|
55583
55589
|
return hex3.length & 1 ? "0" + hex3 : hex3;
|
|
55584
55590
|
}
|
|
55585
55591
|
function hexToNumber3(hex3) {
|
|
@@ -55591,19 +55597,33 @@ function bytesToNumberBE(bytes) {
|
|
|
55591
55597
|
return hexToNumber3(bytesToHex3(bytes));
|
|
55592
55598
|
}
|
|
55593
55599
|
function bytesToNumberLE2(bytes) {
|
|
55594
|
-
|
|
55600
|
+
abytes3(bytes);
|
|
55601
|
+
return hexToNumber3(bytesToHex3(Uint8Array.from(bytes).reverse()));
|
|
55595
55602
|
}
|
|
55596
55603
|
function numberToBytesBE2(n2, len) {
|
|
55597
|
-
|
|
55598
|
-
n2 = abignumber(n2);
|
|
55599
|
-
const res = hexToBytes3(n2.toString(16).padStart(len * 2, "0"));
|
|
55600
|
-
if (res.length !== len)
|
|
55601
|
-
throw new Error("number too large");
|
|
55602
|
-
return res;
|
|
55604
|
+
return hexToBytes3(n2.toString(16).padStart(len * 2, "0"));
|
|
55603
55605
|
}
|
|
55604
55606
|
function numberToBytesLE2(n2, len) {
|
|
55605
55607
|
return numberToBytesBE2(n2, len).reverse();
|
|
55606
55608
|
}
|
|
55609
|
+
function ensureBytes(title, hex3, expectedLength) {
|
|
55610
|
+
let res;
|
|
55611
|
+
if (typeof hex3 === "string") {
|
|
55612
|
+
try {
|
|
55613
|
+
res = hexToBytes3(hex3);
|
|
55614
|
+
} catch (e) {
|
|
55615
|
+
throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
|
|
55616
|
+
}
|
|
55617
|
+
} else if (isBytes3(hex3)) {
|
|
55618
|
+
res = Uint8Array.from(hex3);
|
|
55619
|
+
} else {
|
|
55620
|
+
throw new Error(title + " must be hex string or Uint8Array");
|
|
55621
|
+
}
|
|
55622
|
+
const len = res.length;
|
|
55623
|
+
if (typeof expectedLength === "number" && len !== expectedLength)
|
|
55624
|
+
throw new Error(title + " of length " + expectedLength + " expected, got " + len);
|
|
55625
|
+
return res;
|
|
55626
|
+
}
|
|
55607
55627
|
function equalBytes2(a2, b2) {
|
|
55608
55628
|
if (a2.length !== b2.length)
|
|
55609
55629
|
return false;
|
|
@@ -55638,15 +55658,14 @@ function bitLen(n2) {
|
|
|
55638
55658
|
return len;
|
|
55639
55659
|
}
|
|
55640
55660
|
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
55641
|
-
|
|
55642
|
-
|
|
55661
|
+
if (typeof hashLen !== "number" || hashLen < 2)
|
|
55662
|
+
throw new Error("hashLen must be a number");
|
|
55663
|
+
if (typeof qByteLen !== "number" || qByteLen < 2)
|
|
55664
|
+
throw new Error("qByteLen must be a number");
|
|
55643
55665
|
if (typeof hmacFn !== "function")
|
|
55644
55666
|
throw new Error("hmacFn must be a function");
|
|
55645
55667
|
const u8n = (len) => new Uint8Array(len);
|
|
55646
|
-
const
|
|
55647
|
-
const byte0 = Uint8Array.of(0);
|
|
55648
|
-
const byte1 = Uint8Array.of(1);
|
|
55649
|
-
const _maxDrbgIters = 1e3;
|
|
55668
|
+
const u8of = (byte) => Uint8Array.of(byte);
|
|
55650
55669
|
let v2 = u8n(hashLen);
|
|
55651
55670
|
let k2 = u8n(hashLen);
|
|
55652
55671
|
let i2 = 0;
|
|
@@ -55655,18 +55674,18 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
55655
55674
|
k2.fill(0);
|
|
55656
55675
|
i2 = 0;
|
|
55657
55676
|
};
|
|
55658
|
-
const h2 = (...
|
|
55659
|
-
const reseed = (seed =
|
|
55660
|
-
k2 = h2(
|
|
55677
|
+
const h2 = (...b2) => hmacFn(k2, v2, ...b2);
|
|
55678
|
+
const reseed = (seed = u8n(0)) => {
|
|
55679
|
+
k2 = h2(u8of(0), seed);
|
|
55661
55680
|
v2 = h2();
|
|
55662
55681
|
if (seed.length === 0)
|
|
55663
55682
|
return;
|
|
55664
|
-
k2 = h2(
|
|
55683
|
+
k2 = h2(u8of(1), seed);
|
|
55665
55684
|
v2 = h2();
|
|
55666
55685
|
};
|
|
55667
55686
|
const gen = () => {
|
|
55668
|
-
if (i2++ >=
|
|
55669
|
-
throw new Error("drbg: tried
|
|
55687
|
+
if (i2++ >= 1e3)
|
|
55688
|
+
throw new Error("drbg: tried 1000 values");
|
|
55670
55689
|
let len = 0;
|
|
55671
55690
|
const out = [];
|
|
55672
55691
|
while (len < qByteLen) {
|
|
@@ -55688,7 +55707,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
55688
55707
|
};
|
|
55689
55708
|
return genUntil;
|
|
55690
55709
|
}
|
|
55691
|
-
function
|
|
55710
|
+
function isHash(val) {
|
|
55711
|
+
return typeof val === "function" && Number.isSafeInteger(val.outputLen);
|
|
55712
|
+
}
|
|
55713
|
+
function _validateObject(object3, fields, optFields = {}) {
|
|
55692
55714
|
if (!object3 || typeof object3 !== "object")
|
|
55693
55715
|
throw new Error("expected valid options object");
|
|
55694
55716
|
function checkField(fieldName, expectedType, isOpt) {
|
|
@@ -55699,9 +55721,8 @@ function validateObject2(object3, fields = {}, optFields = {}) {
|
|
|
55699
55721
|
if (current !== expectedType || val === null)
|
|
55700
55722
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
55701
55723
|
}
|
|
55702
|
-
|
|
55703
|
-
|
|
55704
|
-
iter(optFields, true);
|
|
55724
|
+
Object.entries(fields).forEach(([k2, v2]) => checkField(k2, v2, false));
|
|
55725
|
+
Object.entries(optFields).forEach(([k2, v2]) => checkField(k2, v2, true));
|
|
55705
55726
|
}
|
|
55706
55727
|
function memoized(fn) {
|
|
55707
55728
|
const map2 = /* @__PURE__ */ new WeakMap();
|
|
@@ -55716,7 +55737,7 @@ function memoized(fn) {
|
|
|
55716
55737
|
}
|
|
55717
55738
|
var _0n2, _1n2, isPosBig, bitMask, notImplemented;
|
|
55718
55739
|
var init_utils3 = __esm({
|
|
55719
|
-
"
|
|
55740
|
+
"../../node_modules/@noble/curves/esm/utils.js"() {
|
|
55720
55741
|
init_utils2();
|
|
55721
55742
|
init_utils2();
|
|
55722
55743
|
_0n2 = /* @__PURE__ */ BigInt(0);
|
|
@@ -55729,7 +55750,7 @@ var init_utils3 = __esm({
|
|
|
55729
55750
|
}
|
|
55730
55751
|
});
|
|
55731
55752
|
|
|
55732
|
-
//
|
|
55753
|
+
// ../../node_modules/@noble/curves/esm/abstract/modular.js
|
|
55733
55754
|
function mod3(a2, b2) {
|
|
55734
55755
|
const result = a2 % b2;
|
|
55735
55756
|
return result >= _0n3 ? result : b2 + result;
|
|
@@ -55865,6 +55886,7 @@ function FpSqrt(P2) {
|
|
|
55865
55886
|
function validateField(field) {
|
|
55866
55887
|
const initial = {
|
|
55867
55888
|
ORDER: "bigint",
|
|
55889
|
+
MASK: "bigint",
|
|
55868
55890
|
BYTES: "number",
|
|
55869
55891
|
BITS: "number"
|
|
55870
55892
|
};
|
|
@@ -55872,7 +55894,7 @@ function validateField(field) {
|
|
|
55872
55894
|
map2[val] = "function";
|
|
55873
55895
|
return map2;
|
|
55874
55896
|
}, initial);
|
|
55875
|
-
|
|
55897
|
+
_validateObject(field, opts);
|
|
55876
55898
|
return field;
|
|
55877
55899
|
}
|
|
55878
55900
|
function FpPow(Fp3, num, power) {
|
|
@@ -55926,8 +55948,102 @@ function nLength(n2, nBitLength) {
|
|
|
55926
55948
|
const nByteLength = Math.ceil(_nBitLength / 8);
|
|
55927
55949
|
return { nBitLength: _nBitLength, nByteLength };
|
|
55928
55950
|
}
|
|
55929
|
-
function Field(ORDER, opts = {}) {
|
|
55930
|
-
|
|
55951
|
+
function Field(ORDER, bitLenOrOpts, isLE4 = false, opts = {}) {
|
|
55952
|
+
if (ORDER <= _0n3)
|
|
55953
|
+
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
|
55954
|
+
let _nbitLength = void 0;
|
|
55955
|
+
let _sqrt = void 0;
|
|
55956
|
+
let modFromBytes = false;
|
|
55957
|
+
let allowedLengths = void 0;
|
|
55958
|
+
if (typeof bitLenOrOpts === "object" && bitLenOrOpts != null) {
|
|
55959
|
+
if (opts.sqrt || isLE4)
|
|
55960
|
+
throw new Error("cannot specify opts in two arguments");
|
|
55961
|
+
const _opts = bitLenOrOpts;
|
|
55962
|
+
if (_opts.BITS)
|
|
55963
|
+
_nbitLength = _opts.BITS;
|
|
55964
|
+
if (_opts.sqrt)
|
|
55965
|
+
_sqrt = _opts.sqrt;
|
|
55966
|
+
if (typeof _opts.isLE === "boolean")
|
|
55967
|
+
isLE4 = _opts.isLE;
|
|
55968
|
+
if (typeof _opts.modFromBytes === "boolean")
|
|
55969
|
+
modFromBytes = _opts.modFromBytes;
|
|
55970
|
+
allowedLengths = _opts.allowedLengths;
|
|
55971
|
+
} else {
|
|
55972
|
+
if (typeof bitLenOrOpts === "number")
|
|
55973
|
+
_nbitLength = bitLenOrOpts;
|
|
55974
|
+
if (opts.sqrt)
|
|
55975
|
+
_sqrt = opts.sqrt;
|
|
55976
|
+
}
|
|
55977
|
+
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, _nbitLength);
|
|
55978
|
+
if (BYTES > 2048)
|
|
55979
|
+
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
55980
|
+
let sqrtP;
|
|
55981
|
+
const f2 = Object.freeze({
|
|
55982
|
+
ORDER,
|
|
55983
|
+
isLE: isLE4,
|
|
55984
|
+
BITS,
|
|
55985
|
+
BYTES,
|
|
55986
|
+
MASK: bitMask(BITS),
|
|
55987
|
+
ZERO: _0n3,
|
|
55988
|
+
ONE: _1n3,
|
|
55989
|
+
allowedLengths,
|
|
55990
|
+
create: (num) => mod3(num, ORDER),
|
|
55991
|
+
isValid: (num) => {
|
|
55992
|
+
if (typeof num !== "bigint")
|
|
55993
|
+
throw new Error("invalid field element: expected bigint, got " + typeof num);
|
|
55994
|
+
return _0n3 <= num && num < ORDER;
|
|
55995
|
+
},
|
|
55996
|
+
is0: (num) => num === _0n3,
|
|
55997
|
+
// is valid and invertible
|
|
55998
|
+
isValidNot0: (num) => !f2.is0(num) && f2.isValid(num),
|
|
55999
|
+
isOdd: (num) => (num & _1n3) === _1n3,
|
|
56000
|
+
neg: (num) => mod3(-num, ORDER),
|
|
56001
|
+
eql: (lhs, rhs) => lhs === rhs,
|
|
56002
|
+
sqr: (num) => mod3(num * num, ORDER),
|
|
56003
|
+
add: (lhs, rhs) => mod3(lhs + rhs, ORDER),
|
|
56004
|
+
sub: (lhs, rhs) => mod3(lhs - rhs, ORDER),
|
|
56005
|
+
mul: (lhs, rhs) => mod3(lhs * rhs, ORDER),
|
|
56006
|
+
pow: (num, power) => FpPow(f2, num, power),
|
|
56007
|
+
div: (lhs, rhs) => mod3(lhs * invert(rhs, ORDER), ORDER),
|
|
56008
|
+
// Same as above, but doesn't normalize
|
|
56009
|
+
sqrN: (num) => num * num,
|
|
56010
|
+
addN: (lhs, rhs) => lhs + rhs,
|
|
56011
|
+
subN: (lhs, rhs) => lhs - rhs,
|
|
56012
|
+
mulN: (lhs, rhs) => lhs * rhs,
|
|
56013
|
+
inv: (num) => invert(num, ORDER),
|
|
56014
|
+
sqrt: _sqrt || ((n2) => {
|
|
56015
|
+
if (!sqrtP)
|
|
56016
|
+
sqrtP = FpSqrt(ORDER);
|
|
56017
|
+
return sqrtP(f2, n2);
|
|
56018
|
+
}),
|
|
56019
|
+
toBytes: (num) => isLE4 ? numberToBytesLE2(num, BYTES) : numberToBytesBE2(num, BYTES),
|
|
56020
|
+
fromBytes: (bytes, skipValidation = true) => {
|
|
56021
|
+
if (allowedLengths) {
|
|
56022
|
+
if (!allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
|
|
56023
|
+
throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
|
|
56024
|
+
}
|
|
56025
|
+
const padded = new Uint8Array(BYTES);
|
|
56026
|
+
padded.set(bytes, isLE4 ? 0 : padded.length - bytes.length);
|
|
56027
|
+
bytes = padded;
|
|
56028
|
+
}
|
|
56029
|
+
if (bytes.length !== BYTES)
|
|
56030
|
+
throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
|
|
56031
|
+
let scalar = isLE4 ? bytesToNumberLE2(bytes) : bytesToNumberBE(bytes);
|
|
56032
|
+
if (modFromBytes)
|
|
56033
|
+
scalar = mod3(scalar, ORDER);
|
|
56034
|
+
if (!skipValidation) {
|
|
56035
|
+
if (!f2.isValid(scalar))
|
|
56036
|
+
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
56037
|
+
}
|
|
56038
|
+
return scalar;
|
|
56039
|
+
},
|
|
56040
|
+
// TODO: we don't need it here, move out to separate fn
|
|
56041
|
+
invertBatch: (lst) => FpInvertBatch(f2, lst),
|
|
56042
|
+
// We can't move this out because Fp6, Fp12 implement it
|
|
56043
|
+
// and it's unclear what to return in there.
|
|
56044
|
+
cmov: (a2, b2, c2) => c2 ? b2 : a2
|
|
56045
|
+
});
|
|
56046
|
+
return Object.freeze(f2);
|
|
55931
56047
|
}
|
|
55932
56048
|
function FpSqrtEven(Fp3, elm) {
|
|
55933
56049
|
if (!Fp3.isOdd)
|
|
@@ -55946,7 +56062,6 @@ function getMinHashLength(fieldOrder) {
|
|
|
55946
56062
|
return length + Math.ceil(length / 2);
|
|
55947
56063
|
}
|
|
55948
56064
|
function mapHashToField(key, fieldOrder, isLE4 = false) {
|
|
55949
|
-
abytes3(key);
|
|
55950
56065
|
const len = key.length;
|
|
55951
56066
|
const fieldLen = getFieldBytesLength(fieldOrder);
|
|
55952
56067
|
const minLen = getMinHashLength(fieldOrder);
|
|
@@ -55956,12 +56071,12 @@ function mapHashToField(key, fieldOrder, isLE4 = false) {
|
|
|
55956
56071
|
const reduced = mod3(num, fieldOrder - _1n3) + _1n3;
|
|
55957
56072
|
return isLE4 ? numberToBytesLE2(reduced, fieldLen) : numberToBytesBE2(reduced, fieldLen);
|
|
55958
56073
|
}
|
|
55959
|
-
var _0n3, _1n3, _2n2, _3n, _4n, _5n, _7n2, _8n, _9n, _16n, isNegativeLE, FIELD_FIELDS
|
|
56074
|
+
var _0n3, _1n3, _2n2, _3n, _4n, _5n, _7n2, _8n, _9n, _16n, isNegativeLE, FIELD_FIELDS;
|
|
55960
56075
|
var init_modular2 = __esm({
|
|
55961
|
-
"
|
|
56076
|
+
"../../node_modules/@noble/curves/esm/abstract/modular.js"() {
|
|
55962
56077
|
init_utils3();
|
|
55963
|
-
_0n3 =
|
|
55964
|
-
_1n3 =
|
|
56078
|
+
_0n3 = BigInt(0);
|
|
56079
|
+
_1n3 = BigInt(1);
|
|
55965
56080
|
_2n2 = /* @__PURE__ */ BigInt(2);
|
|
55966
56081
|
_3n = /* @__PURE__ */ BigInt(3);
|
|
55967
56082
|
_4n = /* @__PURE__ */ BigInt(4);
|
|
@@ -55990,145 +56105,10 @@ var init_modular2 = __esm({
|
|
|
55990
56105
|
"mulN",
|
|
55991
56106
|
"sqrN"
|
|
55992
56107
|
];
|
|
55993
|
-
_Field = class {
|
|
55994
|
-
ORDER;
|
|
55995
|
-
BITS;
|
|
55996
|
-
BYTES;
|
|
55997
|
-
isLE;
|
|
55998
|
-
ZERO = _0n3;
|
|
55999
|
-
ONE = _1n3;
|
|
56000
|
-
_lengths;
|
|
56001
|
-
_sqrt;
|
|
56002
|
-
// cached sqrt
|
|
56003
|
-
_mod;
|
|
56004
|
-
constructor(ORDER, opts = {}) {
|
|
56005
|
-
if (ORDER <= _0n3)
|
|
56006
|
-
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
|
56007
|
-
let _nbitLength = void 0;
|
|
56008
|
-
this.isLE = false;
|
|
56009
|
-
if (opts != null && typeof opts === "object") {
|
|
56010
|
-
if (typeof opts.BITS === "number")
|
|
56011
|
-
_nbitLength = opts.BITS;
|
|
56012
|
-
if (typeof opts.sqrt === "function")
|
|
56013
|
-
this.sqrt = opts.sqrt;
|
|
56014
|
-
if (typeof opts.isLE === "boolean")
|
|
56015
|
-
this.isLE = opts.isLE;
|
|
56016
|
-
if (opts.allowedLengths)
|
|
56017
|
-
this._lengths = opts.allowedLengths?.slice();
|
|
56018
|
-
if (typeof opts.modFromBytes === "boolean")
|
|
56019
|
-
this._mod = opts.modFromBytes;
|
|
56020
|
-
}
|
|
56021
|
-
const { nBitLength, nByteLength } = nLength(ORDER, _nbitLength);
|
|
56022
|
-
if (nByteLength > 2048)
|
|
56023
|
-
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
56024
|
-
this.ORDER = ORDER;
|
|
56025
|
-
this.BITS = nBitLength;
|
|
56026
|
-
this.BYTES = nByteLength;
|
|
56027
|
-
this._sqrt = void 0;
|
|
56028
|
-
Object.preventExtensions(this);
|
|
56029
|
-
}
|
|
56030
|
-
create(num) {
|
|
56031
|
-
return mod3(num, this.ORDER);
|
|
56032
|
-
}
|
|
56033
|
-
isValid(num) {
|
|
56034
|
-
if (typeof num !== "bigint")
|
|
56035
|
-
throw new Error("invalid field element: expected bigint, got " + typeof num);
|
|
56036
|
-
return _0n3 <= num && num < this.ORDER;
|
|
56037
|
-
}
|
|
56038
|
-
is0(num) {
|
|
56039
|
-
return num === _0n3;
|
|
56040
|
-
}
|
|
56041
|
-
// is valid and invertible
|
|
56042
|
-
isValidNot0(num) {
|
|
56043
|
-
return !this.is0(num) && this.isValid(num);
|
|
56044
|
-
}
|
|
56045
|
-
isOdd(num) {
|
|
56046
|
-
return (num & _1n3) === _1n3;
|
|
56047
|
-
}
|
|
56048
|
-
neg(num) {
|
|
56049
|
-
return mod3(-num, this.ORDER);
|
|
56050
|
-
}
|
|
56051
|
-
eql(lhs, rhs) {
|
|
56052
|
-
return lhs === rhs;
|
|
56053
|
-
}
|
|
56054
|
-
sqr(num) {
|
|
56055
|
-
return mod3(num * num, this.ORDER);
|
|
56056
|
-
}
|
|
56057
|
-
add(lhs, rhs) {
|
|
56058
|
-
return mod3(lhs + rhs, this.ORDER);
|
|
56059
|
-
}
|
|
56060
|
-
sub(lhs, rhs) {
|
|
56061
|
-
return mod3(lhs - rhs, this.ORDER);
|
|
56062
|
-
}
|
|
56063
|
-
mul(lhs, rhs) {
|
|
56064
|
-
return mod3(lhs * rhs, this.ORDER);
|
|
56065
|
-
}
|
|
56066
|
-
pow(num, power) {
|
|
56067
|
-
return FpPow(this, num, power);
|
|
56068
|
-
}
|
|
56069
|
-
div(lhs, rhs) {
|
|
56070
|
-
return mod3(lhs * invert(rhs, this.ORDER), this.ORDER);
|
|
56071
|
-
}
|
|
56072
|
-
// Same as above, but doesn't normalize
|
|
56073
|
-
sqrN(num) {
|
|
56074
|
-
return num * num;
|
|
56075
|
-
}
|
|
56076
|
-
addN(lhs, rhs) {
|
|
56077
|
-
return lhs + rhs;
|
|
56078
|
-
}
|
|
56079
|
-
subN(lhs, rhs) {
|
|
56080
|
-
return lhs - rhs;
|
|
56081
|
-
}
|
|
56082
|
-
mulN(lhs, rhs) {
|
|
56083
|
-
return lhs * rhs;
|
|
56084
|
-
}
|
|
56085
|
-
inv(num) {
|
|
56086
|
-
return invert(num, this.ORDER);
|
|
56087
|
-
}
|
|
56088
|
-
sqrt(num) {
|
|
56089
|
-
if (!this._sqrt)
|
|
56090
|
-
this._sqrt = FpSqrt(this.ORDER);
|
|
56091
|
-
return this._sqrt(this, num);
|
|
56092
|
-
}
|
|
56093
|
-
toBytes(num) {
|
|
56094
|
-
return this.isLE ? numberToBytesLE2(num, this.BYTES) : numberToBytesBE2(num, this.BYTES);
|
|
56095
|
-
}
|
|
56096
|
-
fromBytes(bytes, skipValidation = false) {
|
|
56097
|
-
abytes3(bytes);
|
|
56098
|
-
const { _lengths: allowedLengths, BYTES, isLE: isLE4, ORDER, _mod: modFromBytes } = this;
|
|
56099
|
-
if (allowedLengths) {
|
|
56100
|
-
if (!allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
|
|
56101
|
-
throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
|
|
56102
|
-
}
|
|
56103
|
-
const padded = new Uint8Array(BYTES);
|
|
56104
|
-
padded.set(bytes, isLE4 ? 0 : padded.length - bytes.length);
|
|
56105
|
-
bytes = padded;
|
|
56106
|
-
}
|
|
56107
|
-
if (bytes.length !== BYTES)
|
|
56108
|
-
throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
|
|
56109
|
-
let scalar = isLE4 ? bytesToNumberLE2(bytes) : bytesToNumberBE(bytes);
|
|
56110
|
-
if (modFromBytes)
|
|
56111
|
-
scalar = mod3(scalar, ORDER);
|
|
56112
|
-
if (!skipValidation) {
|
|
56113
|
-
if (!this.isValid(scalar))
|
|
56114
|
-
throw new Error("invalid field element: outside of range 0..ORDER");
|
|
56115
|
-
}
|
|
56116
|
-
return scalar;
|
|
56117
|
-
}
|
|
56118
|
-
// TODO: we don't need it here, move out to separate fn
|
|
56119
|
-
invertBatch(lst) {
|
|
56120
|
-
return FpInvertBatch(this, lst);
|
|
56121
|
-
}
|
|
56122
|
-
// We can't move this out because Fp6, Fp12 implement it
|
|
56123
|
-
// and it's unclear what to return in there.
|
|
56124
|
-
cmov(a2, b2, condition) {
|
|
56125
|
-
return condition ? b2 : a2;
|
|
56126
|
-
}
|
|
56127
|
-
};
|
|
56128
56108
|
}
|
|
56129
56109
|
});
|
|
56130
56110
|
|
|
56131
|
-
//
|
|
56111
|
+
// ../../node_modules/@noble/curves/esm/abstract/curve.js
|
|
56132
56112
|
function negateCt(condition, item) {
|
|
56133
56113
|
const neg = item.negate();
|
|
56134
56114
|
return condition ? neg : item;
|
|
@@ -56204,8 +56184,7 @@ function mulEndoUnsafe(Point, point, k1, k2) {
|
|
|
56204
56184
|
}
|
|
56205
56185
|
return { p1, p2 };
|
|
56206
56186
|
}
|
|
56207
|
-
function pippenger(c2, points, scalars) {
|
|
56208
|
-
const fieldN = c2.Fn;
|
|
56187
|
+
function pippenger(c2, fieldN, points, scalars) {
|
|
56209
56188
|
validateMSMPoints(points, c2);
|
|
56210
56189
|
validateMSMScalars(scalars, fieldN);
|
|
56211
56190
|
const plength = points.length;
|
|
@@ -56254,7 +56233,7 @@ function createField(order, field, isLE4) {
|
|
|
56254
56233
|
return Field(order, { isLE: isLE4 });
|
|
56255
56234
|
}
|
|
56256
56235
|
}
|
|
56257
|
-
function
|
|
56236
|
+
function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
|
|
56258
56237
|
if (FpFnLE === void 0)
|
|
56259
56238
|
FpFnLE = type === "edwards";
|
|
56260
56239
|
if (!CURVE || typeof CURVE !== "object")
|
|
@@ -56275,26 +56254,16 @@ function createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
|
|
|
56275
56254
|
CURVE = Object.freeze(Object.assign({}, CURVE));
|
|
56276
56255
|
return { CURVE, Fp: Fp3, Fn: Fn3 };
|
|
56277
56256
|
}
|
|
56278
|
-
function createKeygen2(randomSecretKey, getPublicKey) {
|
|
56279
|
-
return function keygen(seed) {
|
|
56280
|
-
const secretKey = randomSecretKey(seed);
|
|
56281
|
-
return { secretKey, publicKey: getPublicKey(secretKey) };
|
|
56282
|
-
};
|
|
56283
|
-
}
|
|
56284
56257
|
var _0n4, _1n4, pointPrecomputes, pointWindowSizes, wNAF;
|
|
56285
56258
|
var init_curve2 = __esm({
|
|
56286
|
-
"
|
|
56259
|
+
"../../node_modules/@noble/curves/esm/abstract/curve.js"() {
|
|
56287
56260
|
init_utils3();
|
|
56288
56261
|
init_modular2();
|
|
56289
|
-
_0n4 =
|
|
56290
|
-
_1n4 =
|
|
56262
|
+
_0n4 = BigInt(0);
|
|
56263
|
+
_1n4 = BigInt(1);
|
|
56291
56264
|
pointPrecomputes = /* @__PURE__ */ new WeakMap();
|
|
56292
56265
|
pointWindowSizes = /* @__PURE__ */ new WeakMap();
|
|
56293
56266
|
wNAF = class {
|
|
56294
|
-
BASE;
|
|
56295
|
-
ZERO;
|
|
56296
|
-
Fn;
|
|
56297
|
-
bits;
|
|
56298
56267
|
// Parametrized with a given Point class (not individual point)
|
|
56299
56268
|
constructor(Point, bits) {
|
|
56300
56269
|
this.BASE = Point.BASE;
|
|
@@ -56424,7 +56393,7 @@ var init_curve2 = __esm({
|
|
|
56424
56393
|
}
|
|
56425
56394
|
});
|
|
56426
56395
|
|
|
56427
|
-
//
|
|
56396
|
+
// ../../node_modules/@noble/curves/esm/abstract/edwards.js
|
|
56428
56397
|
function isEdValidXY(Fp3, CURVE, x2, y2) {
|
|
56429
56398
|
const x22 = Fp3.sqr(x2);
|
|
56430
56399
|
const y22 = Fp3.sqr(y2);
|
|
@@ -56433,11 +56402,11 @@ function isEdValidXY(Fp3, CURVE, x2, y2) {
|
|
|
56433
56402
|
return Fp3.eql(left2, right2);
|
|
56434
56403
|
}
|
|
56435
56404
|
function edwards(params, extraOpts = {}) {
|
|
56436
|
-
const validated =
|
|
56405
|
+
const validated = _createCurveFields("edwards", params, extraOpts, extraOpts.FpFnLE);
|
|
56437
56406
|
const { Fp: Fp3, Fn: Fn3 } = validated;
|
|
56438
56407
|
let CURVE = validated.CURVE;
|
|
56439
56408
|
const { h: cofactor } = CURVE;
|
|
56440
|
-
|
|
56409
|
+
_validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
56441
56410
|
const MASK = _2n3 << BigInt(Fn3.BYTES * 8) - _1n5;
|
|
56442
56411
|
const modP = (n2) => Fp3.create(n2);
|
|
56443
56412
|
const uvRatio3 = extraOpts.uvRatio || ((u2, v2) => {
|
|
@@ -56454,9 +56423,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
56454
56423
|
aInRange2("coordinate " + title, n2, min, MASK);
|
|
56455
56424
|
return n2;
|
|
56456
56425
|
}
|
|
56457
|
-
function
|
|
56426
|
+
function aextpoint(other) {
|
|
56458
56427
|
if (!(other instanceof Point))
|
|
56459
|
-
throw new Error("
|
|
56428
|
+
throw new Error("ExtendedPoint expected");
|
|
56460
56429
|
}
|
|
56461
56430
|
const toAffineMemo = memoized((p2, iz) => {
|
|
56462
56431
|
const { X: X2, Y: Y2, Z: Z2 } = p2;
|
|
@@ -56493,19 +56462,6 @@ function edwards(params, extraOpts = {}) {
|
|
|
56493
56462
|
return true;
|
|
56494
56463
|
});
|
|
56495
56464
|
class Point {
|
|
56496
|
-
// base / generator point
|
|
56497
|
-
static BASE = new Point(CURVE.Gx, CURVE.Gy, _1n5, modP(CURVE.Gx * CURVE.Gy));
|
|
56498
|
-
// zero / infinity / identity point
|
|
56499
|
-
static ZERO = new Point(_0n5, _1n5, _1n5, _0n5);
|
|
56500
|
-
// 0, 1, 1, 0
|
|
56501
|
-
// math field
|
|
56502
|
-
static Fp = Fp3;
|
|
56503
|
-
// scalar field
|
|
56504
|
-
static Fn = Fn3;
|
|
56505
|
-
X;
|
|
56506
|
-
Y;
|
|
56507
|
-
Z;
|
|
56508
|
-
T;
|
|
56509
56465
|
constructor(X2, Y2, Z2, T2) {
|
|
56510
56466
|
this.X = acoord("x", X2);
|
|
56511
56467
|
this.Y = acoord("y", Y2);
|
|
@@ -56528,8 +56484,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
56528
56484
|
static fromBytes(bytes, zip215 = false) {
|
|
56529
56485
|
const len = Fp3.BYTES;
|
|
56530
56486
|
const { a: a2, d: d2 } = CURVE;
|
|
56531
|
-
bytes = copyBytes3(
|
|
56532
|
-
|
|
56487
|
+
bytes = copyBytes3(_abytes2(bytes, len, "point"));
|
|
56488
|
+
_abool2(zip215, "zip215");
|
|
56533
56489
|
const normed = copyBytes3(bytes);
|
|
56534
56490
|
const lastByte = bytes[len - 1];
|
|
56535
56491
|
normed[len - 1] = lastByte & ~128;
|
|
@@ -56550,8 +56506,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
56550
56506
|
x2 = modP(-x2);
|
|
56551
56507
|
return Point.fromAffine({ x: x2, y: y2 });
|
|
56552
56508
|
}
|
|
56553
|
-
static fromHex(
|
|
56554
|
-
return Point.fromBytes(
|
|
56509
|
+
static fromHex(bytes, zip215 = false) {
|
|
56510
|
+
return Point.fromBytes(ensureBytes("point", bytes), zip215);
|
|
56555
56511
|
}
|
|
56556
56512
|
get x() {
|
|
56557
56513
|
return this.toAffine().x;
|
|
@@ -56571,7 +56527,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
56571
56527
|
}
|
|
56572
56528
|
// Compare one point to another.
|
|
56573
56529
|
equals(other) {
|
|
56574
|
-
|
|
56530
|
+
aextpoint(other);
|
|
56575
56531
|
const { X: X1, Y: Y1, Z: Z1 } = this;
|
|
56576
56532
|
const { X: X2, Y: Y2, Z: Z2 } = other;
|
|
56577
56533
|
const X1Z2 = modP(X1 * Z2);
|
|
@@ -56611,7 +56567,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
56611
56567
|
// https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
|
|
56612
56568
|
// Cost: 9M + 1*a + 1*d + 7add.
|
|
56613
56569
|
add(other) {
|
|
56614
|
-
|
|
56570
|
+
aextpoint(other);
|
|
56615
56571
|
const { a: a2, d: d2 } = CURVE;
|
|
56616
56572
|
const { X: X1, Y: Y1, Z: Z1, T: T1 } = this;
|
|
56617
56573
|
const { X: X2, Y: Y2, Z: Z2, T: T2 } = other;
|
|
@@ -56687,7 +56643,36 @@ function edwards(params, extraOpts = {}) {
|
|
|
56687
56643
|
toString() {
|
|
56688
56644
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
56689
56645
|
}
|
|
56646
|
+
// TODO: remove
|
|
56647
|
+
get ex() {
|
|
56648
|
+
return this.X;
|
|
56649
|
+
}
|
|
56650
|
+
get ey() {
|
|
56651
|
+
return this.Y;
|
|
56652
|
+
}
|
|
56653
|
+
get ez() {
|
|
56654
|
+
return this.Z;
|
|
56655
|
+
}
|
|
56656
|
+
get et() {
|
|
56657
|
+
return this.T;
|
|
56658
|
+
}
|
|
56659
|
+
static normalizeZ(points) {
|
|
56660
|
+
return normalizeZ(Point, points);
|
|
56661
|
+
}
|
|
56662
|
+
static msm(points, scalars) {
|
|
56663
|
+
return pippenger(Point, Fn3, points, scalars);
|
|
56664
|
+
}
|
|
56665
|
+
_setWindowSize(windowSize) {
|
|
56666
|
+
this.precompute(windowSize);
|
|
56667
|
+
}
|
|
56668
|
+
toRawBytes() {
|
|
56669
|
+
return this.toBytes();
|
|
56670
|
+
}
|
|
56690
56671
|
}
|
|
56672
|
+
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n5, modP(CURVE.Gx * CURVE.Gy));
|
|
56673
|
+
Point.ZERO = new Point(_0n5, _1n5, _1n5, _0n5);
|
|
56674
|
+
Point.Fp = Fp3;
|
|
56675
|
+
Point.Fn = Fn3;
|
|
56691
56676
|
const wnaf = new wNAF(Point, Fn3.BITS);
|
|
56692
56677
|
Point.BASE.precompute(8);
|
|
56693
56678
|
return Point;
|
|
@@ -56695,7 +56680,7 @@ function edwards(params, extraOpts = {}) {
|
|
|
56695
56680
|
function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
56696
56681
|
if (typeof cHash !== "function")
|
|
56697
56682
|
throw new Error('"hash" function param is required');
|
|
56698
|
-
|
|
56683
|
+
_validateObject(eddsaOpts, {}, {
|
|
56699
56684
|
adjustScalarBytes: "function",
|
|
56700
56685
|
randomBytes: "function",
|
|
56701
56686
|
domain: "function",
|
|
@@ -56707,7 +56692,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56707
56692
|
const randomBytes3 = eddsaOpts.randomBytes || randomBytes2;
|
|
56708
56693
|
const adjustScalarBytes3 = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
|
|
56709
56694
|
const domain2 = eddsaOpts.domain || ((data, ctx, phflag) => {
|
|
56710
|
-
|
|
56695
|
+
_abool2(phflag, "phflag");
|
|
56711
56696
|
if (ctx.length || phflag)
|
|
56712
56697
|
throw new Error("Contexts/pre-hash are not supported");
|
|
56713
56698
|
return data;
|
|
@@ -56717,8 +56702,8 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56717
56702
|
}
|
|
56718
56703
|
function getPrivateScalar(key) {
|
|
56719
56704
|
const len = lengths.secretKey;
|
|
56720
|
-
|
|
56721
|
-
const hashed =
|
|
56705
|
+
key = ensureBytes("private key", key, len);
|
|
56706
|
+
const hashed = ensureBytes("hashed private key", cHash(key), 2 * len);
|
|
56722
56707
|
const head = adjustScalarBytes3(hashed.slice(0, len));
|
|
56723
56708
|
const prefix = hashed.slice(len, 2 * len);
|
|
56724
56709
|
const scalar = modN_LE(head);
|
|
@@ -56735,10 +56720,10 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56735
56720
|
}
|
|
56736
56721
|
function hashDomainToScalar(context = Uint8Array.of(), ...msgs) {
|
|
56737
56722
|
const msg = concatBytes2(...msgs);
|
|
56738
|
-
return modN_LE(cHash(domain2(msg,
|
|
56723
|
+
return modN_LE(cHash(domain2(msg, ensureBytes("context", context), !!prehash)));
|
|
56739
56724
|
}
|
|
56740
56725
|
function sign(msg, secretKey, options = {}) {
|
|
56741
|
-
msg =
|
|
56726
|
+
msg = ensureBytes("message", msg);
|
|
56742
56727
|
if (prehash)
|
|
56743
56728
|
msg = prehash(msg);
|
|
56744
56729
|
const { prefix, scalar, pointBytes } = getExtendedPublicKey(secretKey);
|
|
@@ -56749,17 +56734,17 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56749
56734
|
if (!Fn3.isValid(s2))
|
|
56750
56735
|
throw new Error("sign failed: invalid s");
|
|
56751
56736
|
const rs = concatBytes2(R2, Fn3.toBytes(s2));
|
|
56752
|
-
return
|
|
56737
|
+
return _abytes2(rs, lengths.signature, "result");
|
|
56753
56738
|
}
|
|
56754
56739
|
const verifyOpts = { zip215: true };
|
|
56755
56740
|
function verify(sig, msg, publicKey, options = verifyOpts) {
|
|
56756
56741
|
const { context, zip215 } = options;
|
|
56757
56742
|
const len = lengths.signature;
|
|
56758
|
-
sig =
|
|
56759
|
-
msg =
|
|
56760
|
-
publicKey =
|
|
56743
|
+
sig = ensureBytes("signature", sig, len);
|
|
56744
|
+
msg = ensureBytes("message", msg);
|
|
56745
|
+
publicKey = ensureBytes("publicKey", publicKey, lengths.publicKey);
|
|
56761
56746
|
if (zip215 !== void 0)
|
|
56762
|
-
|
|
56747
|
+
_abool2(zip215, "zip215");
|
|
56763
56748
|
if (prehash)
|
|
56764
56749
|
msg = prehash(msg);
|
|
56765
56750
|
const mid = len / 2;
|
|
@@ -56787,7 +56772,11 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56787
56772
|
seed: _size2
|
|
56788
56773
|
};
|
|
56789
56774
|
function randomSecretKey(seed = randomBytes3(lengths.seed)) {
|
|
56790
|
-
return
|
|
56775
|
+
return _abytes2(seed, lengths.seed, "seed");
|
|
56776
|
+
}
|
|
56777
|
+
function keygen(seed) {
|
|
56778
|
+
const secretKey = utils.randomSecretKey(seed);
|
|
56779
|
+
return { secretKey, publicKey: getPublicKey(secretKey) };
|
|
56791
56780
|
}
|
|
56792
56781
|
function isValidSecretKey(key) {
|
|
56793
56782
|
return isBytes3(key) && key.length === Fn3.BYTES;
|
|
@@ -56824,13 +56813,19 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56824
56813
|
},
|
|
56825
56814
|
toMontgomerySecret(secretKey) {
|
|
56826
56815
|
const size = lengths.secretKey;
|
|
56827
|
-
|
|
56816
|
+
_abytes2(secretKey, size);
|
|
56828
56817
|
const hashed = cHash(secretKey.subarray(0, size));
|
|
56829
56818
|
return adjustScalarBytes3(hashed).subarray(0, size);
|
|
56819
|
+
},
|
|
56820
|
+
/** @deprecated */
|
|
56821
|
+
randomPrivateKey: randomSecretKey,
|
|
56822
|
+
/** @deprecated */
|
|
56823
|
+
precompute(windowSize = 8, point = Point.BASE) {
|
|
56824
|
+
return point.precompute(windowSize, false);
|
|
56830
56825
|
}
|
|
56831
56826
|
};
|
|
56832
56827
|
return Object.freeze({
|
|
56833
|
-
keygen
|
|
56828
|
+
keygen,
|
|
56834
56829
|
getPublicKey,
|
|
56835
56830
|
sign,
|
|
56836
56831
|
verify,
|
|
@@ -56839,21 +56834,55 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
|
|
|
56839
56834
|
lengths
|
|
56840
56835
|
});
|
|
56841
56836
|
}
|
|
56837
|
+
function _eddsa_legacy_opts_to_new(c2) {
|
|
56838
|
+
const CURVE = {
|
|
56839
|
+
a: c2.a,
|
|
56840
|
+
d: c2.d,
|
|
56841
|
+
p: c2.Fp.ORDER,
|
|
56842
|
+
n: c2.n,
|
|
56843
|
+
h: c2.h,
|
|
56844
|
+
Gx: c2.Gx,
|
|
56845
|
+
Gy: c2.Gy
|
|
56846
|
+
};
|
|
56847
|
+
const Fp3 = c2.Fp;
|
|
56848
|
+
const Fn3 = Field(CURVE.n, c2.nBitLength, true);
|
|
56849
|
+
const curveOpts = { Fp: Fp3, Fn: Fn3, uvRatio: c2.uvRatio };
|
|
56850
|
+
const eddsaOpts = {
|
|
56851
|
+
randomBytes: c2.randomBytes,
|
|
56852
|
+
adjustScalarBytes: c2.adjustScalarBytes,
|
|
56853
|
+
domain: c2.domain,
|
|
56854
|
+
prehash: c2.prehash,
|
|
56855
|
+
mapToCurve: c2.mapToCurve
|
|
56856
|
+
};
|
|
56857
|
+
return { CURVE, curveOpts, hash: c2.hash, eddsaOpts };
|
|
56858
|
+
}
|
|
56859
|
+
function _eddsa_new_output_to_legacy(c2, eddsa2) {
|
|
56860
|
+
const Point = eddsa2.Point;
|
|
56861
|
+
const legacy = Object.assign({}, eddsa2, {
|
|
56862
|
+
ExtendedPoint: Point,
|
|
56863
|
+
CURVE: c2,
|
|
56864
|
+
nBitLength: Point.Fn.BITS,
|
|
56865
|
+
nByteLength: Point.Fn.BYTES
|
|
56866
|
+
});
|
|
56867
|
+
return legacy;
|
|
56868
|
+
}
|
|
56869
|
+
function twistedEdwards(c2) {
|
|
56870
|
+
const { CURVE, curveOpts, hash: hash2, eddsaOpts } = _eddsa_legacy_opts_to_new(c2);
|
|
56871
|
+
const Point = edwards(CURVE, curveOpts);
|
|
56872
|
+
const EDDSA = eddsa(Point, hash2, eddsaOpts);
|
|
56873
|
+
return _eddsa_new_output_to_legacy(c2, EDDSA);
|
|
56874
|
+
}
|
|
56842
56875
|
var _0n5, _1n5, _2n3, _8n2, PrimeEdwardsPoint;
|
|
56843
56876
|
var init_edwards = __esm({
|
|
56844
|
-
"
|
|
56877
|
+
"../../node_modules/@noble/curves/esm/abstract/edwards.js"() {
|
|
56845
56878
|
init_utils3();
|
|
56846
56879
|
init_curve2();
|
|
56880
|
+
init_modular2();
|
|
56847
56881
|
_0n5 = BigInt(0);
|
|
56848
56882
|
_1n5 = BigInt(1);
|
|
56849
56883
|
_2n3 = BigInt(2);
|
|
56850
56884
|
_8n2 = BigInt(8);
|
|
56851
56885
|
PrimeEdwardsPoint = class {
|
|
56852
|
-
static BASE;
|
|
56853
|
-
static ZERO;
|
|
56854
|
-
static Fp;
|
|
56855
|
-
static Fn;
|
|
56856
|
-
ep;
|
|
56857
56886
|
constructor(ep) {
|
|
56858
56887
|
this.ep = ep;
|
|
56859
56888
|
}
|
|
@@ -56915,14 +56944,18 @@ var init_edwards = __esm({
|
|
|
56915
56944
|
precompute(windowSize, isLazy) {
|
|
56916
56945
|
return this.init(this.ep.precompute(windowSize, isLazy));
|
|
56917
56946
|
}
|
|
56947
|
+
/** @deprecated use `toBytes` */
|
|
56948
|
+
toRawBytes() {
|
|
56949
|
+
return this.toBytes();
|
|
56950
|
+
}
|
|
56918
56951
|
};
|
|
56919
56952
|
}
|
|
56920
56953
|
});
|
|
56921
56954
|
|
|
56922
|
-
//
|
|
56955
|
+
// ../../node_modules/@noble/curves/esm/abstract/hash-to-curve.js
|
|
56923
56956
|
function i2osp(value, length) {
|
|
56924
|
-
|
|
56925
|
-
|
|
56957
|
+
anum(value);
|
|
56958
|
+
anum(length);
|
|
56926
56959
|
if (value < 0 || value >= 1 << 8 * length)
|
|
56927
56960
|
throw new Error("invalid I2OSP input: " + value);
|
|
56928
56961
|
const res = Array.from({ length }).fill(0);
|
|
@@ -56939,17 +56972,21 @@ function strxor(a2, b2) {
|
|
|
56939
56972
|
}
|
|
56940
56973
|
return arr;
|
|
56941
56974
|
}
|
|
56975
|
+
function anum(item) {
|
|
56976
|
+
if (!Number.isSafeInteger(item))
|
|
56977
|
+
throw new Error("number expected");
|
|
56978
|
+
}
|
|
56942
56979
|
function normDST(DST) {
|
|
56943
56980
|
if (!isBytes3(DST) && typeof DST !== "string")
|
|
56944
|
-
throw new Error("DST must be Uint8Array or
|
|
56945
|
-
return typeof DST === "string" ?
|
|
56981
|
+
throw new Error("DST must be Uint8Array or string");
|
|
56982
|
+
return typeof DST === "string" ? utf8ToBytes(DST) : DST;
|
|
56946
56983
|
}
|
|
56947
56984
|
function expand_message_xmd(msg, DST, lenInBytes, H2) {
|
|
56948
56985
|
abytes3(msg);
|
|
56949
|
-
|
|
56986
|
+
anum(lenInBytes);
|
|
56950
56987
|
DST = normDST(DST);
|
|
56951
56988
|
if (DST.length > 255)
|
|
56952
|
-
DST = H2(concatBytes2(
|
|
56989
|
+
DST = H2(concatBytes2(utf8ToBytes("H2C-OVERSIZE-DST-"), DST));
|
|
56953
56990
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H2;
|
|
56954
56991
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
|
56955
56992
|
if (lenInBytes > 65535 || ell > 255)
|
|
@@ -56969,27 +57006,28 @@ function expand_message_xmd(msg, DST, lenInBytes, H2) {
|
|
|
56969
57006
|
}
|
|
56970
57007
|
function expand_message_xof(msg, DST, lenInBytes, k2, H2) {
|
|
56971
57008
|
abytes3(msg);
|
|
56972
|
-
|
|
57009
|
+
anum(lenInBytes);
|
|
56973
57010
|
DST = normDST(DST);
|
|
56974
57011
|
if (DST.length > 255) {
|
|
56975
57012
|
const dkLen = Math.ceil(2 * k2 / 8);
|
|
56976
|
-
DST = H2.create({ dkLen }).update(
|
|
57013
|
+
DST = H2.create({ dkLen }).update(utf8ToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
|
|
56977
57014
|
}
|
|
56978
57015
|
if (lenInBytes > 65535 || DST.length > 255)
|
|
56979
57016
|
throw new Error("expand_message_xof: invalid lenInBytes");
|
|
56980
57017
|
return H2.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
|
|
56981
57018
|
}
|
|
56982
57019
|
function hash_to_field(msg, count, options) {
|
|
56983
|
-
|
|
57020
|
+
_validateObject(options, {
|
|
56984
57021
|
p: "bigint",
|
|
56985
57022
|
m: "number",
|
|
56986
57023
|
k: "number",
|
|
56987
57024
|
hash: "function"
|
|
56988
57025
|
});
|
|
56989
57026
|
const { p: p2, k: k2, m: m2, hash: hash2, expand, DST } = options;
|
|
56990
|
-
|
|
57027
|
+
if (!isHash(options.hash))
|
|
57028
|
+
throw new Error("expected valid hash");
|
|
56991
57029
|
abytes3(msg);
|
|
56992
|
-
|
|
57030
|
+
anum(count);
|
|
56993
57031
|
const log2p = p2.toString(2).length;
|
|
56994
57032
|
const L2 = Math.ceil((log2p + k2) / 8);
|
|
56995
57033
|
const len_in_bytes = count * m2 * L2;
|
|
@@ -57029,8 +57067,7 @@ function createHasher3(Point, mapToCurve, defaults) {
|
|
|
57029
57067
|
return P2;
|
|
57030
57068
|
}
|
|
57031
57069
|
return {
|
|
57032
|
-
defaults
|
|
57033
|
-
Point,
|
|
57070
|
+
defaults,
|
|
57034
57071
|
hashToCurve(msg, options) {
|
|
57035
57072
|
const opts = Object.assign({}, defaults, options);
|
|
57036
57073
|
const u2 = hash_to_field(msg, 2, opts);
|
|
@@ -57047,11 +57084,6 @@ function createHasher3(Point, mapToCurve, defaults) {
|
|
|
57047
57084
|
},
|
|
57048
57085
|
/** See {@link H2CHasher} */
|
|
57049
57086
|
mapToCurve(scalars) {
|
|
57050
|
-
if (defaults.m === 1) {
|
|
57051
|
-
if (typeof scalars !== "bigint")
|
|
57052
|
-
throw new Error("expected bigint (m=1)");
|
|
57053
|
-
return clear(map2([scalars]));
|
|
57054
|
-
}
|
|
57055
57087
|
if (!Array.isArray(scalars))
|
|
57056
57088
|
throw new Error("expected array of bigints");
|
|
57057
57089
|
for (const i2 of scalars)
|
|
@@ -57070,17 +57102,17 @@ function createHasher3(Point, mapToCurve, defaults) {
|
|
|
57070
57102
|
}
|
|
57071
57103
|
var os2ip, _DST_scalar;
|
|
57072
57104
|
var init_hash_to_curve = __esm({
|
|
57073
|
-
"
|
|
57105
|
+
"../../node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
|
|
57074
57106
|
init_utils3();
|
|
57075
57107
|
init_modular2();
|
|
57076
57108
|
os2ip = bytesToNumberBE;
|
|
57077
|
-
_DST_scalar =
|
|
57109
|
+
_DST_scalar = utf8ToBytes("HashToScalar-");
|
|
57078
57110
|
}
|
|
57079
57111
|
});
|
|
57080
57112
|
|
|
57081
|
-
//
|
|
57113
|
+
// ../../node_modules/@noble/curves/esm/abstract/montgomery.js
|
|
57082
57114
|
function validateOpts(curve) {
|
|
57083
|
-
|
|
57115
|
+
_validateObject(curve, {
|
|
57084
57116
|
adjustScalarBytes: "function",
|
|
57085
57117
|
powPminus2: "function"
|
|
57086
57118
|
});
|
|
@@ -57106,13 +57138,13 @@ function montgomery2(curveDef) {
|
|
|
57106
57138
|
return numberToBytesLE2(modP(u2), fieldLen);
|
|
57107
57139
|
}
|
|
57108
57140
|
function decodeU(u2) {
|
|
57109
|
-
const _u =
|
|
57141
|
+
const _u = ensureBytes("u coordinate", u2, fieldLen);
|
|
57110
57142
|
if (is25519)
|
|
57111
57143
|
_u[31] &= 127;
|
|
57112
57144
|
return modP(bytesToNumberLE2(_u));
|
|
57113
57145
|
}
|
|
57114
57146
|
function decodeScalar(scalar) {
|
|
57115
|
-
return bytesToNumberLE2(adjustScalarBytes3(
|
|
57147
|
+
return bytesToNumberLE2(adjustScalarBytes3(ensureBytes("scalar", scalar, fieldLen)));
|
|
57116
57148
|
}
|
|
57117
57149
|
function scalarMult(scalar, u2) {
|
|
57118
57150
|
const pu = montgomeryLadder(decodeU(u2), decodeScalar(scalar));
|
|
@@ -57123,8 +57155,6 @@ function montgomery2(curveDef) {
|
|
|
57123
57155
|
function scalarMultBase(scalar) {
|
|
57124
57156
|
return scalarMult(scalar, GuBytes);
|
|
57125
57157
|
}
|
|
57126
|
-
const getPublicKey = scalarMultBase;
|
|
57127
|
-
const getSharedSecret = scalarMult;
|
|
57128
57158
|
function cswap(swap, x_2, x_3) {
|
|
57129
57159
|
const dummy = modP(swap * (x_2 - x_3));
|
|
57130
57160
|
x_2 = modP(x_2 - dummy);
|
|
@@ -57174,26 +57204,32 @@ function montgomery2(curveDef) {
|
|
|
57174
57204
|
seed: fieldLen
|
|
57175
57205
|
};
|
|
57176
57206
|
const randomSecretKey = (seed = randomBytes_(fieldLen)) => {
|
|
57177
|
-
abytes3(seed, lengths.seed
|
|
57207
|
+
abytes3(seed, lengths.seed);
|
|
57178
57208
|
return seed;
|
|
57179
57209
|
};
|
|
57180
|
-
|
|
57181
|
-
|
|
57182
|
-
|
|
57183
|
-
|
|
57184
|
-
|
|
57210
|
+
function keygen(seed) {
|
|
57211
|
+
const secretKey = randomSecretKey(seed);
|
|
57212
|
+
return { secretKey, publicKey: scalarMultBase(secretKey) };
|
|
57213
|
+
}
|
|
57214
|
+
const utils = {
|
|
57215
|
+
randomSecretKey,
|
|
57216
|
+
randomPrivateKey: randomSecretKey
|
|
57217
|
+
};
|
|
57218
|
+
return {
|
|
57219
|
+
keygen,
|
|
57220
|
+
getSharedSecret: (secretKey, publicKey) => scalarMult(secretKey, publicKey),
|
|
57221
|
+
getPublicKey: (secretKey) => scalarMultBase(secretKey),
|
|
57185
57222
|
scalarMult,
|
|
57186
57223
|
scalarMultBase,
|
|
57187
57224
|
utils,
|
|
57188
57225
|
GuBytes: GuBytes.slice(),
|
|
57189
57226
|
lengths
|
|
57190
|
-
}
|
|
57227
|
+
};
|
|
57191
57228
|
}
|
|
57192
57229
|
var _0n6, _1n6, _2n4;
|
|
57193
57230
|
var init_montgomery2 = __esm({
|
|
57194
|
-
"
|
|
57231
|
+
"../../node_modules/@noble/curves/esm/abstract/montgomery.js"() {
|
|
57195
57232
|
init_utils3();
|
|
57196
|
-
init_curve2();
|
|
57197
57233
|
init_modular2();
|
|
57198
57234
|
_0n6 = BigInt(0);
|
|
57199
57235
|
_1n6 = BigInt(1);
|
|
@@ -57201,260 +57237,24 @@ var init_montgomery2 = __esm({
|
|
|
57201
57237
|
}
|
|
57202
57238
|
});
|
|
57203
57239
|
|
|
57204
|
-
//
|
|
57205
|
-
function createORPF(opts) {
|
|
57206
|
-
validateObject2(opts, {
|
|
57207
|
-
name: "string",
|
|
57208
|
-
hash: "function",
|
|
57209
|
-
hashToScalar: "function",
|
|
57210
|
-
hashToGroup: "function"
|
|
57211
|
-
});
|
|
57212
|
-
const { name: name2, Point, hash: hash2 } = opts;
|
|
57213
|
-
const { Fn: Fn3 } = Point;
|
|
57214
|
-
const hashToGroup = (msg, ctx) => opts.hashToGroup(msg, {
|
|
57215
|
-
DST: concatBytes2(asciiToBytes("HashToGroup-"), ctx)
|
|
57216
|
-
});
|
|
57217
|
-
const hashToScalarPrefixed = (msg, ctx) => opts.hashToScalar(msg, { DST: concatBytes2(_DST_scalar, ctx) });
|
|
57218
|
-
const randomScalar = (rng = randomBytes2) => {
|
|
57219
|
-
const t2 = mapHashToField(rng(getMinHashLength(Fn3.ORDER)), Fn3.ORDER, Fn3.isLE);
|
|
57220
|
-
return Fn3.isLE ? bytesToNumberLE2(t2) : bytesToNumberBE(t2);
|
|
57221
|
-
};
|
|
57222
|
-
const msm = (points, scalars) => pippenger(Point, points, scalars);
|
|
57223
|
-
const getCtx = (mode) => concatBytes2(asciiToBytes("OPRFV1-"), new Uint8Array([mode]), asciiToBytes("-" + name2));
|
|
57224
|
-
const ctxOPRF = getCtx(0);
|
|
57225
|
-
const ctxVOPRF = getCtx(1);
|
|
57226
|
-
const ctxPOPRF = getCtx(2);
|
|
57227
|
-
function encode4(...args2) {
|
|
57228
|
-
const res = [];
|
|
57229
|
-
for (const a2 of args2) {
|
|
57230
|
-
if (typeof a2 === "number")
|
|
57231
|
-
res.push(numberToBytesBE2(a2, 2));
|
|
57232
|
-
else if (typeof a2 === "string")
|
|
57233
|
-
res.push(asciiToBytes(a2));
|
|
57234
|
-
else {
|
|
57235
|
-
abytes3(a2);
|
|
57236
|
-
res.push(numberToBytesBE2(a2.length, 2), a2);
|
|
57237
|
-
}
|
|
57238
|
-
}
|
|
57239
|
-
return concatBytes2(...res);
|
|
57240
|
-
}
|
|
57241
|
-
const hashInput = (...bytes) => hash2(encode4(...bytes, "Finalize"));
|
|
57242
|
-
function getTranscripts(B2, C2, D2, ctx) {
|
|
57243
|
-
const Bm = B2.toBytes();
|
|
57244
|
-
const seed = hash2(encode4(Bm, concatBytes2(asciiToBytes("Seed-"), ctx)));
|
|
57245
|
-
const res = [];
|
|
57246
|
-
for (let i2 = 0; i2 < C2.length; i2++) {
|
|
57247
|
-
const Ci = C2[i2].toBytes();
|
|
57248
|
-
const Di = D2[i2].toBytes();
|
|
57249
|
-
const di = hashToScalarPrefixed(encode4(seed, i2, Ci, Di, "Composite"), ctx);
|
|
57250
|
-
res.push(di);
|
|
57251
|
-
}
|
|
57252
|
-
return res;
|
|
57253
|
-
}
|
|
57254
|
-
function computeComposites(B2, C2, D2, ctx) {
|
|
57255
|
-
const T2 = getTranscripts(B2, C2, D2, ctx);
|
|
57256
|
-
const M2 = msm(C2, T2);
|
|
57257
|
-
const Z2 = msm(D2, T2);
|
|
57258
|
-
return { M: M2, Z: Z2 };
|
|
57259
|
-
}
|
|
57260
|
-
function computeCompositesFast(k2, B2, C2, D2, ctx) {
|
|
57261
|
-
const T2 = getTranscripts(B2, C2, D2, ctx);
|
|
57262
|
-
const M2 = msm(C2, T2);
|
|
57263
|
-
const Z2 = M2.multiply(k2);
|
|
57264
|
-
return { M: M2, Z: Z2 };
|
|
57265
|
-
}
|
|
57266
|
-
function challengeTranscript(B2, M2, Z2, t2, t3, ctx) {
|
|
57267
|
-
const [Bm, a0, a1, a2, a3] = [B2, M2, Z2, t2, t3].map((i2) => i2.toBytes());
|
|
57268
|
-
return hashToScalarPrefixed(encode4(Bm, a0, a1, a2, a3, "Challenge"), ctx);
|
|
57269
|
-
}
|
|
57270
|
-
function generateProof(ctx, k2, B2, C2, D2, rng) {
|
|
57271
|
-
const { M: M2, Z: Z2 } = computeCompositesFast(k2, B2, C2, D2, ctx);
|
|
57272
|
-
const r2 = randomScalar(rng);
|
|
57273
|
-
const t2 = Point.BASE.multiply(r2);
|
|
57274
|
-
const t3 = M2.multiply(r2);
|
|
57275
|
-
const c2 = challengeTranscript(B2, M2, Z2, t2, t3, ctx);
|
|
57276
|
-
const s2 = Fn3.sub(r2, Fn3.mul(c2, k2));
|
|
57277
|
-
return concatBytes2(...[c2, s2].map((i2) => Fn3.toBytes(i2)));
|
|
57278
|
-
}
|
|
57279
|
-
function verifyProof(ctx, B2, C2, D2, proof) {
|
|
57280
|
-
abytes3(proof, 2 * Fn3.BYTES);
|
|
57281
|
-
const { M: M2, Z: Z2 } = computeComposites(B2, C2, D2, ctx);
|
|
57282
|
-
const [c2, s2] = [proof.subarray(0, Fn3.BYTES), proof.subarray(Fn3.BYTES)].map((f2) => Fn3.fromBytes(f2));
|
|
57283
|
-
const t2 = Point.BASE.multiply(s2).add(B2.multiply(c2));
|
|
57284
|
-
const t3 = M2.multiply(s2).add(Z2.multiply(c2));
|
|
57285
|
-
const expectedC = challengeTranscript(B2, M2, Z2, t2, t3, ctx);
|
|
57286
|
-
if (!Fn3.eql(c2, expectedC))
|
|
57287
|
-
throw new Error("proof verification failed");
|
|
57288
|
-
}
|
|
57289
|
-
function generateKeyPair() {
|
|
57290
|
-
const skS = randomScalar();
|
|
57291
|
-
const pkS = Point.BASE.multiply(skS);
|
|
57292
|
-
return { secretKey: Fn3.toBytes(skS), publicKey: pkS.toBytes() };
|
|
57293
|
-
}
|
|
57294
|
-
function deriveKeyPair(ctx, seed, info) {
|
|
57295
|
-
const dst = concatBytes2(asciiToBytes("DeriveKeyPair"), ctx);
|
|
57296
|
-
const msg = concatBytes2(seed, encode4(info), Uint8Array.of(0));
|
|
57297
|
-
for (let counter = 0; counter <= 255; counter++) {
|
|
57298
|
-
msg[msg.length - 1] = counter;
|
|
57299
|
-
const skS = opts.hashToScalar(msg, { DST: dst });
|
|
57300
|
-
if (Fn3.is0(skS))
|
|
57301
|
-
continue;
|
|
57302
|
-
return { secretKey: Fn3.toBytes(skS), publicKey: Point.BASE.multiply(skS).toBytes() };
|
|
57303
|
-
}
|
|
57304
|
-
throw new Error("Cannot derive key");
|
|
57305
|
-
}
|
|
57306
|
-
function blind(ctx, input, rng = randomBytes2) {
|
|
57307
|
-
const blind2 = randomScalar(rng);
|
|
57308
|
-
const inputPoint = hashToGroup(input, ctx);
|
|
57309
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57310
|
-
throw new Error("Input point at infinity");
|
|
57311
|
-
const blinded = inputPoint.multiply(blind2);
|
|
57312
|
-
return { blind: Fn3.toBytes(blind2), blinded: blinded.toBytes() };
|
|
57313
|
-
}
|
|
57314
|
-
function evaluate(ctx, secretKey, input) {
|
|
57315
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57316
|
-
const inputPoint = hashToGroup(input, ctx);
|
|
57317
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57318
|
-
throw new Error("Input point at infinity");
|
|
57319
|
-
const unblinded = inputPoint.multiply(skS).toBytes();
|
|
57320
|
-
return hashInput(input, unblinded);
|
|
57321
|
-
}
|
|
57322
|
-
const oprf = {
|
|
57323
|
-
generateKeyPair,
|
|
57324
|
-
deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxOPRF, seed, keyInfo),
|
|
57325
|
-
blind: (input, rng = randomBytes2) => blind(ctxOPRF, input, rng),
|
|
57326
|
-
blindEvaluate(secretKey, blindedPoint) {
|
|
57327
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57328
|
-
const elm = Point.fromBytes(blindedPoint);
|
|
57329
|
-
return elm.multiply(skS).toBytes();
|
|
57330
|
-
},
|
|
57331
|
-
finalize(input, blindBytes, evaluatedBytes) {
|
|
57332
|
-
const blind2 = Fn3.fromBytes(blindBytes);
|
|
57333
|
-
const evalPoint = Point.fromBytes(evaluatedBytes);
|
|
57334
|
-
const unblinded = evalPoint.multiply(Fn3.inv(blind2)).toBytes();
|
|
57335
|
-
return hashInput(input, unblinded);
|
|
57336
|
-
},
|
|
57337
|
-
evaluate: (secretKey, input) => evaluate(ctxOPRF, secretKey, input)
|
|
57338
|
-
};
|
|
57339
|
-
const voprf = {
|
|
57340
|
-
generateKeyPair,
|
|
57341
|
-
deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxVOPRF, seed, keyInfo),
|
|
57342
|
-
blind: (input, rng = randomBytes2) => blind(ctxVOPRF, input, rng),
|
|
57343
|
-
blindEvaluateBatch(secretKey, publicKey, blinded, rng = randomBytes2) {
|
|
57344
|
-
if (!Array.isArray(blinded))
|
|
57345
|
-
throw new Error("expected array");
|
|
57346
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57347
|
-
const pkS = Point.fromBytes(publicKey);
|
|
57348
|
-
const blindedPoints = blinded.map(Point.fromBytes);
|
|
57349
|
-
const evaluated = blindedPoints.map((i2) => i2.multiply(skS));
|
|
57350
|
-
const proof = generateProof(ctxVOPRF, skS, pkS, blindedPoints, evaluated, rng);
|
|
57351
|
-
return { evaluated: evaluated.map((i2) => i2.toBytes()), proof };
|
|
57352
|
-
},
|
|
57353
|
-
blindEvaluate(secretKey, publicKey, blinded, rng = randomBytes2) {
|
|
57354
|
-
const res = this.blindEvaluateBatch(secretKey, publicKey, [blinded], rng);
|
|
57355
|
-
return { evaluated: res.evaluated[0], proof: res.proof };
|
|
57356
|
-
},
|
|
57357
|
-
finalizeBatch(items, publicKey, proof) {
|
|
57358
|
-
if (!Array.isArray(items))
|
|
57359
|
-
throw new Error("expected array");
|
|
57360
|
-
const pkS = Point.fromBytes(publicKey);
|
|
57361
|
-
const blindedPoints = items.map((i2) => i2.blinded).map(Point.fromBytes);
|
|
57362
|
-
const evalPoints = items.map((i2) => i2.evaluated).map(Point.fromBytes);
|
|
57363
|
-
verifyProof(ctxVOPRF, pkS, blindedPoints, evalPoints, proof);
|
|
57364
|
-
return items.map((i2) => oprf.finalize(i2.input, i2.blind, i2.evaluated));
|
|
57365
|
-
},
|
|
57366
|
-
finalize(input, blind2, evaluated, blinded, publicKey, proof) {
|
|
57367
|
-
return this.finalizeBatch([{ input, blind: blind2, evaluated, blinded }], publicKey, proof)[0];
|
|
57368
|
-
},
|
|
57369
|
-
evaluate: (secretKey, input) => evaluate(ctxVOPRF, secretKey, input)
|
|
57370
|
-
};
|
|
57371
|
-
const poprf = (info) => {
|
|
57372
|
-
const m2 = hashToScalarPrefixed(encode4("Info", info), ctxPOPRF);
|
|
57373
|
-
const T2 = Point.BASE.multiply(m2);
|
|
57374
|
-
return {
|
|
57375
|
-
generateKeyPair,
|
|
57376
|
-
deriveKeyPair: (seed, keyInfo) => deriveKeyPair(ctxPOPRF, seed, keyInfo),
|
|
57377
|
-
blind(input, publicKey, rng = randomBytes2) {
|
|
57378
|
-
const pkS = Point.fromBytes(publicKey);
|
|
57379
|
-
const tweakedKey = T2.add(pkS);
|
|
57380
|
-
if (tweakedKey.equals(Point.ZERO))
|
|
57381
|
-
throw new Error("tweakedKey point at infinity");
|
|
57382
|
-
const blind2 = randomScalar(rng);
|
|
57383
|
-
const inputPoint = hashToGroup(input, ctxPOPRF);
|
|
57384
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57385
|
-
throw new Error("Input point at infinity");
|
|
57386
|
-
const blindedPoint = inputPoint.multiply(blind2);
|
|
57387
|
-
return {
|
|
57388
|
-
blind: Fn3.toBytes(blind2),
|
|
57389
|
-
blinded: blindedPoint.toBytes(),
|
|
57390
|
-
tweakedKey: tweakedKey.toBytes()
|
|
57391
|
-
};
|
|
57392
|
-
},
|
|
57393
|
-
blindEvaluateBatch(secretKey, blinded, rng = randomBytes2) {
|
|
57394
|
-
if (!Array.isArray(blinded))
|
|
57395
|
-
throw new Error("expected array");
|
|
57396
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57397
|
-
const t2 = Fn3.add(skS, m2);
|
|
57398
|
-
const invT = Fn3.inv(t2);
|
|
57399
|
-
const blindedPoints = blinded.map(Point.fromBytes);
|
|
57400
|
-
const evalPoints = blindedPoints.map((i2) => i2.multiply(invT));
|
|
57401
|
-
const tweakedKey = Point.BASE.multiply(t2);
|
|
57402
|
-
const proof = generateProof(ctxPOPRF, t2, tweakedKey, evalPoints, blindedPoints, rng);
|
|
57403
|
-
return { evaluated: evalPoints.map((i2) => i2.toBytes()), proof };
|
|
57404
|
-
},
|
|
57405
|
-
blindEvaluate(secretKey, blinded, rng = randomBytes2) {
|
|
57406
|
-
const res = this.blindEvaluateBatch(secretKey, [blinded], rng);
|
|
57407
|
-
return { evaluated: res.evaluated[0], proof: res.proof };
|
|
57408
|
-
},
|
|
57409
|
-
finalizeBatch(items, proof, tweakedKey) {
|
|
57410
|
-
if (!Array.isArray(items))
|
|
57411
|
-
throw new Error("expected array");
|
|
57412
|
-
const evalPoints = items.map((i2) => i2.evaluated).map(Point.fromBytes);
|
|
57413
|
-
verifyProof(ctxPOPRF, Point.fromBytes(tweakedKey), evalPoints, items.map((i2) => i2.blinded).map(Point.fromBytes), proof);
|
|
57414
|
-
return items.map((i2, j2) => {
|
|
57415
|
-
const blind2 = Fn3.fromBytes(i2.blind);
|
|
57416
|
-
const point = evalPoints[j2].multiply(Fn3.inv(blind2)).toBytes();
|
|
57417
|
-
return hashInput(i2.input, info, point);
|
|
57418
|
-
});
|
|
57419
|
-
},
|
|
57420
|
-
finalize(input, blind2, evaluated, blinded, proof, tweakedKey) {
|
|
57421
|
-
return this.finalizeBatch([{ input, blind: blind2, evaluated, blinded }], proof, tweakedKey)[0];
|
|
57422
|
-
},
|
|
57423
|
-
evaluate(secretKey, input) {
|
|
57424
|
-
const skS = Fn3.fromBytes(secretKey);
|
|
57425
|
-
const inputPoint = hashToGroup(input, ctxPOPRF);
|
|
57426
|
-
if (inputPoint.equals(Point.ZERO))
|
|
57427
|
-
throw new Error("Input point at infinity");
|
|
57428
|
-
const t2 = Fn3.add(skS, m2);
|
|
57429
|
-
const invT = Fn3.inv(t2);
|
|
57430
|
-
const unblinded = inputPoint.multiply(invT).toBytes();
|
|
57431
|
-
return hashInput(input, info, unblinded);
|
|
57432
|
-
}
|
|
57433
|
-
};
|
|
57434
|
-
};
|
|
57435
|
-
return Object.freeze({ name: name2, oprf, voprf, poprf, __tests: { Fn: Fn3 } });
|
|
57436
|
-
}
|
|
57437
|
-
var init_oprf = __esm({
|
|
57438
|
-
"../crypto/node_modules/@noble/curves/abstract/oprf.js"() {
|
|
57439
|
-
init_utils3();
|
|
57440
|
-
init_curve2();
|
|
57441
|
-
init_hash_to_curve();
|
|
57442
|
-
init_modular2();
|
|
57443
|
-
}
|
|
57444
|
-
});
|
|
57445
|
-
|
|
57446
|
-
// ../crypto/node_modules/@noble/curves/ed25519.js
|
|
57240
|
+
// ../../node_modules/@noble/curves/esm/ed25519.js
|
|
57447
57241
|
var ed25519_exports = {};
|
|
57448
57242
|
__export(ed25519_exports, {
|
|
57449
57243
|
ED25519_TORSION_SUBGROUP: () => ED25519_TORSION_SUBGROUP,
|
|
57450
|
-
|
|
57244
|
+
RistrettoPoint: () => RistrettoPoint,
|
|
57451
57245
|
ed25519: () => ed25519,
|
|
57452
57246
|
ed25519_hasher: () => ed25519_hasher,
|
|
57453
57247
|
ed25519ctx: () => ed25519ctx,
|
|
57454
57248
|
ed25519ph: () => ed25519ph,
|
|
57249
|
+
edwardsToMontgomery: () => edwardsToMontgomery,
|
|
57250
|
+
edwardsToMontgomeryPriv: () => edwardsToMontgomeryPriv,
|
|
57251
|
+
edwardsToMontgomeryPub: () => edwardsToMontgomeryPub,
|
|
57252
|
+
encodeToCurve: () => encodeToCurve,
|
|
57253
|
+
hashToCurve: () => hashToCurve,
|
|
57254
|
+
hashToRistretto255: () => hashToRistretto255,
|
|
57255
|
+
hash_to_ristretto255: () => hash_to_ristretto255,
|
|
57455
57256
|
ristretto255: () => ristretto255,
|
|
57456
57257
|
ristretto255_hasher: () => ristretto255_hasher,
|
|
57457
|
-
ristretto255_oprf: () => ristretto255_oprf,
|
|
57458
57258
|
x25519: () => x25519
|
|
57459
57259
|
});
|
|
57460
57260
|
function ed25519_pow_2_252_3(x2) {
|
|
@@ -57503,12 +57303,9 @@ function uvRatio(u2, v2) {
|
|
|
57503
57303
|
function ed25519_domain(data, ctx, phflag) {
|
|
57504
57304
|
if (ctx.length > 255)
|
|
57505
57305
|
throw new Error("Context is too big");
|
|
57506
|
-
return concatBytes2(
|
|
57306
|
+
return concatBytes2(utf8ToBytes("SigEd25519 no Ed25519 collisions"), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
57507
57307
|
}
|
|
57508
|
-
function
|
|
57509
|
-
return eddsa(ed25519_Point, sha5122, Object.assign({ adjustScalarBytes }, opts));
|
|
57510
|
-
}
|
|
57511
|
-
function _map_to_curve_elligator2_curve25519(u2) {
|
|
57308
|
+
function map_to_curve_elligator2_curve25519(u2) {
|
|
57512
57309
|
const ELL2_C4 = (ed25519_CURVE_p - _5n2) / _8n3;
|
|
57513
57310
|
const ELL2_J2 = BigInt(486662);
|
|
57514
57311
|
let tv1 = Fp.sqr(u2);
|
|
@@ -57552,7 +57349,7 @@ function _map_to_curve_elligator2_curve25519(u2) {
|
|
|
57552
57349
|
return { xMn: xn, xMd: xd, yMn: y3, yMd: _1n7 };
|
|
57553
57350
|
}
|
|
57554
57351
|
function map_to_curve_elligator2_edwards25519(u2) {
|
|
57555
|
-
const { xMn, xMd, yMn, yMd } =
|
|
57352
|
+
const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u2);
|
|
57556
57353
|
let xn = Fp.mul(xMn, yMd);
|
|
57557
57354
|
xn = Fp.mul(xn, ELL2_C1_EDWARDS);
|
|
57558
57355
|
let xd = Fp.mul(xMd, yMn);
|
|
@@ -57589,23 +57386,37 @@ function calcElligatorRistrettoMap(r0) {
|
|
|
57589
57386
|
const W1 = mod4(Nt * SQRT_AD_MINUS_ONE);
|
|
57590
57387
|
const W2 = mod4(_1n7 - s22);
|
|
57591
57388
|
const W3 = mod4(_1n7 + s22);
|
|
57592
|
-
return new
|
|
57389
|
+
return new ed25519.Point(mod4(W0 * W3), mod4(W2 * W1), mod4(W1 * W3), mod4(W0 * W2));
|
|
57390
|
+
}
|
|
57391
|
+
function ristretto255_map(bytes) {
|
|
57392
|
+
abytes3(bytes, 64);
|
|
57393
|
+
const r1 = bytes255ToNumberLE(bytes.subarray(0, 32));
|
|
57394
|
+
const R1 = calcElligatorRistrettoMap(r1);
|
|
57395
|
+
const r2 = bytes255ToNumberLE(bytes.subarray(32, 64));
|
|
57396
|
+
const R2 = calcElligatorRistrettoMap(r2);
|
|
57397
|
+
return new _RistrettoPoint(R1.add(R2));
|
|
57593
57398
|
}
|
|
57594
|
-
|
|
57399
|
+
function edwardsToMontgomeryPub(edwardsPub) {
|
|
57400
|
+
return ed25519.utils.toMontgomery(ensureBytes("pub", edwardsPub));
|
|
57401
|
+
}
|
|
57402
|
+
function edwardsToMontgomeryPriv(edwardsPriv) {
|
|
57403
|
+
return ed25519.utils.toMontgomerySecret(ensureBytes("pub", edwardsPriv));
|
|
57404
|
+
}
|
|
57405
|
+
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;
|
|
57595
57406
|
var init_ed25519 = __esm({
|
|
57596
|
-
"
|
|
57407
|
+
"../../node_modules/@noble/curves/esm/ed25519.js"() {
|
|
57597
57408
|
init_sha22();
|
|
57598
57409
|
init_utils2();
|
|
57410
|
+
init_curve2();
|
|
57599
57411
|
init_edwards();
|
|
57600
57412
|
init_hash_to_curve();
|
|
57601
57413
|
init_modular2();
|
|
57602
57414
|
init_montgomery2();
|
|
57603
|
-
init_oprf();
|
|
57604
57415
|
init_utils3();
|
|
57605
57416
|
_0n7 = /* @__PURE__ */ BigInt(0);
|
|
57606
57417
|
_1n7 = BigInt(1);
|
|
57607
57418
|
_2n5 = BigInt(2);
|
|
57608
|
-
_3n2 =
|
|
57419
|
+
_3n2 = BigInt(3);
|
|
57609
57420
|
_5n2 = BigInt(5);
|
|
57610
57421
|
_8n3 = BigInt(8);
|
|
57611
57422
|
ed25519_CURVE_p = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");
|
|
@@ -57619,14 +57430,29 @@ var init_ed25519 = __esm({
|
|
|
57619
57430
|
Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
|
|
57620
57431
|
}))();
|
|
57621
57432
|
ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
57622
|
-
|
|
57623
|
-
|
|
57624
|
-
|
|
57625
|
-
|
|
57626
|
-
|
|
57627
|
-
|
|
57433
|
+
Fp = /* @__PURE__ */ (() => Field(ed25519_CURVE.p, { isLE: true }))();
|
|
57434
|
+
Fn = /* @__PURE__ */ (() => Field(ed25519_CURVE.n, { isLE: true }))();
|
|
57435
|
+
ed25519Defaults = /* @__PURE__ */ (() => ({
|
|
57436
|
+
...ed25519_CURVE,
|
|
57437
|
+
Fp,
|
|
57438
|
+
hash: sha5122,
|
|
57439
|
+
adjustScalarBytes,
|
|
57440
|
+
// dom2
|
|
57441
|
+
// Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.
|
|
57442
|
+
// Constant-time, u/√v
|
|
57443
|
+
uvRatio
|
|
57444
|
+
}))();
|
|
57445
|
+
ed25519 = /* @__PURE__ */ (() => twistedEdwards(ed25519Defaults))();
|
|
57446
|
+
ed25519ctx = /* @__PURE__ */ (() => twistedEdwards({
|
|
57447
|
+
...ed25519Defaults,
|
|
57448
|
+
domain: ed25519_domain
|
|
57449
|
+
}))();
|
|
57450
|
+
ed25519ph = /* @__PURE__ */ (() => twistedEdwards(Object.assign({}, ed25519Defaults, {
|
|
57451
|
+
domain: ed25519_domain,
|
|
57452
|
+
prehash: sha5122
|
|
57453
|
+
})))();
|
|
57628
57454
|
x25519 = /* @__PURE__ */ (() => {
|
|
57629
|
-
const P2 =
|
|
57455
|
+
const P2 = Fp.ORDER;
|
|
57630
57456
|
return montgomery2({
|
|
57631
57457
|
P: P2,
|
|
57632
57458
|
type: "x25519",
|
|
@@ -57641,7 +57467,7 @@ var init_ed25519 = __esm({
|
|
|
57641
57467
|
ELL2_C2 = /* @__PURE__ */ (() => Fp.pow(_2n5, ELL2_C1))();
|
|
57642
57468
|
ELL2_C3 = /* @__PURE__ */ (() => Fp.sqrt(Fp.neg(Fp.ONE)))();
|
|
57643
57469
|
ELL2_C1_EDWARDS = /* @__PURE__ */ (() => FpSqrtEven(Fp, Fp.neg(BigInt(486664))))();
|
|
57644
|
-
ed25519_hasher = /* @__PURE__ */ (() => createHasher3(
|
|
57470
|
+
ed25519_hasher = /* @__PURE__ */ (() => createHasher3(ed25519.Point, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), {
|
|
57645
57471
|
DST: "edwards25519_XMD:SHA-512_ELL2_RO_",
|
|
57646
57472
|
encodeDST: "edwards25519_XMD:SHA-512_ELL2_NU_",
|
|
57647
57473
|
p: ed25519_CURVE_p,
|
|
@@ -57657,23 +57483,13 @@ var init_ed25519 = __esm({
|
|
|
57657
57483
|
D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");
|
|
57658
57484
|
invertSqrt = (number3) => uvRatio(_1n7, number3);
|
|
57659
57485
|
MAX_255B = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
57660
|
-
bytes255ToNumberLE = (bytes) => Fp.create(bytesToNumberLE2(bytes) & MAX_255B);
|
|
57486
|
+
bytes255ToNumberLE = (bytes) => ed25519.Point.Fp.create(bytesToNumberLE2(bytes) & MAX_255B);
|
|
57661
57487
|
_RistrettoPoint = class __RistrettoPoint extends PrimeEdwardsPoint {
|
|
57662
|
-
// Do NOT change syntax: the following gymnastics is done,
|
|
57663
|
-
// because typescript strips comments, which makes bundlers disable tree-shaking.
|
|
57664
|
-
// prettier-ignore
|
|
57665
|
-
static BASE = /* @__PURE__ */ (() => new __RistrettoPoint(ed25519_Point.BASE))();
|
|
57666
|
-
// prettier-ignore
|
|
57667
|
-
static ZERO = /* @__PURE__ */ (() => new __RistrettoPoint(ed25519_Point.ZERO))();
|
|
57668
|
-
// prettier-ignore
|
|
57669
|
-
static Fp = /* @__PURE__ */ (() => Fp)();
|
|
57670
|
-
// prettier-ignore
|
|
57671
|
-
static Fn = /* @__PURE__ */ (() => Fn)();
|
|
57672
57488
|
constructor(ep) {
|
|
57673
57489
|
super(ep);
|
|
57674
57490
|
}
|
|
57675
57491
|
static fromAffine(ap) {
|
|
57676
|
-
return new __RistrettoPoint(
|
|
57492
|
+
return new __RistrettoPoint(ed25519.Point.fromAffine(ap));
|
|
57677
57493
|
}
|
|
57678
57494
|
assertSame(other) {
|
|
57679
57495
|
if (!(other instanceof __RistrettoPoint))
|
|
@@ -57682,6 +57498,10 @@ var init_ed25519 = __esm({
|
|
|
57682
57498
|
init(ep) {
|
|
57683
57499
|
return new __RistrettoPoint(ep);
|
|
57684
57500
|
}
|
|
57501
|
+
/** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
|
|
57502
|
+
static hashToCurve(hex3) {
|
|
57503
|
+
return ristretto255_map(ensureBytes("ristrettoHash", hex3, 64));
|
|
57504
|
+
}
|
|
57685
57505
|
static fromBytes(bytes) {
|
|
57686
57506
|
abytes3(bytes, 32);
|
|
57687
57507
|
const { a: a2, d: d2 } = ed25519_CURVE;
|
|
@@ -57706,7 +57526,7 @@ var init_ed25519 = __esm({
|
|
|
57706
57526
|
const t2 = mod4(x2 * y2);
|
|
57707
57527
|
if (!isValid2 || isNegativeLE(t2, P2) || y2 === _0n7)
|
|
57708
57528
|
throw new Error("invalid ristretto255 encoding 2");
|
|
57709
|
-
return new __RistrettoPoint(new
|
|
57529
|
+
return new __RistrettoPoint(new ed25519.Point(x2, y2, _1n7, t2));
|
|
57710
57530
|
}
|
|
57711
57531
|
/**
|
|
57712
57532
|
* Converts ristretto-encoded string to ristretto point.
|
|
@@ -57714,7 +57534,10 @@ var init_ed25519 = __esm({
|
|
|
57714
57534
|
* @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
|
|
57715
57535
|
*/
|
|
57716
57536
|
static fromHex(hex3) {
|
|
57717
|
-
return __RistrettoPoint.fromBytes(
|
|
57537
|
+
return __RistrettoPoint.fromBytes(ensureBytes("ristrettoHex", hex3, 32));
|
|
57538
|
+
}
|
|
57539
|
+
static msm(points, scalars) {
|
|
57540
|
+
return pippenger(__RistrettoPoint, ed25519.Point.Fn, points, scalars);
|
|
57718
57541
|
}
|
|
57719
57542
|
/**
|
|
57720
57543
|
* Encodes ristretto point to Uint8Array.
|
|
@@ -57765,53 +57588,22 @@ var init_ed25519 = __esm({
|
|
|
57765
57588
|
return this.equals(__RistrettoPoint.ZERO);
|
|
57766
57589
|
}
|
|
57767
57590
|
};
|
|
57591
|
+
_RistrettoPoint.BASE = /* @__PURE__ */ (() => new _RistrettoPoint(ed25519.Point.BASE))();
|
|
57592
|
+
_RistrettoPoint.ZERO = /* @__PURE__ */ (() => new _RistrettoPoint(ed25519.Point.ZERO))();
|
|
57593
|
+
_RistrettoPoint.Fp = /* @__PURE__ */ (() => Fp)();
|
|
57594
|
+
_RistrettoPoint.Fn = /* @__PURE__ */ (() => Fn)();
|
|
57768
57595
|
ristretto255 = { Point: _RistrettoPoint };
|
|
57769
57596
|
ristretto255_hasher = {
|
|
57770
|
-
Point: _RistrettoPoint,
|
|
57771
|
-
/**
|
|
57772
|
-
* Spec: https://www.rfc-editor.org/rfc/rfc9380.html#name-hashing-to-ristretto255. Caveats:
|
|
57773
|
-
* * There are no test vectors
|
|
57774
|
-
* * encodeToCurve / mapToCurve is undefined
|
|
57775
|
-
* * mapToCurve would be `calcElligatorRistrettoMap(scalars[0])`, not ristretto255_map!
|
|
57776
|
-
* * hashToScalar is undefined too, so we just use OPRF implementation
|
|
57777
|
-
* * We cannot re-use 'createHasher', because ristretto255_map is different algorithm/RFC
|
|
57778
|
-
(os2ip -> bytes255ToNumberLE)
|
|
57779
|
-
* * mapToCurve == calcElligatorRistrettoMap, hashToCurve == ristretto255_map
|
|
57780
|
-
* * 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
|
|
57781
|
-
* * current version is closest to spec.
|
|
57782
|
-
*/
|
|
57783
57597
|
hashToCurve(msg, options) {
|
|
57784
57598
|
const DST = options?.DST || "ristretto255_XMD:SHA-512_R255MAP_RO_";
|
|
57785
57599
|
const xmd = expand_message_xmd(msg, DST, 64, sha5122);
|
|
57786
|
-
return
|
|
57600
|
+
return ristretto255_map(xmd);
|
|
57787
57601
|
},
|
|
57788
57602
|
hashToScalar(msg, options = { DST: _DST_scalar }) {
|
|
57789
57603
|
const xmd = expand_message_xmd(msg, options.DST, 64, sha5122);
|
|
57790
57604
|
return Fn.create(bytesToNumberLE2(xmd));
|
|
57791
|
-
},
|
|
57792
|
-
/**
|
|
57793
|
-
* HashToCurve-like construction based on RFC 9496 (Element Derivation).
|
|
57794
|
-
* Converts 64 uniform random bytes into a curve point.
|
|
57795
|
-
*
|
|
57796
|
-
* WARNING: This represents an older hash-to-curve construction, preceding the finalization of RFC 9380.
|
|
57797
|
-
* It was later reused as a component in the newer `hash_to_ristretto255` function defined in RFC 9380.
|
|
57798
|
-
*/
|
|
57799
|
-
deriveToCurve(bytes) {
|
|
57800
|
-
abytes3(bytes, 64);
|
|
57801
|
-
const r1 = bytes255ToNumberLE(bytes.subarray(0, 32));
|
|
57802
|
-
const R1 = calcElligatorRistrettoMap(r1);
|
|
57803
|
-
const r2 = bytes255ToNumberLE(bytes.subarray(32, 64));
|
|
57804
|
-
const R2 = calcElligatorRistrettoMap(r2);
|
|
57805
|
-
return new _RistrettoPoint(R1.add(R2));
|
|
57806
57605
|
}
|
|
57807
57606
|
};
|
|
57808
|
-
ristretto255_oprf = /* @__PURE__ */ (() => createORPF({
|
|
57809
|
-
name: "ristretto255-SHA512",
|
|
57810
|
-
Point: _RistrettoPoint,
|
|
57811
|
-
hash: sha5122,
|
|
57812
|
-
hashToGroup: ristretto255_hasher.hashToCurve,
|
|
57813
|
-
hashToScalar: ristretto255_hasher.hashToScalar
|
|
57814
|
-
}))();
|
|
57815
57607
|
ED25519_TORSION_SUBGROUP = [
|
|
57816
57608
|
"0100000000000000000000000000000000000000000000000000000000000000",
|
|
57817
57609
|
"c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a",
|
|
@@ -57822,10 +57614,16 @@ var init_ed25519 = __esm({
|
|
|
57822
57614
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
|
57823
57615
|
"c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"
|
|
57824
57616
|
];
|
|
57617
|
+
edwardsToMontgomery = edwardsToMontgomeryPub;
|
|
57618
|
+
RistrettoPoint = _RistrettoPoint;
|
|
57619
|
+
hashToCurve = /* @__PURE__ */ (() => ed25519_hasher.hashToCurve)();
|
|
57620
|
+
encodeToCurve = /* @__PURE__ */ (() => ed25519_hasher.encodeToCurve)();
|
|
57621
|
+
hashToRistretto255 = /* @__PURE__ */ (() => ristretto255_hasher.hashToCurve)();
|
|
57622
|
+
hash_to_ristretto255 = /* @__PURE__ */ (() => ristretto255_hasher.hashToCurve)();
|
|
57825
57623
|
}
|
|
57826
57624
|
});
|
|
57827
57625
|
|
|
57828
|
-
//
|
|
57626
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js
|
|
57829
57627
|
function keccakP(s2, rounds = 24) {
|
|
57830
57628
|
const B2 = new Uint32Array(5 * 2);
|
|
57831
57629
|
for (let round = 24 - rounds; round < 24; round++) {
|
|
@@ -57868,7 +57666,7 @@ function keccakP(s2, rounds = 24) {
|
|
|
57868
57666
|
}
|
|
57869
57667
|
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;
|
|
57870
57668
|
var init_sha32 = __esm({
|
|
57871
|
-
"
|
|
57669
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha3.js"() {
|
|
57872
57670
|
init_u642();
|
|
57873
57671
|
init_utils2();
|
|
57874
57672
|
_0n8 = BigInt(0);
|
|
@@ -57888,7 +57686,7 @@ var init_sha32 = __esm({
|
|
|
57888
57686
|
for (let j2 = 0; j2 < 7; j2++) {
|
|
57889
57687
|
R2 = (R2 << _1n8 ^ (R2 >> _7n3) * _0x71n2) % _256n2;
|
|
57890
57688
|
if (R2 & _2n6)
|
|
57891
|
-
t2 ^= _1n8 << (_1n8 << BigInt(j2)) - _1n8;
|
|
57689
|
+
t2 ^= _1n8 << (_1n8 << /* @__PURE__ */ BigInt(j2)) - _1n8;
|
|
57892
57690
|
}
|
|
57893
57691
|
_SHA3_IOTA2.push(t2);
|
|
57894
57692
|
}
|
|
@@ -57897,26 +57695,21 @@ var init_sha32 = __esm({
|
|
|
57897
57695
|
SHA3_IOTA_L2 = IOTAS2[1];
|
|
57898
57696
|
rotlH = (h2, l2, s2) => s2 > 32 ? rotlBH2(h2, l2, s2) : rotlSH2(h2, l2, s2);
|
|
57899
57697
|
rotlL = (h2, l2, s2) => s2 > 32 ? rotlBL2(h2, l2, s2) : rotlSL2(h2, l2, s2);
|
|
57900
|
-
Keccak = class _Keccak {
|
|
57901
|
-
state;
|
|
57902
|
-
pos = 0;
|
|
57903
|
-
posOut = 0;
|
|
57904
|
-
finished = false;
|
|
57905
|
-
state32;
|
|
57906
|
-
destroyed = false;
|
|
57907
|
-
blockLen;
|
|
57908
|
-
suffix;
|
|
57909
|
-
outputLen;
|
|
57910
|
-
enableXOF = false;
|
|
57911
|
-
rounds;
|
|
57698
|
+
Keccak = class _Keccak extends Hash {
|
|
57912
57699
|
// NOTE: we accept arguments in bytes instead of bits here.
|
|
57913
57700
|
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
57701
|
+
super();
|
|
57702
|
+
this.pos = 0;
|
|
57703
|
+
this.posOut = 0;
|
|
57704
|
+
this.finished = false;
|
|
57705
|
+
this.destroyed = false;
|
|
57706
|
+
this.enableXOF = false;
|
|
57914
57707
|
this.blockLen = blockLen;
|
|
57915
57708
|
this.suffix = suffix;
|
|
57916
57709
|
this.outputLen = outputLen;
|
|
57917
57710
|
this.enableXOF = enableXOF;
|
|
57918
57711
|
this.rounds = rounds;
|
|
57919
|
-
anumber3(outputLen
|
|
57712
|
+
anumber3(outputLen);
|
|
57920
57713
|
if (!(0 < blockLen && blockLen < 200))
|
|
57921
57714
|
throw new Error("only keccak-f1600 function is supported");
|
|
57922
57715
|
this.state = new Uint8Array(200);
|
|
@@ -57934,6 +57727,7 @@ var init_sha32 = __esm({
|
|
|
57934
57727
|
}
|
|
57935
57728
|
update(data) {
|
|
57936
57729
|
aexists3(this);
|
|
57730
|
+
data = toBytes(data);
|
|
57937
57731
|
abytes3(data);
|
|
57938
57732
|
const { blockLen, state } = this;
|
|
57939
57733
|
const len = data.length;
|
|
@@ -57999,7 +57793,7 @@ var init_sha32 = __esm({
|
|
|
57999
57793
|
}
|
|
58000
57794
|
_cloneInto(to) {
|
|
58001
57795
|
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
58002
|
-
to
|
|
57796
|
+
to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
58003
57797
|
to.state32.set(this.state32);
|
|
58004
57798
|
to.pos = this.pos;
|
|
58005
57799
|
to.posOut = this.posOut;
|
|
@@ -58012,26 +57806,32 @@ var init_sha32 = __esm({
|
|
|
58012
57806
|
return to;
|
|
58013
57807
|
}
|
|
58014
57808
|
};
|
|
58015
|
-
genShake = (suffix, blockLen, outputLen
|
|
58016
|
-
shake2562 = /* @__PURE__ */ genShake(31, 136,
|
|
57809
|
+
genShake = (suffix, blockLen, outputLen) => createXOFer((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true));
|
|
57810
|
+
shake2562 = /* @__PURE__ */ (() => genShake(31, 136, 256 / 8))();
|
|
58017
57811
|
}
|
|
58018
57812
|
});
|
|
58019
57813
|
|
|
58020
|
-
//
|
|
57814
|
+
// ../../node_modules/@noble/curves/esm/ed448.js
|
|
58021
57815
|
var ed448_exports = {};
|
|
58022
57816
|
__export(ed448_exports, {
|
|
57817
|
+
DecafPoint: () => DecafPoint,
|
|
58023
57818
|
E448: () => E448,
|
|
58024
57819
|
ED448_TORSION_SUBGROUP: () => ED448_TORSION_SUBGROUP,
|
|
58025
57820
|
decaf448: () => decaf448,
|
|
58026
57821
|
decaf448_hasher: () => decaf448_hasher,
|
|
58027
|
-
decaf448_oprf: () => decaf448_oprf,
|
|
58028
57822
|
ed448: () => ed448,
|
|
58029
57823
|
ed448_hasher: () => ed448_hasher,
|
|
58030
57824
|
ed448ph: () => ed448ph,
|
|
57825
|
+
edwardsToMontgomery: () => edwardsToMontgomery2,
|
|
57826
|
+
edwardsToMontgomeryPub: () => edwardsToMontgomeryPub2,
|
|
57827
|
+
encodeToCurve: () => encodeToCurve2,
|
|
57828
|
+
hashToCurve: () => hashToCurve2,
|
|
57829
|
+
hashToDecaf448: () => hashToDecaf448,
|
|
57830
|
+
hash_to_decaf448: () => hash_to_decaf448,
|
|
58031
57831
|
x448: () => x448
|
|
58032
57832
|
});
|
|
58033
57833
|
function ed448_pow_Pminus3div4(x2) {
|
|
58034
|
-
const P2 =
|
|
57834
|
+
const P2 = ed448_CURVE.p;
|
|
58035
57835
|
const b2 = x2 * x2 * x2 % P2;
|
|
58036
57836
|
const b3 = b2 * b2 * x2 % P2;
|
|
58037
57837
|
const b6 = pow22(b3, _3n3, P2) * b3 % P2;
|
|
@@ -58053,7 +57853,7 @@ function adjustScalarBytes2(bytes) {
|
|
|
58053
57853
|
return bytes;
|
|
58054
57854
|
}
|
|
58055
57855
|
function uvRatio2(u2, v2) {
|
|
58056
|
-
const P2 =
|
|
57856
|
+
const P2 = ed448_CURVE.p;
|
|
58057
57857
|
const u2v = mod3(u2 * u2 * v2, P2);
|
|
58058
57858
|
const u3v = mod3(u2v * u2, P2);
|
|
58059
57859
|
const u5v3 = mod3(u3v * u2v * v2, P2);
|
|
@@ -58067,9 +57867,6 @@ function dom4(data, ctx, phflag) {
|
|
|
58067
57867
|
throw new Error("context must be smaller than 255, got: " + ctx.length);
|
|
58068
57868
|
return concatBytes2(asciiToBytes("SigEd448"), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
|
58069
57869
|
}
|
|
58070
|
-
function ed4(opts) {
|
|
58071
|
-
return eddsa(ed448_Point, shake256_114, Object.assign({ adjustScalarBytes: adjustScalarBytes2, domain: dom4 }, opts));
|
|
58072
|
-
}
|
|
58073
57870
|
function map_to_curve_elligator2_curve448(u2) {
|
|
58074
57871
|
let tv1 = Fp2.sqr(u2);
|
|
58075
57872
|
let e1 = Fp2.eql(tv1, Fp2.ONE);
|
|
@@ -58141,8 +57938,9 @@ function map_to_curve_elligator2_edwards448(u2) {
|
|
|
58141
57938
|
return { x: Fp2.mul(xEn, inv[0]), y: Fp2.mul(yEn, inv[1]) };
|
|
58142
57939
|
}
|
|
58143
57940
|
function calcElligatorDecafMap(r0) {
|
|
58144
|
-
const { d: d2
|
|
58145
|
-
const
|
|
57941
|
+
const { d: d2 } = ed448_CURVE;
|
|
57942
|
+
const P2 = Fp2.ORDER;
|
|
57943
|
+
const mod4 = (n2) => Fp2.create(n2);
|
|
58146
57944
|
const r2 = mod4(-(r0 * r0));
|
|
58147
57945
|
const u0 = mod4(d2 * (r2 - _1n9));
|
|
58148
57946
|
const u1 = mod4((u0 + _1n9) * (u0 - r2));
|
|
@@ -58162,55 +57960,78 @@ function calcElligatorDecafMap(r0) {
|
|
|
58162
57960
|
const W1 = mod4(s22 + _1n9);
|
|
58163
57961
|
const W2 = mod4(s22 - _1n9);
|
|
58164
57962
|
const W3 = mod4(v_prime * s2 * (r2 - _1n9) * ONE_MINUS_TWO_D + sgn);
|
|
58165
|
-
return new
|
|
57963
|
+
return new ed448.Point(mod4(W0 * W3), mod4(W2 * W1), mod4(W1 * W3), mod4(W0 * W2));
|
|
57964
|
+
}
|
|
57965
|
+
function decaf448_map(bytes) {
|
|
57966
|
+
abytes3(bytes, 112);
|
|
57967
|
+
const skipValidation = true;
|
|
57968
|
+
const r1 = Fp448.create(Fp448.fromBytes(bytes.subarray(0, 56), skipValidation));
|
|
57969
|
+
const R1 = calcElligatorDecafMap(r1);
|
|
57970
|
+
const r2 = Fp448.create(Fp448.fromBytes(bytes.subarray(56, 112), skipValidation));
|
|
57971
|
+
const R2 = calcElligatorDecafMap(r2);
|
|
57972
|
+
return new _DecafPoint(R1.add(R2));
|
|
57973
|
+
}
|
|
57974
|
+
function edwardsToMontgomeryPub2(edwardsPub) {
|
|
57975
|
+
return ed448.utils.toMontgomery(ensureBytes("pub", edwardsPub));
|
|
58166
57976
|
}
|
|
58167
|
-
var
|
|
57977
|
+
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;
|
|
58168
57978
|
var init_ed448 = __esm({
|
|
58169
|
-
"
|
|
57979
|
+
"../../node_modules/@noble/curves/esm/ed448.js"() {
|
|
58170
57980
|
init_sha32();
|
|
58171
57981
|
init_utils2();
|
|
57982
|
+
init_curve2();
|
|
58172
57983
|
init_edwards();
|
|
58173
57984
|
init_hash_to_curve();
|
|
58174
57985
|
init_modular2();
|
|
58175
57986
|
init_montgomery2();
|
|
58176
|
-
init_oprf();
|
|
58177
57987
|
init_utils3();
|
|
58178
|
-
|
|
58179
|
-
|
|
58180
|
-
p: ed448_CURVE_p,
|
|
57988
|
+
ed448_CURVE = {
|
|
57989
|
+
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
|
58181
57990
|
n: BigInt("0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffff7cca23e9c44edb49aed63690216cc2728dc58f552378c292ab5844f3"),
|
|
58182
57991
|
h: BigInt(4),
|
|
58183
57992
|
a: BigInt(1),
|
|
58184
57993
|
d: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffff6756"),
|
|
58185
57994
|
Gx: BigInt("0x4f1970c66bed0ded221d15a622bf36da9e146570470f1767ea6de324a3d3a46412ae1af72ab66511433b80e18b00938e2626a82bc70cc05e"),
|
|
58186
57995
|
Gy: BigInt("0x693f46716eb6bc248876203756c9c7624bea73736ca3984087789c1e05a0c2d73ad3ff1ce67c39c4fdbd132c4ed7c8ad9808795bf230fa14")
|
|
58187
|
-
}
|
|
58188
|
-
E448_CURVE =
|
|
57996
|
+
};
|
|
57997
|
+
E448_CURVE = Object.assign({}, ed448_CURVE, {
|
|
58189
57998
|
d: BigInt("0xd78b4bdc7f0daf19f24f38c29373a2ccad46157242a50f37809b1da3412a12e79ccc9c81264cfe9ad080997058fb61c4243cc32dbaa156b9"),
|
|
58190
57999
|
Gx: BigInt("0x79a70b2b70400553ae7c9df416c792c61128751ac92969240c25a07d728bdc93e21f7787ed6972249de732f38496cd11698713093e9c04fc"),
|
|
58191
58000
|
Gy: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffff80000000000000000000000000000000000000000000000000000001")
|
|
58192
|
-
})
|
|
58001
|
+
});
|
|
58193
58002
|
shake256_114 = /* @__PURE__ */ createHasher2(() => shake2562.create({ dkLen: 114 }));
|
|
58194
58003
|
shake256_64 = /* @__PURE__ */ createHasher2(() => shake2562.create({ dkLen: 64 }));
|
|
58195
58004
|
_1n9 = BigInt(1);
|
|
58196
58005
|
_2n7 = BigInt(2);
|
|
58197
58006
|
_3n3 = BigInt(3);
|
|
58198
|
-
_4n2 =
|
|
58007
|
+
_4n2 = BigInt(4);
|
|
58199
58008
|
_11n = BigInt(11);
|
|
58200
58009
|
_22n = BigInt(22);
|
|
58201
58010
|
_44n = BigInt(44);
|
|
58202
58011
|
_88n = BigInt(88);
|
|
58203
58012
|
_223n = BigInt(223);
|
|
58204
|
-
Fp2 = /* @__PURE__ */ (() => Field(
|
|
58013
|
+
Fp2 = /* @__PURE__ */ (() => Field(ed448_CURVE.p, { BITS: 456, isLE: true }))();
|
|
58205
58014
|
Fn2 = /* @__PURE__ */ (() => Field(ed448_CURVE.n, { BITS: 456, isLE: true }))();
|
|
58206
|
-
Fp448 = /* @__PURE__ */ (() => Field(
|
|
58015
|
+
Fp448 = /* @__PURE__ */ (() => Field(ed448_CURVE.p, { BITS: 448, isLE: true }))();
|
|
58207
58016
|
Fn448 = /* @__PURE__ */ (() => Field(ed448_CURVE.n, { BITS: 448, isLE: true }))();
|
|
58208
|
-
|
|
58209
|
-
|
|
58210
|
-
|
|
58211
|
-
|
|
58017
|
+
ED448_DEF = /* @__PURE__ */ (() => ({
|
|
58018
|
+
...ed448_CURVE,
|
|
58019
|
+
Fp: Fp2,
|
|
58020
|
+
Fn: Fn2,
|
|
58021
|
+
nBitLength: Fn2.BITS,
|
|
58022
|
+
hash: shake256_114,
|
|
58023
|
+
adjustScalarBytes: adjustScalarBytes2,
|
|
58024
|
+
domain: dom4,
|
|
58025
|
+
uvRatio: uvRatio2
|
|
58026
|
+
}))();
|
|
58027
|
+
ed448 = twistedEdwards(ED448_DEF);
|
|
58028
|
+
ed448ph = /* @__PURE__ */ (() => twistedEdwards({
|
|
58029
|
+
...ED448_DEF,
|
|
58030
|
+
prehash: shake256_64
|
|
58031
|
+
}))();
|
|
58032
|
+
E448 = edwards(E448_CURVE);
|
|
58212
58033
|
x448 = /* @__PURE__ */ (() => {
|
|
58213
|
-
const P2 =
|
|
58034
|
+
const P2 = ed448_CURVE.p;
|
|
58214
58035
|
return montgomery2({
|
|
58215
58036
|
P: P2,
|
|
58216
58037
|
type: "x448",
|
|
@@ -58222,12 +58043,12 @@ var init_ed448 = __esm({
|
|
|
58222
58043
|
adjustScalarBytes: adjustScalarBytes2
|
|
58223
58044
|
});
|
|
58224
58045
|
})();
|
|
58225
|
-
ELL2_C12 = /* @__PURE__ */ (() => (
|
|
58046
|
+
ELL2_C12 = /* @__PURE__ */ (() => (Fp2.ORDER - BigInt(3)) / BigInt(4))();
|
|
58226
58047
|
ELL2_J = /* @__PURE__ */ BigInt(156326);
|
|
58227
|
-
ed448_hasher = /* @__PURE__ */ (() => createHasher3(
|
|
58048
|
+
ed448_hasher = /* @__PURE__ */ (() => createHasher3(ed448.Point, (scalars) => map_to_curve_elligator2_edwards448(scalars[0]), {
|
|
58228
58049
|
DST: "edwards448_XOF:SHAKE256_ELL2_RO_",
|
|
58229
58050
|
encodeDST: "edwards448_XOF:SHAKE256_ELL2_NU_",
|
|
58230
|
-
p:
|
|
58051
|
+
p: Fp2.ORDER,
|
|
58231
58052
|
m: 1,
|
|
58232
58053
|
k: 224,
|
|
58233
58054
|
expand: "xof",
|
|
@@ -58239,20 +58060,11 @@ var init_ed448 = __esm({
|
|
|
58239
58060
|
INVSQRT_MINUS_D = /* @__PURE__ */ BigInt("315019913931389607337177038330951043522456072897266928557328499619017160722351061360252776265186336876723201881398623946864393857820716");
|
|
58240
58061
|
invertSqrt2 = (number3) => uvRatio2(_1n9, number3);
|
|
58241
58062
|
_DecafPoint = class __DecafPoint extends PrimeEdwardsPoint {
|
|
58242
|
-
// The following gymnastics is done because typescript strips comments otherwise
|
|
58243
|
-
// prettier-ignore
|
|
58244
|
-
static BASE = /* @__PURE__ */ (() => new __DecafPoint(ed448_Point.BASE).multiplyUnsafe(_2n7))();
|
|
58245
|
-
// prettier-ignore
|
|
58246
|
-
static ZERO = /* @__PURE__ */ (() => new __DecafPoint(ed448_Point.ZERO))();
|
|
58247
|
-
// prettier-ignore
|
|
58248
|
-
static Fp = /* @__PURE__ */ (() => Fp448)();
|
|
58249
|
-
// prettier-ignore
|
|
58250
|
-
static Fn = /* @__PURE__ */ (() => Fn448)();
|
|
58251
58063
|
constructor(ep) {
|
|
58252
58064
|
super(ep);
|
|
58253
58065
|
}
|
|
58254
58066
|
static fromAffine(ap) {
|
|
58255
|
-
return new __DecafPoint(
|
|
58067
|
+
return new __DecafPoint(ed448.Point.fromAffine(ap));
|
|
58256
58068
|
}
|
|
58257
58069
|
assertSame(other) {
|
|
58258
58070
|
if (!(other instanceof __DecafPoint))
|
|
@@ -58261,9 +58073,14 @@ var init_ed448 = __esm({
|
|
|
58261
58073
|
init(ep) {
|
|
58262
58074
|
return new __DecafPoint(ep);
|
|
58263
58075
|
}
|
|
58076
|
+
/** @deprecated use `import { decaf448_hasher } from '@noble/curves/ed448.js';` */
|
|
58077
|
+
static hashToCurve(hex3) {
|
|
58078
|
+
return decaf448_map(ensureBytes("decafHash", hex3, 112));
|
|
58079
|
+
}
|
|
58264
58080
|
static fromBytes(bytes) {
|
|
58265
58081
|
abytes3(bytes, 56);
|
|
58266
|
-
const { d: d2
|
|
58082
|
+
const { d: d2 } = ed448_CURVE;
|
|
58083
|
+
const P2 = Fp2.ORDER;
|
|
58267
58084
|
const mod4 = (n2) => Fp448.create(n2);
|
|
58268
58085
|
const s2 = Fp448.fromBytes(bytes);
|
|
58269
58086
|
if (!equalBytes2(Fn448.toBytes(s2), bytes) || isNegativeLE(s2, P2))
|
|
@@ -58281,7 +58098,7 @@ var init_ed448 = __esm({
|
|
|
58281
58098
|
const t2 = mod4(x2 * y2);
|
|
58282
58099
|
if (!isValid2)
|
|
58283
58100
|
throw new Error("invalid decaf448 encoding 2");
|
|
58284
|
-
return new __DecafPoint(new
|
|
58101
|
+
return new __DecafPoint(new ed448.Point(x2, y2, _1n9, t2));
|
|
58285
58102
|
}
|
|
58286
58103
|
/**
|
|
58287
58104
|
* Converts decaf-encoded string to decaf point.
|
|
@@ -58289,7 +58106,11 @@ var init_ed448 = __esm({
|
|
|
58289
58106
|
* @param hex Decaf-encoded 56 bytes. Not every 56-byte string is valid decaf encoding
|
|
58290
58107
|
*/
|
|
58291
58108
|
static fromHex(hex3) {
|
|
58292
|
-
return __DecafPoint.fromBytes(
|
|
58109
|
+
return __DecafPoint.fromBytes(ensureBytes("decafHex", hex3, 56));
|
|
58110
|
+
}
|
|
58111
|
+
/** @deprecated use `import { pippenger } from '@noble/curves/abstract/curve.js';` */
|
|
58112
|
+
static msm(points, scalars) {
|
|
58113
|
+
return pippenger(__DecafPoint, Fn2, points, scalars);
|
|
58293
58114
|
}
|
|
58294
58115
|
/**
|
|
58295
58116
|
* Encodes decaf point to Uint8Array.
|
|
@@ -58297,8 +58118,8 @@ var init_ed448 = __esm({
|
|
|
58297
58118
|
*/
|
|
58298
58119
|
toBytes() {
|
|
58299
58120
|
const { X: X2, Z: Z2, T: T2 } = this.ep;
|
|
58300
|
-
const P2 =
|
|
58301
|
-
const mod4 = (n2) =>
|
|
58121
|
+
const P2 = Fp2.ORDER;
|
|
58122
|
+
const mod4 = (n2) => Fp2.create(n2);
|
|
58302
58123
|
const u1 = mod4(mod4(X2 + T2) * mod4(X2 - T2));
|
|
58303
58124
|
const x2 = mod4(X2 * X2);
|
|
58304
58125
|
const { value: invsqrt } = invertSqrt2(mod4(u1 * ONE_MINUS_D * x2));
|
|
@@ -58319,76 +58140,57 @@ var init_ed448 = __esm({
|
|
|
58319
58140
|
this.assertSame(other);
|
|
58320
58141
|
const { X: X1, Y: Y1 } = this.ep;
|
|
58321
58142
|
const { X: X2, Y: Y2 } = other.ep;
|
|
58322
|
-
return
|
|
58143
|
+
return Fp2.create(X1 * Y2) === Fp2.create(Y1 * X2);
|
|
58323
58144
|
}
|
|
58324
58145
|
is0() {
|
|
58325
58146
|
return this.equals(__DecafPoint.ZERO);
|
|
58326
58147
|
}
|
|
58327
58148
|
};
|
|
58149
|
+
_DecafPoint.BASE = /* @__PURE__ */ (() => new _DecafPoint(ed448.Point.BASE).multiplyUnsafe(_2n7))();
|
|
58150
|
+
_DecafPoint.ZERO = /* @__PURE__ */ (() => new _DecafPoint(ed448.Point.ZERO))();
|
|
58151
|
+
_DecafPoint.Fp = /* @__PURE__ */ (() => Fp448)();
|
|
58152
|
+
_DecafPoint.Fn = /* @__PURE__ */ (() => Fn448)();
|
|
58328
58153
|
decaf448 = { Point: _DecafPoint };
|
|
58329
58154
|
decaf448_hasher = {
|
|
58330
|
-
Point: _DecafPoint,
|
|
58331
58155
|
hashToCurve(msg, options) {
|
|
58332
58156
|
const DST = options?.DST || "decaf448_XOF:SHAKE256_D448MAP_RO_";
|
|
58333
|
-
return
|
|
58157
|
+
return decaf448_map(expand_message_xof(msg, DST, 112, 224, shake2562));
|
|
58334
58158
|
},
|
|
58335
|
-
|
|
58336
|
-
|
|
58337
|
-
|
|
58338
|
-
* it must use 84-byte xof (56+56/2), not 64.
|
|
58339
|
-
*/
|
|
58159
|
+
// Warning: has big modulo bias of 2^-64.
|
|
58160
|
+
// RFC is invalid. RFC says "use 64-byte xof", while for 2^-112 bias
|
|
58161
|
+
// it must use 84-byte xof (56+56/2), not 64.
|
|
58340
58162
|
hashToScalar(msg, options = { DST: _DST_scalar }) {
|
|
58341
58163
|
const xof = expand_message_xof(msg, options.DST, 64, 256, shake2562);
|
|
58342
58164
|
return Fn448.create(bytesToNumberLE2(xof));
|
|
58343
|
-
},
|
|
58344
|
-
/**
|
|
58345
|
-
* HashToCurve-like construction based on RFC 9496 (Element Derivation).
|
|
58346
|
-
* Converts 112 uniform random bytes into a curve point.
|
|
58347
|
-
*
|
|
58348
|
-
* WARNING: This represents an older hash-to-curve construction, preceding the finalization of RFC 9380.
|
|
58349
|
-
* It was later reused as a component in the newer `hash_to_ristretto255` function defined in RFC 9380.
|
|
58350
|
-
*/
|
|
58351
|
-
deriveToCurve(bytes) {
|
|
58352
|
-
abytes3(bytes, 112);
|
|
58353
|
-
const skipValidation = true;
|
|
58354
|
-
const r1 = Fp448.create(Fp448.fromBytes(bytes.subarray(0, 56), skipValidation));
|
|
58355
|
-
const R1 = calcElligatorDecafMap(r1);
|
|
58356
|
-
const r2 = Fp448.create(Fp448.fromBytes(bytes.subarray(56, 112), skipValidation));
|
|
58357
|
-
const R2 = calcElligatorDecafMap(r2);
|
|
58358
|
-
return new _DecafPoint(R1.add(R2));
|
|
58359
58165
|
}
|
|
58360
58166
|
};
|
|
58361
|
-
decaf448_oprf = /* @__PURE__ */ (() => createORPF({
|
|
58362
|
-
name: "decaf448-SHAKE256",
|
|
58363
|
-
Point: _DecafPoint,
|
|
58364
|
-
hash: (msg) => shake2562(msg, { dkLen: 64 }),
|
|
58365
|
-
hashToGroup: decaf448_hasher.hashToCurve,
|
|
58366
|
-
hashToScalar: decaf448_hasher.hashToScalar
|
|
58367
|
-
}))();
|
|
58368
58167
|
ED448_TORSION_SUBGROUP = [
|
|
58369
58168
|
"010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
58370
58169
|
"fefffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffff00",
|
|
58371
58170
|
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
|
58372
58171
|
"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080"
|
|
58373
58172
|
];
|
|
58173
|
+
DecafPoint = _DecafPoint;
|
|
58174
|
+
hashToCurve2 = /* @__PURE__ */ (() => ed448_hasher.hashToCurve)();
|
|
58175
|
+
encodeToCurve2 = /* @__PURE__ */ (() => ed448_hasher.encodeToCurve)();
|
|
58176
|
+
hashToDecaf448 = /* @__PURE__ */ (() => decaf448_hasher.hashToCurve)();
|
|
58177
|
+
hash_to_decaf448 = /* @__PURE__ */ (() => decaf448_hasher.hashToCurve)();
|
|
58178
|
+
edwardsToMontgomery2 = edwardsToMontgomeryPub2;
|
|
58374
58179
|
}
|
|
58375
58180
|
});
|
|
58376
58181
|
|
|
58377
|
-
//
|
|
58378
|
-
var
|
|
58182
|
+
// ../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js
|
|
58183
|
+
var HMAC, hmac2;
|
|
58379
58184
|
var init_hmac2 = __esm({
|
|
58380
|
-
"
|
|
58185
|
+
"../../node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js"() {
|
|
58381
58186
|
init_utils2();
|
|
58382
|
-
|
|
58383
|
-
|
|
58384
|
-
|
|
58385
|
-
|
|
58386
|
-
|
|
58387
|
-
finished = false;
|
|
58388
|
-
destroyed = false;
|
|
58389
|
-
constructor(hash2, key) {
|
|
58187
|
+
HMAC = class extends Hash {
|
|
58188
|
+
constructor(hash2, _key) {
|
|
58189
|
+
super();
|
|
58190
|
+
this.finished = false;
|
|
58191
|
+
this.destroyed = false;
|
|
58390
58192
|
ahash2(hash2);
|
|
58391
|
-
|
|
58193
|
+
const key = toBytes(_key);
|
|
58392
58194
|
this.iHash = hash2.create();
|
|
58393
58195
|
if (typeof this.iHash.update !== "function")
|
|
58394
58196
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
@@ -58413,7 +58215,7 @@ var init_hmac2 = __esm({
|
|
|
58413
58215
|
}
|
|
58414
58216
|
digestInto(out) {
|
|
58415
58217
|
aexists3(this);
|
|
58416
|
-
abytes3(out, this.outputLen
|
|
58218
|
+
abytes3(out, this.outputLen);
|
|
58417
58219
|
this.finished = true;
|
|
58418
58220
|
this.iHash.digestInto(out);
|
|
58419
58221
|
this.oHash.update(out);
|
|
@@ -58426,7 +58228,7 @@ var init_hmac2 = __esm({
|
|
|
58426
58228
|
return out;
|
|
58427
58229
|
}
|
|
58428
58230
|
_cloneInto(to) {
|
|
58429
|
-
to
|
|
58231
|
+
to || (to = Object.create(Object.getPrototypeOf(this), {}));
|
|
58430
58232
|
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
58431
58233
|
to = to;
|
|
58432
58234
|
to.finished = finished;
|
|
@@ -58446,12 +58248,12 @@ var init_hmac2 = __esm({
|
|
|
58446
58248
|
this.iHash.destroy();
|
|
58447
58249
|
}
|
|
58448
58250
|
};
|
|
58449
|
-
hmac2 = (hash2, key, message) => new
|
|
58450
|
-
hmac2.create = (hash2, key) => new
|
|
58251
|
+
hmac2 = (hash2, key, message) => new HMAC(hash2, key).update(message).digest();
|
|
58252
|
+
hmac2.create = (hash2, key) => new HMAC(hash2, key);
|
|
58451
58253
|
}
|
|
58452
58254
|
});
|
|
58453
58255
|
|
|
58454
|
-
//
|
|
58256
|
+
// ../../node_modules/@noble/curves/esm/abstract/weierstrass.js
|
|
58455
58257
|
function _splitEndoScalar(k2, basis, n2) {
|
|
58456
58258
|
const [[a1, b1], [a2, b2]] = basis;
|
|
58457
58259
|
const c1 = divNearest(b2 * k2, n2);
|
|
@@ -58480,24 +58282,42 @@ function validateSigOpts(opts, def) {
|
|
|
58480
58282
|
for (let optName of Object.keys(def)) {
|
|
58481
58283
|
optsn[optName] = opts[optName] === void 0 ? def[optName] : opts[optName];
|
|
58482
58284
|
}
|
|
58483
|
-
|
|
58484
|
-
|
|
58285
|
+
_abool2(optsn.lowS, "lowS");
|
|
58286
|
+
_abool2(optsn.prehash, "prehash");
|
|
58485
58287
|
if (optsn.format !== void 0)
|
|
58486
58288
|
validateSigFormat(optsn.format);
|
|
58487
58289
|
return optsn;
|
|
58488
58290
|
}
|
|
58489
|
-
function
|
|
58490
|
-
const
|
|
58291
|
+
function _normFnElement(Fn3, key) {
|
|
58292
|
+
const { BYTES: expected } = Fn3;
|
|
58293
|
+
let num;
|
|
58294
|
+
if (typeof key === "bigint") {
|
|
58295
|
+
num = key;
|
|
58296
|
+
} else {
|
|
58297
|
+
let bytes = ensureBytes("private key", key);
|
|
58298
|
+
try {
|
|
58299
|
+
num = Fn3.fromBytes(bytes);
|
|
58300
|
+
} catch (error2) {
|
|
58301
|
+
throw new Error(`invalid private key: expected ui8a of size ${expected}, got ${typeof key}`);
|
|
58302
|
+
}
|
|
58303
|
+
}
|
|
58304
|
+
if (!Fn3.isValidNot0(num))
|
|
58305
|
+
throw new Error("invalid private key: out of range [1..N-1]");
|
|
58306
|
+
return num;
|
|
58307
|
+
}
|
|
58308
|
+
function weierstrassN(params, extraOpts = {}) {
|
|
58309
|
+
const validated = _createCurveFields("weierstrass", params, extraOpts);
|
|
58491
58310
|
const { Fp: Fp3, Fn: Fn3 } = validated;
|
|
58492
58311
|
let CURVE = validated.CURVE;
|
|
58493
58312
|
const { h: cofactor, n: CURVE_ORDER } = CURVE;
|
|
58494
|
-
|
|
58313
|
+
_validateObject(extraOpts, {}, {
|
|
58495
58314
|
allowInfinityPoint: "boolean",
|
|
58496
58315
|
clearCofactor: "function",
|
|
58497
58316
|
isTorsionFree: "function",
|
|
58498
58317
|
fromBytes: "function",
|
|
58499
58318
|
toBytes: "function",
|
|
58500
|
-
endo: "object"
|
|
58319
|
+
endo: "object",
|
|
58320
|
+
wrapPrivateKey: "boolean"
|
|
58501
58321
|
});
|
|
58502
58322
|
const { endo } = extraOpts;
|
|
58503
58323
|
if (endo) {
|
|
@@ -58513,7 +58333,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58513
58333
|
function pointToBytes(_c, point, isCompressed) {
|
|
58514
58334
|
const { x: x2, y: y2 } = point.toAffine();
|
|
58515
58335
|
const bx = Fp3.toBytes(x2);
|
|
58516
|
-
|
|
58336
|
+
_abool2(isCompressed, "isCompressed");
|
|
58517
58337
|
if (isCompressed) {
|
|
58518
58338
|
assertCompressionIsSupported();
|
|
58519
58339
|
const hasEvenY = !Fp3.isOdd(y2);
|
|
@@ -58523,7 +58343,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58523
58343
|
}
|
|
58524
58344
|
}
|
|
58525
58345
|
function pointFromBytes(bytes) {
|
|
58526
|
-
|
|
58346
|
+
_abytes2(bytes, void 0, "Point");
|
|
58527
58347
|
const { publicKey: comp, publicKeyUncompressed: uncomp } = lengths;
|
|
58528
58348
|
const length = bytes.length;
|
|
58529
58349
|
const head = bytes[0];
|
|
@@ -58541,9 +58361,9 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58541
58361
|
throw new Error("bad point: is not on curve, sqrt error" + err);
|
|
58542
58362
|
}
|
|
58543
58363
|
assertCompressionIsSupported();
|
|
58544
|
-
const
|
|
58545
|
-
const
|
|
58546
|
-
if (
|
|
58364
|
+
const isYOdd = Fp3.isOdd(y3);
|
|
58365
|
+
const isHeadOdd = (head & 1) === 1;
|
|
58366
|
+
if (isHeadOdd !== isYOdd)
|
|
58547
58367
|
y3 = Fp3.neg(y3);
|
|
58548
58368
|
return { x: x2, y: y3 };
|
|
58549
58369
|
} else if (length === uncomp && head === 4) {
|
|
@@ -58582,7 +58402,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58582
58402
|
}
|
|
58583
58403
|
function aprjpoint(other) {
|
|
58584
58404
|
if (!(other instanceof Point))
|
|
58585
|
-
throw new Error("
|
|
58405
|
+
throw new Error("ProjectivePoint expected");
|
|
58586
58406
|
}
|
|
58587
58407
|
function splitEndoScalarN(k2) {
|
|
58588
58408
|
if (!endo || !endo.basises)
|
|
@@ -58627,18 +58447,6 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58627
58447
|
return k1p.add(k2p);
|
|
58628
58448
|
}
|
|
58629
58449
|
class Point {
|
|
58630
|
-
// base / generator point
|
|
58631
|
-
static BASE = new Point(CURVE.Gx, CURVE.Gy, Fp3.ONE);
|
|
58632
|
-
// zero / infinity / identity point
|
|
58633
|
-
static ZERO = new Point(Fp3.ZERO, Fp3.ONE, Fp3.ZERO);
|
|
58634
|
-
// 0, 1, 0
|
|
58635
|
-
// math field
|
|
58636
|
-
static Fp = Fp3;
|
|
58637
|
-
// scalar field
|
|
58638
|
-
static Fn = Fn3;
|
|
58639
|
-
X;
|
|
58640
|
-
Y;
|
|
58641
|
-
Z;
|
|
58642
58450
|
/** Does NOT validate if the point is valid. Use `.assertValidity()`. */
|
|
58643
58451
|
constructor(X2, Y2, Z2) {
|
|
58644
58452
|
this.X = acoord("x", X2);
|
|
@@ -58661,12 +58469,12 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58661
58469
|
return new Point(x2, y2, Fp3.ONE);
|
|
58662
58470
|
}
|
|
58663
58471
|
static fromBytes(bytes) {
|
|
58664
|
-
const P2 = Point.fromAffine(decodePoint(
|
|
58472
|
+
const P2 = Point.fromAffine(decodePoint(_abytes2(bytes, void 0, "point")));
|
|
58665
58473
|
P2.assertValidity();
|
|
58666
58474
|
return P2;
|
|
58667
58475
|
}
|
|
58668
58476
|
static fromHex(hex3) {
|
|
58669
|
-
return Point.fromBytes(
|
|
58477
|
+
return Point.fromBytes(ensureBytes("pointHex", hex3));
|
|
58670
58478
|
}
|
|
58671
58479
|
get x() {
|
|
58672
58480
|
return this.toAffine().x;
|
|
@@ -58863,6 +58671,10 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58863
58671
|
return wnaf.unsafe(p2, sc);
|
|
58864
58672
|
}
|
|
58865
58673
|
}
|
|
58674
|
+
multiplyAndAddUnsafe(Q2, a2, b2) {
|
|
58675
|
+
const sum = this.multiplyUnsafe(a2).add(Q2.multiplyUnsafe(b2));
|
|
58676
|
+
return sum.is0() ? void 0 : sum;
|
|
58677
|
+
}
|
|
58866
58678
|
/**
|
|
58867
58679
|
* Converts Projective point to affine (x, y) coordinates.
|
|
58868
58680
|
* @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
|
|
@@ -58894,7 +58706,7 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58894
58706
|
return this.multiplyUnsafe(cofactor).is0();
|
|
58895
58707
|
}
|
|
58896
58708
|
toBytes(isCompressed = true) {
|
|
58897
|
-
|
|
58709
|
+
_abool2(isCompressed, "isCompressed");
|
|
58898
58710
|
this.assertValidity();
|
|
58899
58711
|
return encodePoint(Point, this, isCompressed);
|
|
58900
58712
|
}
|
|
@@ -58904,7 +58716,36 @@ function weierstrass(params, extraOpts = {}) {
|
|
|
58904
58716
|
toString() {
|
|
58905
58717
|
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
58906
58718
|
}
|
|
58719
|
+
// TODO: remove
|
|
58720
|
+
get px() {
|
|
58721
|
+
return this.X;
|
|
58722
|
+
}
|
|
58723
|
+
get py() {
|
|
58724
|
+
return this.X;
|
|
58725
|
+
}
|
|
58726
|
+
get pz() {
|
|
58727
|
+
return this.Z;
|
|
58728
|
+
}
|
|
58729
|
+
toRawBytes(isCompressed = true) {
|
|
58730
|
+
return this.toBytes(isCompressed);
|
|
58731
|
+
}
|
|
58732
|
+
_setWindowSize(windowSize) {
|
|
58733
|
+
this.precompute(windowSize);
|
|
58734
|
+
}
|
|
58735
|
+
static normalizeZ(points) {
|
|
58736
|
+
return normalizeZ(Point, points);
|
|
58737
|
+
}
|
|
58738
|
+
static msm(points, scalars) {
|
|
58739
|
+
return pippenger(Point, Fn3, points, scalars);
|
|
58740
|
+
}
|
|
58741
|
+
static fromPrivateKey(privateKey) {
|
|
58742
|
+
return Point.BASE.multiply(_normFnElement(Fn3, privateKey));
|
|
58743
|
+
}
|
|
58907
58744
|
}
|
|
58745
|
+
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp3.ONE);
|
|
58746
|
+
Point.ZERO = new Point(Fp3.ZERO, Fp3.ONE, Fp3.ZERO);
|
|
58747
|
+
Point.Fp = Fp3;
|
|
58748
|
+
Point.Fn = Fn3;
|
|
58908
58749
|
const bits = Fn3.BITS;
|
|
58909
58750
|
const wnaf = new wNAF(Point, extraOpts.endo ? Math.ceil(bits / 2) : bits);
|
|
58910
58751
|
Point.BASE.precompute(8);
|
|
@@ -59029,8 +58870,7 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
59029
58870
|
const lengths = Object.assign(getWLengths(Point.Fp, Fn3), { seed: getMinHashLength(Fn3.ORDER) });
|
|
59030
58871
|
function isValidSecretKey(secretKey) {
|
|
59031
58872
|
try {
|
|
59032
|
-
|
|
59033
|
-
return Fn3.isValidNot0(num);
|
|
58873
|
+
return !!_normFnElement(Fn3, secretKey);
|
|
59034
58874
|
} catch (error2) {
|
|
59035
58875
|
return false;
|
|
59036
58876
|
}
|
|
@@ -59049,18 +58889,24 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
59049
58889
|
}
|
|
59050
58890
|
}
|
|
59051
58891
|
function randomSecretKey(seed = randomBytes_(lengths.seed)) {
|
|
59052
|
-
return mapHashToField(
|
|
58892
|
+
return mapHashToField(_abytes2(seed, lengths.seed, "seed"), Fn3.ORDER);
|
|
59053
58893
|
}
|
|
59054
58894
|
function getPublicKey(secretKey, isCompressed = true) {
|
|
59055
|
-
return Point.BASE.multiply(Fn3
|
|
58895
|
+
return Point.BASE.multiply(_normFnElement(Fn3, secretKey)).toBytes(isCompressed);
|
|
58896
|
+
}
|
|
58897
|
+
function keygen(seed) {
|
|
58898
|
+
const secretKey = randomSecretKey(seed);
|
|
58899
|
+
return { secretKey, publicKey: getPublicKey(secretKey) };
|
|
59056
58900
|
}
|
|
59057
58901
|
function isProbPub(item) {
|
|
58902
|
+
if (typeof item === "bigint")
|
|
58903
|
+
return false;
|
|
58904
|
+
if (item instanceof Point)
|
|
58905
|
+
return true;
|
|
59058
58906
|
const { secretKey, publicKey, publicKeyUncompressed } = lengths;
|
|
59059
|
-
if (
|
|
58907
|
+
if (Fn3.allowedLengths || secretKey === publicKey)
|
|
59060
58908
|
return void 0;
|
|
59061
|
-
|
|
59062
|
-
return void 0;
|
|
59063
|
-
const l2 = abytes3(item, void 0, "key").length;
|
|
58909
|
+
const l2 = ensureBytes("key", item).length;
|
|
59064
58910
|
return l2 === publicKey || l2 === publicKeyUncompressed;
|
|
59065
58911
|
}
|
|
59066
58912
|
function getSharedSecret(secretKeyA, publicKeyB, isCompressed = true) {
|
|
@@ -59068,40 +58914,46 @@ function ecdh(Point, ecdhOpts = {}) {
|
|
|
59068
58914
|
throw new Error("first arg must be private key");
|
|
59069
58915
|
if (isProbPub(publicKeyB) === false)
|
|
59070
58916
|
throw new Error("second arg must be public key");
|
|
59071
|
-
const s2 = Fn3
|
|
59072
|
-
const b2 = Point.
|
|
58917
|
+
const s2 = _normFnElement(Fn3, secretKeyA);
|
|
58918
|
+
const b2 = Point.fromHex(publicKeyB);
|
|
59073
58919
|
return b2.multiply(s2).toBytes(isCompressed);
|
|
59074
58920
|
}
|
|
59075
58921
|
const utils = {
|
|
59076
58922
|
isValidSecretKey,
|
|
59077
58923
|
isValidPublicKey,
|
|
59078
|
-
randomSecretKey
|
|
58924
|
+
randomSecretKey,
|
|
58925
|
+
// TODO: remove
|
|
58926
|
+
isValidPrivateKey: isValidSecretKey,
|
|
58927
|
+
randomPrivateKey: randomSecretKey,
|
|
58928
|
+
normPrivateKeyToScalar: (key) => _normFnElement(Fn3, key),
|
|
58929
|
+
precompute(windowSize = 8, point = Point.BASE) {
|
|
58930
|
+
return point.precompute(windowSize, false);
|
|
58931
|
+
}
|
|
59079
58932
|
};
|
|
59080
|
-
const keygen = createKeygen2(randomSecretKey, getPublicKey);
|
|
59081
58933
|
return Object.freeze({ getPublicKey, getSharedSecret, keygen, Point, utils, lengths });
|
|
59082
58934
|
}
|
|
59083
58935
|
function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
59084
58936
|
ahash2(hash2);
|
|
59085
|
-
|
|
58937
|
+
_validateObject(ecdsaOpts, {}, {
|
|
59086
58938
|
hmac: "function",
|
|
59087
58939
|
lowS: "boolean",
|
|
59088
58940
|
randomBytes: "function",
|
|
59089
58941
|
bits2int: "function",
|
|
59090
58942
|
bits2int_modN: "function"
|
|
59091
58943
|
});
|
|
59092
|
-
ecdsaOpts = Object.assign({}, ecdsaOpts);
|
|
59093
58944
|
const randomBytes3 = ecdsaOpts.randomBytes || randomBytes2;
|
|
59094
|
-
const
|
|
58945
|
+
const hmac4 = ecdsaOpts.hmac || ((key, ...msgs) => hmac2(hash2, key, concatBytes2(...msgs)));
|
|
59095
58946
|
const { Fp: Fp3, Fn: Fn3 } = Point;
|
|
59096
58947
|
const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn3;
|
|
59097
58948
|
const { keygen, getPublicKey, getSharedSecret, utils, lengths } = ecdh(Point, ecdsaOpts);
|
|
59098
58949
|
const defaultSigOpts = {
|
|
59099
|
-
prehash:
|
|
59100
|
-
lowS: typeof ecdsaOpts.lowS === "boolean" ? ecdsaOpts.lowS :
|
|
59101
|
-
format:
|
|
58950
|
+
prehash: false,
|
|
58951
|
+
lowS: typeof ecdsaOpts.lowS === "boolean" ? ecdsaOpts.lowS : false,
|
|
58952
|
+
format: void 0,
|
|
58953
|
+
//'compact' as ECDSASigFormat,
|
|
59102
58954
|
extraEntropy: false
|
|
59103
58955
|
};
|
|
59104
|
-
const
|
|
58956
|
+
const defaultSigOpts_format = "compact";
|
|
59105
58957
|
function isBiggerThanHalfOrder(number3) {
|
|
59106
58958
|
const HALF = CURVE_ORDER >> _1n10;
|
|
59107
58959
|
return number3 > HALF;
|
|
@@ -59111,36 +58963,25 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59111
58963
|
throw new Error(`invalid signature ${title}: out of range 1..Point.Fn.ORDER`);
|
|
59112
58964
|
return num;
|
|
59113
58965
|
}
|
|
59114
|
-
function assertSmallCofactor() {
|
|
59115
|
-
if (hasLargeCofactor)
|
|
59116
|
-
throw new Error('"recovered" sig type is not supported for cofactor >2 curves');
|
|
59117
|
-
}
|
|
59118
58966
|
function validateSigLength(bytes, format) {
|
|
59119
58967
|
validateSigFormat(format);
|
|
59120
58968
|
const size = lengths.signature;
|
|
59121
58969
|
const sizer = format === "compact" ? size : format === "recovered" ? size + 1 : void 0;
|
|
59122
|
-
return
|
|
58970
|
+
return _abytes2(bytes, sizer, `${format} signature`);
|
|
59123
58971
|
}
|
|
59124
58972
|
class Signature {
|
|
59125
|
-
r;
|
|
59126
|
-
s;
|
|
59127
|
-
recovery;
|
|
59128
58973
|
constructor(r2, s2, recovery) {
|
|
59129
58974
|
this.r = validateRS("r", r2);
|
|
59130
58975
|
this.s = validateRS("s", s2);
|
|
59131
|
-
if (recovery != null)
|
|
59132
|
-
assertSmallCofactor();
|
|
59133
|
-
if (![0, 1, 2, 3].includes(recovery))
|
|
59134
|
-
throw new Error("invalid recovery id");
|
|
58976
|
+
if (recovery != null)
|
|
59135
58977
|
this.recovery = recovery;
|
|
59136
|
-
}
|
|
59137
58978
|
Object.freeze(this);
|
|
59138
58979
|
}
|
|
59139
|
-
static fromBytes(bytes, format =
|
|
58980
|
+
static fromBytes(bytes, format = defaultSigOpts_format) {
|
|
59140
58981
|
validateSigLength(bytes, format);
|
|
59141
58982
|
let recid;
|
|
59142
58983
|
if (format === "der") {
|
|
59143
|
-
const { r: r3, s: s3 } = DER.toSig(
|
|
58984
|
+
const { r: r3, s: s3 } = DER.toSig(_abytes2(bytes));
|
|
59144
58985
|
return new Signature(r3, s3);
|
|
59145
58986
|
}
|
|
59146
58987
|
if (format === "recovered") {
|
|
@@ -59148,7 +58989,7 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59148
58989
|
format = "compact";
|
|
59149
58990
|
bytes = bytes.subarray(1);
|
|
59150
58991
|
}
|
|
59151
|
-
const L2 =
|
|
58992
|
+
const L2 = Fn3.BYTES;
|
|
59152
58993
|
const r2 = bytes.subarray(0, L2);
|
|
59153
58994
|
const s2 = bytes.subarray(L2, L2 * 2);
|
|
59154
58995
|
return new Signature(Fn3.fromBytes(r2), Fn3.fromBytes(s2), recid);
|
|
@@ -59156,30 +58997,29 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59156
58997
|
static fromHex(hex3, format) {
|
|
59157
58998
|
return this.fromBytes(hexToBytes3(hex3), format);
|
|
59158
58999
|
}
|
|
59159
|
-
assertRecovery() {
|
|
59160
|
-
const { recovery } = this;
|
|
59161
|
-
if (recovery == null)
|
|
59162
|
-
throw new Error("invalid recovery id: must be present");
|
|
59163
|
-
return recovery;
|
|
59164
|
-
}
|
|
59165
59000
|
addRecoveryBit(recovery) {
|
|
59166
59001
|
return new Signature(this.r, this.s, recovery);
|
|
59167
59002
|
}
|
|
59168
59003
|
recoverPublicKey(messageHash) {
|
|
59169
|
-
const
|
|
59170
|
-
const recovery = this
|
|
59171
|
-
|
|
59004
|
+
const FIELD_ORDER = Fp3.ORDER;
|
|
59005
|
+
const { r: r2, s: s2, recovery: rec } = this;
|
|
59006
|
+
if (rec == null || ![0, 1, 2, 3].includes(rec))
|
|
59007
|
+
throw new Error("recovery id invalid");
|
|
59008
|
+
const hasCofactor = CURVE_ORDER * _2n8 < FIELD_ORDER;
|
|
59009
|
+
if (hasCofactor && rec > 1)
|
|
59010
|
+
throw new Error("recovery id is ambiguous for h>1 curve");
|
|
59011
|
+
const radj = rec === 2 || rec === 3 ? r2 + CURVE_ORDER : r2;
|
|
59172
59012
|
if (!Fp3.isValid(radj))
|
|
59173
|
-
throw new Error("
|
|
59013
|
+
throw new Error("recovery id 2 or 3 invalid");
|
|
59174
59014
|
const x2 = Fp3.toBytes(radj);
|
|
59175
|
-
const R2 = Point.fromBytes(concatBytes2(pprefix((
|
|
59015
|
+
const R2 = Point.fromBytes(concatBytes2(pprefix((rec & 1) === 0), x2));
|
|
59176
59016
|
const ir2 = Fn3.inv(radj);
|
|
59177
|
-
const h2 = bits2int_modN(
|
|
59017
|
+
const h2 = bits2int_modN(ensureBytes("msgHash", messageHash));
|
|
59178
59018
|
const u1 = Fn3.create(-h2 * ir2);
|
|
59179
59019
|
const u2 = Fn3.create(s2 * ir2);
|
|
59180
59020
|
const Q2 = Point.BASE.multiplyUnsafe(u1).add(R2.multiplyUnsafe(u2));
|
|
59181
59021
|
if (Q2.is0())
|
|
59182
|
-
throw new Error("
|
|
59022
|
+
throw new Error("point at infinify");
|
|
59183
59023
|
Q2.assertValidity();
|
|
59184
59024
|
return Q2;
|
|
59185
59025
|
}
|
|
@@ -59187,22 +59027,46 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59187
59027
|
hasHighS() {
|
|
59188
59028
|
return isBiggerThanHalfOrder(this.s);
|
|
59189
59029
|
}
|
|
59190
|
-
toBytes(format =
|
|
59030
|
+
toBytes(format = defaultSigOpts_format) {
|
|
59191
59031
|
validateSigFormat(format);
|
|
59192
59032
|
if (format === "der")
|
|
59193
59033
|
return hexToBytes3(DER.hexFromSig(this));
|
|
59194
|
-
const
|
|
59195
|
-
const
|
|
59196
|
-
const sb = Fn3.toBytes(s2);
|
|
59034
|
+
const r2 = Fn3.toBytes(this.r);
|
|
59035
|
+
const s2 = Fn3.toBytes(this.s);
|
|
59197
59036
|
if (format === "recovered") {
|
|
59198
|
-
|
|
59199
|
-
|
|
59037
|
+
if (this.recovery == null)
|
|
59038
|
+
throw new Error("recovery bit must be present");
|
|
59039
|
+
return concatBytes2(Uint8Array.of(this.recovery), r2, s2);
|
|
59200
59040
|
}
|
|
59201
|
-
return concatBytes2(
|
|
59041
|
+
return concatBytes2(r2, s2);
|
|
59202
59042
|
}
|
|
59203
59043
|
toHex(format) {
|
|
59204
59044
|
return bytesToHex3(this.toBytes(format));
|
|
59205
59045
|
}
|
|
59046
|
+
// TODO: remove
|
|
59047
|
+
assertValidity() {
|
|
59048
|
+
}
|
|
59049
|
+
static fromCompact(hex3) {
|
|
59050
|
+
return Signature.fromBytes(ensureBytes("sig", hex3), "compact");
|
|
59051
|
+
}
|
|
59052
|
+
static fromDER(hex3) {
|
|
59053
|
+
return Signature.fromBytes(ensureBytes("sig", hex3), "der");
|
|
59054
|
+
}
|
|
59055
|
+
normalizeS() {
|
|
59056
|
+
return this.hasHighS() ? new Signature(this.r, Fn3.neg(this.s), this.recovery) : this;
|
|
59057
|
+
}
|
|
59058
|
+
toDERRawBytes() {
|
|
59059
|
+
return this.toBytes("der");
|
|
59060
|
+
}
|
|
59061
|
+
toDERHex() {
|
|
59062
|
+
return bytesToHex3(this.toBytes("der"));
|
|
59063
|
+
}
|
|
59064
|
+
toCompactRawBytes() {
|
|
59065
|
+
return this.toBytes("compact");
|
|
59066
|
+
}
|
|
59067
|
+
toCompactHex() {
|
|
59068
|
+
return bytesToHex3(this.toBytes("compact"));
|
|
59069
|
+
}
|
|
59206
59070
|
}
|
|
59207
59071
|
const bits2int = ecdsaOpts.bits2int || function bits2int_def(bytes) {
|
|
59208
59072
|
if (bytes.length > 8192)
|
|
@@ -59220,20 +59084,20 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59220
59084
|
return Fn3.toBytes(num);
|
|
59221
59085
|
}
|
|
59222
59086
|
function validateMsgAndHash(message, prehash) {
|
|
59223
|
-
|
|
59224
|
-
return prehash ?
|
|
59087
|
+
_abytes2(message, void 0, "message");
|
|
59088
|
+
return prehash ? _abytes2(hash2(message), void 0, "prehashed message") : message;
|
|
59225
59089
|
}
|
|
59226
|
-
function prepSig(message,
|
|
59090
|
+
function prepSig(message, privateKey, opts) {
|
|
59091
|
+
if (["recovered", "canonical"].some((k2) => k2 in opts))
|
|
59092
|
+
throw new Error("sign() legacy options not supported");
|
|
59227
59093
|
const { lowS, prehash, extraEntropy } = validateSigOpts(opts, defaultSigOpts);
|
|
59228
59094
|
message = validateMsgAndHash(message, prehash);
|
|
59229
59095
|
const h1int = bits2int_modN(message);
|
|
59230
|
-
const d2 = Fn3
|
|
59231
|
-
if (!Fn3.isValidNot0(d2))
|
|
59232
|
-
throw new Error("invalid private key");
|
|
59096
|
+
const d2 = _normFnElement(Fn3, privateKey);
|
|
59233
59097
|
const seedArgs = [int2octets(d2), int2octets(h1int)];
|
|
59234
59098
|
if (extraEntropy != null && extraEntropy !== false) {
|
|
59235
59099
|
const e = extraEntropy === true ? randomBytes3(lengths.secretKey) : extraEntropy;
|
|
59236
|
-
seedArgs.push(
|
|
59100
|
+
seedArgs.push(ensureBytes("extraEntropy", e));
|
|
59237
59101
|
}
|
|
59238
59102
|
const seed = concatBytes2(...seedArgs);
|
|
59239
59103
|
const m2 = h1int;
|
|
@@ -59255,27 +59119,54 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59255
59119
|
normS = Fn3.neg(s2);
|
|
59256
59120
|
recovery ^= 1;
|
|
59257
59121
|
}
|
|
59258
|
-
return new Signature(r2, normS,
|
|
59122
|
+
return new Signature(r2, normS, recovery);
|
|
59259
59123
|
}
|
|
59260
59124
|
return { seed, k2sig };
|
|
59261
59125
|
}
|
|
59262
59126
|
function sign(message, secretKey, opts = {}) {
|
|
59127
|
+
message = ensureBytes("message", message);
|
|
59263
59128
|
const { seed, k2sig } = prepSig(message, secretKey, opts);
|
|
59264
|
-
const drbg = createHmacDrbg(hash2.outputLen, Fn3.BYTES,
|
|
59129
|
+
const drbg = createHmacDrbg(hash2.outputLen, Fn3.BYTES, hmac4);
|
|
59265
59130
|
const sig = drbg(seed, k2sig);
|
|
59266
|
-
return sig
|
|
59131
|
+
return sig;
|
|
59132
|
+
}
|
|
59133
|
+
function tryParsingSig(sg) {
|
|
59134
|
+
let sig = void 0;
|
|
59135
|
+
const isHex = typeof sg === "string" || isBytes3(sg);
|
|
59136
|
+
const isObj = !isHex && sg !== null && typeof sg === "object" && typeof sg.r === "bigint" && typeof sg.s === "bigint";
|
|
59137
|
+
if (!isHex && !isObj)
|
|
59138
|
+
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
59139
|
+
if (isObj) {
|
|
59140
|
+
sig = new Signature(sg.r, sg.s);
|
|
59141
|
+
} else if (isHex) {
|
|
59142
|
+
try {
|
|
59143
|
+
sig = Signature.fromBytes(ensureBytes("sig", sg), "der");
|
|
59144
|
+
} catch (derError) {
|
|
59145
|
+
if (!(derError instanceof DER.Err))
|
|
59146
|
+
throw derError;
|
|
59147
|
+
}
|
|
59148
|
+
if (!sig) {
|
|
59149
|
+
try {
|
|
59150
|
+
sig = Signature.fromBytes(ensureBytes("sig", sg), "compact");
|
|
59151
|
+
} catch (error2) {
|
|
59152
|
+
return false;
|
|
59153
|
+
}
|
|
59154
|
+
}
|
|
59155
|
+
}
|
|
59156
|
+
if (!sig)
|
|
59157
|
+
return false;
|
|
59158
|
+
return sig;
|
|
59267
59159
|
}
|
|
59268
59160
|
function verify(signature, message, publicKey, opts = {}) {
|
|
59269
59161
|
const { lowS, prehash, format } = validateSigOpts(opts, defaultSigOpts);
|
|
59270
|
-
publicKey =
|
|
59271
|
-
message = validateMsgAndHash(message, prehash);
|
|
59272
|
-
if (
|
|
59273
|
-
|
|
59274
|
-
|
|
59275
|
-
|
|
59276
|
-
|
|
59162
|
+
publicKey = ensureBytes("publicKey", publicKey);
|
|
59163
|
+
message = validateMsgAndHash(ensureBytes("message", message), prehash);
|
|
59164
|
+
if ("strict" in opts)
|
|
59165
|
+
throw new Error("options.strict was renamed to lowS");
|
|
59166
|
+
const sig = format === void 0 ? tryParsingSig(signature) : Signature.fromBytes(ensureBytes("sig", signature), format);
|
|
59167
|
+
if (sig === false)
|
|
59168
|
+
return false;
|
|
59277
59169
|
try {
|
|
59278
|
-
const sig = Signature.fromBytes(signature, format);
|
|
59279
59170
|
const P2 = Point.fromBytes(publicKey);
|
|
59280
59171
|
if (lowS && sig.hasHighS())
|
|
59281
59172
|
return false;
|
|
@@ -59312,9 +59203,62 @@ function ecdsa(Point, hash2, ecdsaOpts = {}) {
|
|
|
59312
59203
|
hash: hash2
|
|
59313
59204
|
});
|
|
59314
59205
|
}
|
|
59206
|
+
function _weierstrass_legacy_opts_to_new(c2) {
|
|
59207
|
+
const CURVE = {
|
|
59208
|
+
a: c2.a,
|
|
59209
|
+
b: c2.b,
|
|
59210
|
+
p: c2.Fp.ORDER,
|
|
59211
|
+
n: c2.n,
|
|
59212
|
+
h: c2.h,
|
|
59213
|
+
Gx: c2.Gx,
|
|
59214
|
+
Gy: c2.Gy
|
|
59215
|
+
};
|
|
59216
|
+
const Fp3 = c2.Fp;
|
|
59217
|
+
let allowedLengths = c2.allowedPrivateKeyLengths ? Array.from(new Set(c2.allowedPrivateKeyLengths.map((l2) => Math.ceil(l2 / 2)))) : void 0;
|
|
59218
|
+
const Fn3 = Field(CURVE.n, {
|
|
59219
|
+
BITS: c2.nBitLength,
|
|
59220
|
+
allowedLengths,
|
|
59221
|
+
modFromBytes: c2.wrapPrivateKey
|
|
59222
|
+
});
|
|
59223
|
+
const curveOpts = {
|
|
59224
|
+
Fp: Fp3,
|
|
59225
|
+
Fn: Fn3,
|
|
59226
|
+
allowInfinityPoint: c2.allowInfinityPoint,
|
|
59227
|
+
endo: c2.endo,
|
|
59228
|
+
isTorsionFree: c2.isTorsionFree,
|
|
59229
|
+
clearCofactor: c2.clearCofactor,
|
|
59230
|
+
fromBytes: c2.fromBytes,
|
|
59231
|
+
toBytes: c2.toBytes
|
|
59232
|
+
};
|
|
59233
|
+
return { CURVE, curveOpts };
|
|
59234
|
+
}
|
|
59235
|
+
function _ecdsa_legacy_opts_to_new(c2) {
|
|
59236
|
+
const { CURVE, curveOpts } = _weierstrass_legacy_opts_to_new(c2);
|
|
59237
|
+
const ecdsaOpts = {
|
|
59238
|
+
hmac: c2.hmac,
|
|
59239
|
+
randomBytes: c2.randomBytes,
|
|
59240
|
+
lowS: c2.lowS,
|
|
59241
|
+
bits2int: c2.bits2int,
|
|
59242
|
+
bits2int_modN: c2.bits2int_modN
|
|
59243
|
+
};
|
|
59244
|
+
return { CURVE, curveOpts, hash: c2.hash, ecdsaOpts };
|
|
59245
|
+
}
|
|
59246
|
+
function _ecdsa_new_output_to_legacy(c2, _ecdsa) {
|
|
59247
|
+
const Point = _ecdsa.Point;
|
|
59248
|
+
return Object.assign({}, _ecdsa, {
|
|
59249
|
+
ProjectivePoint: Point,
|
|
59250
|
+
CURVE: Object.assign({}, c2, nLength(Point.Fn.ORDER, Point.Fn.BITS))
|
|
59251
|
+
});
|
|
59252
|
+
}
|
|
59253
|
+
function weierstrass(c2) {
|
|
59254
|
+
const { CURVE, curveOpts, hash: hash2, ecdsaOpts } = _ecdsa_legacy_opts_to_new(c2);
|
|
59255
|
+
const Point = weierstrassN(CURVE, curveOpts);
|
|
59256
|
+
const signs = ecdsa(Point, hash2, ecdsaOpts);
|
|
59257
|
+
return _ecdsa_new_output_to_legacy(c2, signs);
|
|
59258
|
+
}
|
|
59315
59259
|
var divNearest, DERErr, DER, _0n9, _1n10, _2n8, _3n4, _4n3;
|
|
59316
59260
|
var init_weierstrass = __esm({
|
|
59317
|
-
"
|
|
59261
|
+
"../../node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
|
|
59318
59262
|
init_hmac2();
|
|
59319
59263
|
init_utils2();
|
|
59320
59264
|
init_utils3();
|
|
@@ -59406,9 +59350,9 @@ var init_weierstrass = __esm({
|
|
|
59406
59350
|
return bytesToNumberBE(data);
|
|
59407
59351
|
}
|
|
59408
59352
|
},
|
|
59409
|
-
toSig(
|
|
59353
|
+
toSig(hex3) {
|
|
59410
59354
|
const { Err: E2, _int: int2, _tlv: tlv } = DER;
|
|
59411
|
-
const data =
|
|
59355
|
+
const data = ensureBytes("signature", hex3);
|
|
59412
59356
|
const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
|
|
59413
59357
|
if (seqLeftBytes.length)
|
|
59414
59358
|
throw new E2("invalid signature: left bytes after parsing");
|
|
@@ -59434,32 +59378,43 @@ var init_weierstrass = __esm({
|
|
|
59434
59378
|
}
|
|
59435
59379
|
});
|
|
59436
59380
|
|
|
59437
|
-
//
|
|
59381
|
+
// ../../node_modules/@noble/curves/esm/_shortw_utils.js
|
|
59382
|
+
function createCurve(curveDef, defHash) {
|
|
59383
|
+
const create = (hash2) => weierstrass({ ...curveDef, hash: hash2 });
|
|
59384
|
+
return { ...create(defHash), create };
|
|
59385
|
+
}
|
|
59386
|
+
var init_shortw_utils = __esm({
|
|
59387
|
+
"../../node_modules/@noble/curves/esm/_shortw_utils.js"() {
|
|
59388
|
+
init_weierstrass();
|
|
59389
|
+
}
|
|
59390
|
+
});
|
|
59391
|
+
|
|
59392
|
+
// ../../node_modules/@noble/curves/esm/nist.js
|
|
59438
59393
|
var nist_exports = {};
|
|
59439
59394
|
__export(nist_exports, {
|
|
59440
59395
|
p256: () => p256,
|
|
59441
59396
|
p256_hasher: () => p256_hasher,
|
|
59442
|
-
p256_oprf: () => p256_oprf,
|
|
59443
59397
|
p384: () => p384,
|
|
59444
59398
|
p384_hasher: () => p384_hasher,
|
|
59445
|
-
p384_oprf: () => p384_oprf,
|
|
59446
59399
|
p521: () => p521,
|
|
59447
59400
|
p521_hasher: () => p521_hasher,
|
|
59448
|
-
|
|
59401
|
+
secp256r1: () => secp256r1,
|
|
59402
|
+
secp384r1: () => secp384r1,
|
|
59403
|
+
secp521r1: () => secp521r1
|
|
59449
59404
|
});
|
|
59450
59405
|
function createSWU(Point, opts) {
|
|
59451
59406
|
const map2 = mapToCurveSimpleSWU(Point.Fp, opts);
|
|
59452
59407
|
return (scalars) => map2(scalars[0]);
|
|
59453
59408
|
}
|
|
59454
|
-
var p256_CURVE, p384_CURVE, p521_CURVE,
|
|
59409
|
+
var p256_CURVE, p384_CURVE, p521_CURVE, Fp256, Fp384, Fp521, p256, p256_hasher, p384, p384_hasher, p521, secp256r1, secp384r1, secp521r1, p521_hasher;
|
|
59455
59410
|
var init_nist = __esm({
|
|
59456
|
-
"
|
|
59411
|
+
"../../node_modules/@noble/curves/esm/nist.js"() {
|
|
59457
59412
|
init_sha22();
|
|
59413
|
+
init_shortw_utils();
|
|
59458
59414
|
init_hash_to_curve();
|
|
59459
59415
|
init_modular2();
|
|
59460
|
-
init_oprf();
|
|
59461
59416
|
init_weierstrass();
|
|
59462
|
-
p256_CURVE =
|
|
59417
|
+
p256_CURVE = {
|
|
59463
59418
|
p: BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),
|
|
59464
59419
|
n: BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),
|
|
59465
59420
|
h: BigInt(1),
|
|
@@ -59467,8 +59422,8 @@ var init_nist = __esm({
|
|
|
59467
59422
|
b: BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),
|
|
59468
59423
|
Gx: BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),
|
|
59469
59424
|
Gy: BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")
|
|
59470
|
-
}
|
|
59471
|
-
p384_CURVE =
|
|
59425
|
+
};
|
|
59426
|
+
p384_CURVE = {
|
|
59472
59427
|
p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),
|
|
59473
59428
|
n: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),
|
|
59474
59429
|
h: BigInt(1),
|
|
@@ -59476,8 +59431,8 @@ var init_nist = __esm({
|
|
|
59476
59431
|
b: BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),
|
|
59477
59432
|
Gx: BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),
|
|
59478
59433
|
Gy: BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")
|
|
59479
|
-
}
|
|
59480
|
-
p521_CURVE =
|
|
59434
|
+
};
|
|
59435
|
+
p521_CURVE = {
|
|
59481
59436
|
p: BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
|
|
59482
59437
|
n: BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),
|
|
59483
59438
|
h: BigInt(1),
|
|
@@ -59485,14 +59440,16 @@ var init_nist = __esm({
|
|
|
59485
59440
|
b: BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),
|
|
59486
59441
|
Gx: BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),
|
|
59487
59442
|
Gy: BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")
|
|
59488
|
-
}
|
|
59489
|
-
|
|
59490
|
-
|
|
59443
|
+
};
|
|
59444
|
+
Fp256 = Field(p256_CURVE.p);
|
|
59445
|
+
Fp384 = Field(p384_CURVE.p);
|
|
59446
|
+
Fp521 = Field(p521_CURVE.p);
|
|
59447
|
+
p256 = createCurve({ ...p256_CURVE, Fp: Fp256, lowS: false }, sha2562);
|
|
59491
59448
|
p256_hasher = /* @__PURE__ */ (() => {
|
|
59492
|
-
return createHasher3(
|
|
59449
|
+
return createHasher3(p256.Point, createSWU(p256.Point, {
|
|
59493
59450
|
A: p256_CURVE.a,
|
|
59494
59451
|
B: p256_CURVE.b,
|
|
59495
|
-
Z:
|
|
59452
|
+
Z: p256.Point.Fp.create(BigInt("-10"))
|
|
59496
59453
|
}), {
|
|
59497
59454
|
DST: "P256_XMD:SHA-256_SSWU_RO_",
|
|
59498
59455
|
encodeDST: "P256_XMD:SHA-256_SSWU_NU_",
|
|
@@ -59503,20 +59460,12 @@ var init_nist = __esm({
|
|
|
59503
59460
|
hash: sha2562
|
|
59504
59461
|
});
|
|
59505
59462
|
})();
|
|
59506
|
-
|
|
59507
|
-
name: "P256-SHA256",
|
|
59508
|
-
Point: p256_Point,
|
|
59509
|
-
hash: sha2562,
|
|
59510
|
-
hashToGroup: p256_hasher.hashToCurve,
|
|
59511
|
-
hashToScalar: p256_hasher.hashToScalar
|
|
59512
|
-
}))();
|
|
59513
|
-
p384_Point = /* @__PURE__ */ weierstrass(p384_CURVE);
|
|
59514
|
-
p384 = /* @__PURE__ */ ecdsa(p384_Point, sha3842);
|
|
59463
|
+
p384 = createCurve({ ...p384_CURVE, Fp: Fp384, lowS: false }, sha3842);
|
|
59515
59464
|
p384_hasher = /* @__PURE__ */ (() => {
|
|
59516
|
-
return createHasher3(
|
|
59465
|
+
return createHasher3(p384.Point, createSWU(p384.Point, {
|
|
59517
59466
|
A: p384_CURVE.a,
|
|
59518
59467
|
B: p384_CURVE.b,
|
|
59519
|
-
Z:
|
|
59468
|
+
Z: p384.Point.Fp.create(BigInt("-12"))
|
|
59520
59469
|
}), {
|
|
59521
59470
|
DST: "P384_XMD:SHA-384_SSWU_RO_",
|
|
59522
59471
|
encodeDST: "P384_XMD:SHA-384_SSWU_NU_",
|
|
@@ -59527,21 +59476,15 @@ var init_nist = __esm({
|
|
|
59527
59476
|
hash: sha3842
|
|
59528
59477
|
});
|
|
59529
59478
|
})();
|
|
59530
|
-
|
|
59531
|
-
|
|
59532
|
-
|
|
59533
|
-
|
|
59534
|
-
hashToGroup: p384_hasher.hashToCurve,
|
|
59535
|
-
hashToScalar: p384_hasher.hashToScalar
|
|
59536
|
-
}))();
|
|
59537
|
-
Fn521 = /* @__PURE__ */ (() => Field(p521_CURVE.n, { allowedLengths: [65, 66] }))();
|
|
59538
|
-
p521_Point = /* @__PURE__ */ weierstrass(p521_CURVE, { Fn: Fn521 });
|
|
59539
|
-
p521 = /* @__PURE__ */ ecdsa(p521_Point, sha5122);
|
|
59479
|
+
p521 = createCurve({ ...p521_CURVE, Fp: Fp521, lowS: false, allowedPrivateKeyLengths: [130, 131, 132] }, sha5122);
|
|
59480
|
+
secp256r1 = p256;
|
|
59481
|
+
secp384r1 = p384;
|
|
59482
|
+
secp521r1 = p521;
|
|
59540
59483
|
p521_hasher = /* @__PURE__ */ (() => {
|
|
59541
|
-
return createHasher3(
|
|
59484
|
+
return createHasher3(p521.Point, createSWU(p521.Point, {
|
|
59542
59485
|
A: p521_CURVE.a,
|
|
59543
59486
|
B: p521_CURVE.b,
|
|
59544
|
-
Z:
|
|
59487
|
+
Z: p521.Point.Fp.create(BigInt("-4"))
|
|
59545
59488
|
}), {
|
|
59546
59489
|
DST: "P521_XMD:SHA-512_SSWU_RO_",
|
|
59547
59490
|
encodeDST: "P521_XMD:SHA-512_SSWU_NU_",
|
|
@@ -59552,14 +59495,6 @@ var init_nist = __esm({
|
|
|
59552
59495
|
hash: sha5122
|
|
59553
59496
|
});
|
|
59554
59497
|
})();
|
|
59555
|
-
p521_oprf = /* @__PURE__ */ (() => createORPF({
|
|
59556
|
-
name: "P521-SHA512",
|
|
59557
|
-
Point: p521_Point,
|
|
59558
|
-
hash: sha5122,
|
|
59559
|
-
hashToGroup: p521_hasher.hashToCurve,
|
|
59560
|
-
hashToScalar: p521_hasher.hashToScalar
|
|
59561
|
-
// produces L=98 just like in RFC
|
|
59562
|
-
}))();
|
|
59563
59498
|
}
|
|
59564
59499
|
});
|
|
59565
59500
|
|
|
@@ -59764,17 +59699,748 @@ var init_resumption = __esm({
|
|
|
59764
59699
|
}
|
|
59765
59700
|
});
|
|
59766
59701
|
|
|
59702
|
+
// ../crypto/node_modules/@noble/hashes/utils.js
|
|
59703
|
+
function isBytes4(a2) {
|
|
59704
|
+
return a2 instanceof Uint8Array || ArrayBuffer.isView(a2) && a2.constructor.name === "Uint8Array";
|
|
59705
|
+
}
|
|
59706
|
+
function anumber4(n2, title = "") {
|
|
59707
|
+
if (!Number.isSafeInteger(n2) || n2 < 0) {
|
|
59708
|
+
const prefix = title && `"${title}" `;
|
|
59709
|
+
throw new Error(`${prefix}expected integer >= 0, got ${n2}`);
|
|
59710
|
+
}
|
|
59711
|
+
}
|
|
59712
|
+
function abytes4(value, length, title = "") {
|
|
59713
|
+
const bytes = isBytes4(value);
|
|
59714
|
+
const len = value?.length;
|
|
59715
|
+
const needsLen = length !== void 0;
|
|
59716
|
+
if (!bytes || needsLen && len !== length) {
|
|
59717
|
+
const prefix = title && `"${title}" `;
|
|
59718
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
59719
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
59720
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
59721
|
+
}
|
|
59722
|
+
return value;
|
|
59723
|
+
}
|
|
59724
|
+
function ahash3(h2) {
|
|
59725
|
+
if (typeof h2 !== "function" || typeof h2.create !== "function")
|
|
59726
|
+
throw new Error("Hash must wrapped by utils.createHasher");
|
|
59727
|
+
anumber4(h2.outputLen);
|
|
59728
|
+
anumber4(h2.blockLen);
|
|
59729
|
+
}
|
|
59730
|
+
function aexists4(instance, checkFinished = true) {
|
|
59731
|
+
if (instance.destroyed)
|
|
59732
|
+
throw new Error("Hash instance has been destroyed");
|
|
59733
|
+
if (checkFinished && instance.finished)
|
|
59734
|
+
throw new Error("Hash#digest() has already been called");
|
|
59735
|
+
}
|
|
59736
|
+
function aoutput4(out, instance) {
|
|
59737
|
+
abytes4(out, void 0, "digestInto() output");
|
|
59738
|
+
const min = instance.outputLen;
|
|
59739
|
+
if (out.length < min) {
|
|
59740
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
59741
|
+
}
|
|
59742
|
+
}
|
|
59743
|
+
function clean4(...arrays) {
|
|
59744
|
+
for (let i2 = 0; i2 < arrays.length; i2++) {
|
|
59745
|
+
arrays[i2].fill(0);
|
|
59746
|
+
}
|
|
59747
|
+
}
|
|
59748
|
+
function createView4(arr) {
|
|
59749
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
59750
|
+
}
|
|
59751
|
+
function rotr3(word, shift) {
|
|
59752
|
+
return word << 32 - shift | word >>> shift;
|
|
59753
|
+
}
|
|
59754
|
+
function createHasher4(hashCons, info = {}) {
|
|
59755
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
59756
|
+
const tmp = hashCons(void 0);
|
|
59757
|
+
hashC.outputLen = tmp.outputLen;
|
|
59758
|
+
hashC.blockLen = tmp.blockLen;
|
|
59759
|
+
hashC.create = (opts) => hashCons(opts);
|
|
59760
|
+
Object.assign(hashC, info);
|
|
59761
|
+
return Object.freeze(hashC);
|
|
59762
|
+
}
|
|
59763
|
+
var oidNist2;
|
|
59764
|
+
var init_utils4 = __esm({
|
|
59765
|
+
"../crypto/node_modules/@noble/hashes/utils.js"() {
|
|
59766
|
+
oidNist2 = (suffix) => ({
|
|
59767
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
59768
|
+
});
|
|
59769
|
+
}
|
|
59770
|
+
});
|
|
59771
|
+
|
|
59772
|
+
// ../crypto/node_modules/@noble/hashes/_md.js
|
|
59773
|
+
function Chi3(a2, b2, c2) {
|
|
59774
|
+
return a2 & b2 ^ ~a2 & c2;
|
|
59775
|
+
}
|
|
59776
|
+
function Maj3(a2, b2, c2) {
|
|
59777
|
+
return a2 & b2 ^ a2 & c2 ^ b2 & c2;
|
|
59778
|
+
}
|
|
59779
|
+
var HashMD3, SHA256_IV3, SHA384_IV3, SHA512_IV3;
|
|
59780
|
+
var init_md3 = __esm({
|
|
59781
|
+
"../crypto/node_modules/@noble/hashes/_md.js"() {
|
|
59782
|
+
init_utils4();
|
|
59783
|
+
HashMD3 = class {
|
|
59784
|
+
blockLen;
|
|
59785
|
+
outputLen;
|
|
59786
|
+
padOffset;
|
|
59787
|
+
isLE;
|
|
59788
|
+
// For partial updates less than block size
|
|
59789
|
+
buffer;
|
|
59790
|
+
view;
|
|
59791
|
+
finished = false;
|
|
59792
|
+
length = 0;
|
|
59793
|
+
pos = 0;
|
|
59794
|
+
destroyed = false;
|
|
59795
|
+
constructor(blockLen, outputLen, padOffset, isLE4) {
|
|
59796
|
+
this.blockLen = blockLen;
|
|
59797
|
+
this.outputLen = outputLen;
|
|
59798
|
+
this.padOffset = padOffset;
|
|
59799
|
+
this.isLE = isLE4;
|
|
59800
|
+
this.buffer = new Uint8Array(blockLen);
|
|
59801
|
+
this.view = createView4(this.buffer);
|
|
59802
|
+
}
|
|
59803
|
+
update(data) {
|
|
59804
|
+
aexists4(this);
|
|
59805
|
+
abytes4(data);
|
|
59806
|
+
const { view, buffer, blockLen } = this;
|
|
59807
|
+
const len = data.length;
|
|
59808
|
+
for (let pos = 0; pos < len; ) {
|
|
59809
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
59810
|
+
if (take === blockLen) {
|
|
59811
|
+
const dataView = createView4(data);
|
|
59812
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
59813
|
+
this.process(dataView, pos);
|
|
59814
|
+
continue;
|
|
59815
|
+
}
|
|
59816
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
59817
|
+
this.pos += take;
|
|
59818
|
+
pos += take;
|
|
59819
|
+
if (this.pos === blockLen) {
|
|
59820
|
+
this.process(view, 0);
|
|
59821
|
+
this.pos = 0;
|
|
59822
|
+
}
|
|
59823
|
+
}
|
|
59824
|
+
this.length += data.length;
|
|
59825
|
+
this.roundClean();
|
|
59826
|
+
return this;
|
|
59827
|
+
}
|
|
59828
|
+
digestInto(out) {
|
|
59829
|
+
aexists4(this);
|
|
59830
|
+
aoutput4(out, this);
|
|
59831
|
+
this.finished = true;
|
|
59832
|
+
const { buffer, view, blockLen, isLE: isLE4 } = this;
|
|
59833
|
+
let { pos } = this;
|
|
59834
|
+
buffer[pos++] = 128;
|
|
59835
|
+
clean4(this.buffer.subarray(pos));
|
|
59836
|
+
if (this.padOffset > blockLen - pos) {
|
|
59837
|
+
this.process(view, 0);
|
|
59838
|
+
pos = 0;
|
|
59839
|
+
}
|
|
59840
|
+
for (let i2 = pos; i2 < blockLen; i2++)
|
|
59841
|
+
buffer[i2] = 0;
|
|
59842
|
+
view.setBigUint64(blockLen - 8, BigInt(this.length * 8), isLE4);
|
|
59843
|
+
this.process(view, 0);
|
|
59844
|
+
const oview = createView4(out);
|
|
59845
|
+
const len = this.outputLen;
|
|
59846
|
+
if (len % 4)
|
|
59847
|
+
throw new Error("_sha2: outputLen must be aligned to 32bit");
|
|
59848
|
+
const outLen = len / 4;
|
|
59849
|
+
const state = this.get();
|
|
59850
|
+
if (outLen > state.length)
|
|
59851
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
59852
|
+
for (let i2 = 0; i2 < outLen; i2++)
|
|
59853
|
+
oview.setUint32(4 * i2, state[i2], isLE4);
|
|
59854
|
+
}
|
|
59855
|
+
digest() {
|
|
59856
|
+
const { buffer, outputLen } = this;
|
|
59857
|
+
this.digestInto(buffer);
|
|
59858
|
+
const res = buffer.slice(0, outputLen);
|
|
59859
|
+
this.destroy();
|
|
59860
|
+
return res;
|
|
59861
|
+
}
|
|
59862
|
+
_cloneInto(to) {
|
|
59863
|
+
to ||= new this.constructor();
|
|
59864
|
+
to.set(...this.get());
|
|
59865
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
59866
|
+
to.destroyed = destroyed;
|
|
59867
|
+
to.finished = finished;
|
|
59868
|
+
to.length = length;
|
|
59869
|
+
to.pos = pos;
|
|
59870
|
+
if (length % blockLen)
|
|
59871
|
+
to.buffer.set(buffer);
|
|
59872
|
+
return to;
|
|
59873
|
+
}
|
|
59874
|
+
clone() {
|
|
59875
|
+
return this._cloneInto();
|
|
59876
|
+
}
|
|
59877
|
+
};
|
|
59878
|
+
SHA256_IV3 = /* @__PURE__ */ Uint32Array.from([
|
|
59879
|
+
1779033703,
|
|
59880
|
+
3144134277,
|
|
59881
|
+
1013904242,
|
|
59882
|
+
2773480762,
|
|
59883
|
+
1359893119,
|
|
59884
|
+
2600822924,
|
|
59885
|
+
528734635,
|
|
59886
|
+
1541459225
|
|
59887
|
+
]);
|
|
59888
|
+
SHA384_IV3 = /* @__PURE__ */ Uint32Array.from([
|
|
59889
|
+
3418070365,
|
|
59890
|
+
3238371032,
|
|
59891
|
+
1654270250,
|
|
59892
|
+
914150663,
|
|
59893
|
+
2438529370,
|
|
59894
|
+
812702999,
|
|
59895
|
+
355462360,
|
|
59896
|
+
4144912697,
|
|
59897
|
+
1731405415,
|
|
59898
|
+
4290775857,
|
|
59899
|
+
2394180231,
|
|
59900
|
+
1750603025,
|
|
59901
|
+
3675008525,
|
|
59902
|
+
1694076839,
|
|
59903
|
+
1203062813,
|
|
59904
|
+
3204075428
|
|
59905
|
+
]);
|
|
59906
|
+
SHA512_IV3 = /* @__PURE__ */ Uint32Array.from([
|
|
59907
|
+
1779033703,
|
|
59908
|
+
4089235720,
|
|
59909
|
+
3144134277,
|
|
59910
|
+
2227873595,
|
|
59911
|
+
1013904242,
|
|
59912
|
+
4271175723,
|
|
59913
|
+
2773480762,
|
|
59914
|
+
1595750129,
|
|
59915
|
+
1359893119,
|
|
59916
|
+
2917565137,
|
|
59917
|
+
2600822924,
|
|
59918
|
+
725511199,
|
|
59919
|
+
528734635,
|
|
59920
|
+
4215389547,
|
|
59921
|
+
1541459225,
|
|
59922
|
+
327033209
|
|
59923
|
+
]);
|
|
59924
|
+
}
|
|
59925
|
+
});
|
|
59926
|
+
|
|
59927
|
+
// ../crypto/node_modules/@noble/hashes/_u64.js
|
|
59928
|
+
function fromBig3(n2, le2 = false) {
|
|
59929
|
+
if (le2)
|
|
59930
|
+
return { h: Number(n2 & U32_MASK643), l: Number(n2 >> _32n3 & U32_MASK643) };
|
|
59931
|
+
return { h: Number(n2 >> _32n3 & U32_MASK643) | 0, l: Number(n2 & U32_MASK643) | 0 };
|
|
59932
|
+
}
|
|
59933
|
+
function split3(lst, le2 = false) {
|
|
59934
|
+
const len = lst.length;
|
|
59935
|
+
let Ah = new Uint32Array(len);
|
|
59936
|
+
let Al = new Uint32Array(len);
|
|
59937
|
+
for (let i2 = 0; i2 < len; i2++) {
|
|
59938
|
+
const { h: h2, l: l2 } = fromBig3(lst[i2], le2);
|
|
59939
|
+
[Ah[i2], Al[i2]] = [h2, l2];
|
|
59940
|
+
}
|
|
59941
|
+
return [Ah, Al];
|
|
59942
|
+
}
|
|
59943
|
+
function add3(Ah, Al, Bh, Bl) {
|
|
59944
|
+
const l2 = (Al >>> 0) + (Bl >>> 0);
|
|
59945
|
+
return { h: Ah + Bh + (l2 / 2 ** 32 | 0) | 0, l: l2 | 0 };
|
|
59946
|
+
}
|
|
59947
|
+
var U32_MASK643, _32n3, shrSH3, shrSL3, rotrSH3, rotrSL3, rotrBH3, rotrBL3, add3L3, add3H3, add4L3, add4H3, add5L3, add5H3;
|
|
59948
|
+
var init_u643 = __esm({
|
|
59949
|
+
"../crypto/node_modules/@noble/hashes/_u64.js"() {
|
|
59950
|
+
U32_MASK643 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
59951
|
+
_32n3 = /* @__PURE__ */ BigInt(32);
|
|
59952
|
+
shrSH3 = (h2, _l, s2) => h2 >>> s2;
|
|
59953
|
+
shrSL3 = (h2, l2, s2) => h2 << 32 - s2 | l2 >>> s2;
|
|
59954
|
+
rotrSH3 = (h2, l2, s2) => h2 >>> s2 | l2 << 32 - s2;
|
|
59955
|
+
rotrSL3 = (h2, l2, s2) => h2 << 32 - s2 | l2 >>> s2;
|
|
59956
|
+
rotrBH3 = (h2, l2, s2) => h2 << 64 - s2 | l2 >>> s2 - 32;
|
|
59957
|
+
rotrBL3 = (h2, l2, s2) => h2 >>> s2 - 32 | l2 << 64 - s2;
|
|
59958
|
+
add3L3 = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
59959
|
+
add3H3 = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
59960
|
+
add4L3 = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
59961
|
+
add4H3 = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
59962
|
+
add5L3 = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
59963
|
+
add5H3 = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
59964
|
+
}
|
|
59965
|
+
});
|
|
59966
|
+
|
|
59967
|
+
// ../crypto/node_modules/@noble/hashes/sha2.js
|
|
59968
|
+
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;
|
|
59969
|
+
var init_sha23 = __esm({
|
|
59970
|
+
"../crypto/node_modules/@noble/hashes/sha2.js"() {
|
|
59971
|
+
init_md3();
|
|
59972
|
+
init_u643();
|
|
59973
|
+
init_utils4();
|
|
59974
|
+
SHA256_K2 = /* @__PURE__ */ Uint32Array.from([
|
|
59975
|
+
1116352408,
|
|
59976
|
+
1899447441,
|
|
59977
|
+
3049323471,
|
|
59978
|
+
3921009573,
|
|
59979
|
+
961987163,
|
|
59980
|
+
1508970993,
|
|
59981
|
+
2453635748,
|
|
59982
|
+
2870763221,
|
|
59983
|
+
3624381080,
|
|
59984
|
+
310598401,
|
|
59985
|
+
607225278,
|
|
59986
|
+
1426881987,
|
|
59987
|
+
1925078388,
|
|
59988
|
+
2162078206,
|
|
59989
|
+
2614888103,
|
|
59990
|
+
3248222580,
|
|
59991
|
+
3835390401,
|
|
59992
|
+
4022224774,
|
|
59993
|
+
264347078,
|
|
59994
|
+
604807628,
|
|
59995
|
+
770255983,
|
|
59996
|
+
1249150122,
|
|
59997
|
+
1555081692,
|
|
59998
|
+
1996064986,
|
|
59999
|
+
2554220882,
|
|
60000
|
+
2821834349,
|
|
60001
|
+
2952996808,
|
|
60002
|
+
3210313671,
|
|
60003
|
+
3336571891,
|
|
60004
|
+
3584528711,
|
|
60005
|
+
113926993,
|
|
60006
|
+
338241895,
|
|
60007
|
+
666307205,
|
|
60008
|
+
773529912,
|
|
60009
|
+
1294757372,
|
|
60010
|
+
1396182291,
|
|
60011
|
+
1695183700,
|
|
60012
|
+
1986661051,
|
|
60013
|
+
2177026350,
|
|
60014
|
+
2456956037,
|
|
60015
|
+
2730485921,
|
|
60016
|
+
2820302411,
|
|
60017
|
+
3259730800,
|
|
60018
|
+
3345764771,
|
|
60019
|
+
3516065817,
|
|
60020
|
+
3600352804,
|
|
60021
|
+
4094571909,
|
|
60022
|
+
275423344,
|
|
60023
|
+
430227734,
|
|
60024
|
+
506948616,
|
|
60025
|
+
659060556,
|
|
60026
|
+
883997877,
|
|
60027
|
+
958139571,
|
|
60028
|
+
1322822218,
|
|
60029
|
+
1537002063,
|
|
60030
|
+
1747873779,
|
|
60031
|
+
1955562222,
|
|
60032
|
+
2024104815,
|
|
60033
|
+
2227730452,
|
|
60034
|
+
2361852424,
|
|
60035
|
+
2428436474,
|
|
60036
|
+
2756734187,
|
|
60037
|
+
3204031479,
|
|
60038
|
+
3329325298
|
|
60039
|
+
]);
|
|
60040
|
+
SHA256_W2 = /* @__PURE__ */ new Uint32Array(64);
|
|
60041
|
+
SHA2_32B = class extends HashMD3 {
|
|
60042
|
+
constructor(outputLen) {
|
|
60043
|
+
super(64, outputLen, 8, false);
|
|
60044
|
+
}
|
|
60045
|
+
get() {
|
|
60046
|
+
const { A: A2, B: B2, C: C2, D: D2, E: E2, F: F2, G: G2, H: H2 } = this;
|
|
60047
|
+
return [A2, B2, C2, D2, E2, F2, G2, H2];
|
|
60048
|
+
}
|
|
60049
|
+
// prettier-ignore
|
|
60050
|
+
set(A2, B2, C2, D2, E2, F2, G2, H2) {
|
|
60051
|
+
this.A = A2 | 0;
|
|
60052
|
+
this.B = B2 | 0;
|
|
60053
|
+
this.C = C2 | 0;
|
|
60054
|
+
this.D = D2 | 0;
|
|
60055
|
+
this.E = E2 | 0;
|
|
60056
|
+
this.F = F2 | 0;
|
|
60057
|
+
this.G = G2 | 0;
|
|
60058
|
+
this.H = H2 | 0;
|
|
60059
|
+
}
|
|
60060
|
+
process(view, offset) {
|
|
60061
|
+
for (let i2 = 0; i2 < 16; i2++, offset += 4)
|
|
60062
|
+
SHA256_W2[i2] = view.getUint32(offset, false);
|
|
60063
|
+
for (let i2 = 16; i2 < 64; i2++) {
|
|
60064
|
+
const W15 = SHA256_W2[i2 - 15];
|
|
60065
|
+
const W2 = SHA256_W2[i2 - 2];
|
|
60066
|
+
const s0 = rotr3(W15, 7) ^ rotr3(W15, 18) ^ W15 >>> 3;
|
|
60067
|
+
const s1 = rotr3(W2, 17) ^ rotr3(W2, 19) ^ W2 >>> 10;
|
|
60068
|
+
SHA256_W2[i2] = s1 + SHA256_W2[i2 - 7] + s0 + SHA256_W2[i2 - 16] | 0;
|
|
60069
|
+
}
|
|
60070
|
+
let { A: A2, B: B2, C: C2, D: D2, E: E2, F: F2, G: G2, H: H2 } = this;
|
|
60071
|
+
for (let i2 = 0; i2 < 64; i2++) {
|
|
60072
|
+
const sigma1 = rotr3(E2, 6) ^ rotr3(E2, 11) ^ rotr3(E2, 25);
|
|
60073
|
+
const T1 = H2 + sigma1 + Chi3(E2, F2, G2) + SHA256_K2[i2] + SHA256_W2[i2] | 0;
|
|
60074
|
+
const sigma0 = rotr3(A2, 2) ^ rotr3(A2, 13) ^ rotr3(A2, 22);
|
|
60075
|
+
const T2 = sigma0 + Maj3(A2, B2, C2) | 0;
|
|
60076
|
+
H2 = G2;
|
|
60077
|
+
G2 = F2;
|
|
60078
|
+
F2 = E2;
|
|
60079
|
+
E2 = D2 + T1 | 0;
|
|
60080
|
+
D2 = C2;
|
|
60081
|
+
C2 = B2;
|
|
60082
|
+
B2 = A2;
|
|
60083
|
+
A2 = T1 + T2 | 0;
|
|
60084
|
+
}
|
|
60085
|
+
A2 = A2 + this.A | 0;
|
|
60086
|
+
B2 = B2 + this.B | 0;
|
|
60087
|
+
C2 = C2 + this.C | 0;
|
|
60088
|
+
D2 = D2 + this.D | 0;
|
|
60089
|
+
E2 = E2 + this.E | 0;
|
|
60090
|
+
F2 = F2 + this.F | 0;
|
|
60091
|
+
G2 = G2 + this.G | 0;
|
|
60092
|
+
H2 = H2 + this.H | 0;
|
|
60093
|
+
this.set(A2, B2, C2, D2, E2, F2, G2, H2);
|
|
60094
|
+
}
|
|
60095
|
+
roundClean() {
|
|
60096
|
+
clean4(SHA256_W2);
|
|
60097
|
+
}
|
|
60098
|
+
destroy() {
|
|
60099
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
60100
|
+
clean4(this.buffer);
|
|
60101
|
+
}
|
|
60102
|
+
};
|
|
60103
|
+
_SHA256 = class extends SHA2_32B {
|
|
60104
|
+
// We cannot use array here since array allows indexing by variable
|
|
60105
|
+
// which means optimizer/compiler cannot use registers.
|
|
60106
|
+
A = SHA256_IV3[0] | 0;
|
|
60107
|
+
B = SHA256_IV3[1] | 0;
|
|
60108
|
+
C = SHA256_IV3[2] | 0;
|
|
60109
|
+
D = SHA256_IV3[3] | 0;
|
|
60110
|
+
E = SHA256_IV3[4] | 0;
|
|
60111
|
+
F = SHA256_IV3[5] | 0;
|
|
60112
|
+
G = SHA256_IV3[6] | 0;
|
|
60113
|
+
H = SHA256_IV3[7] | 0;
|
|
60114
|
+
constructor() {
|
|
60115
|
+
super(32);
|
|
60116
|
+
}
|
|
60117
|
+
};
|
|
60118
|
+
K5122 = /* @__PURE__ */ (() => split3([
|
|
60119
|
+
"0x428a2f98d728ae22",
|
|
60120
|
+
"0x7137449123ef65cd",
|
|
60121
|
+
"0xb5c0fbcfec4d3b2f",
|
|
60122
|
+
"0xe9b5dba58189dbbc",
|
|
60123
|
+
"0x3956c25bf348b538",
|
|
60124
|
+
"0x59f111f1b605d019",
|
|
60125
|
+
"0x923f82a4af194f9b",
|
|
60126
|
+
"0xab1c5ed5da6d8118",
|
|
60127
|
+
"0xd807aa98a3030242",
|
|
60128
|
+
"0x12835b0145706fbe",
|
|
60129
|
+
"0x243185be4ee4b28c",
|
|
60130
|
+
"0x550c7dc3d5ffb4e2",
|
|
60131
|
+
"0x72be5d74f27b896f",
|
|
60132
|
+
"0x80deb1fe3b1696b1",
|
|
60133
|
+
"0x9bdc06a725c71235",
|
|
60134
|
+
"0xc19bf174cf692694",
|
|
60135
|
+
"0xe49b69c19ef14ad2",
|
|
60136
|
+
"0xefbe4786384f25e3",
|
|
60137
|
+
"0x0fc19dc68b8cd5b5",
|
|
60138
|
+
"0x240ca1cc77ac9c65",
|
|
60139
|
+
"0x2de92c6f592b0275",
|
|
60140
|
+
"0x4a7484aa6ea6e483",
|
|
60141
|
+
"0x5cb0a9dcbd41fbd4",
|
|
60142
|
+
"0x76f988da831153b5",
|
|
60143
|
+
"0x983e5152ee66dfab",
|
|
60144
|
+
"0xa831c66d2db43210",
|
|
60145
|
+
"0xb00327c898fb213f",
|
|
60146
|
+
"0xbf597fc7beef0ee4",
|
|
60147
|
+
"0xc6e00bf33da88fc2",
|
|
60148
|
+
"0xd5a79147930aa725",
|
|
60149
|
+
"0x06ca6351e003826f",
|
|
60150
|
+
"0x142929670a0e6e70",
|
|
60151
|
+
"0x27b70a8546d22ffc",
|
|
60152
|
+
"0x2e1b21385c26c926",
|
|
60153
|
+
"0x4d2c6dfc5ac42aed",
|
|
60154
|
+
"0x53380d139d95b3df",
|
|
60155
|
+
"0x650a73548baf63de",
|
|
60156
|
+
"0x766a0abb3c77b2a8",
|
|
60157
|
+
"0x81c2c92e47edaee6",
|
|
60158
|
+
"0x92722c851482353b",
|
|
60159
|
+
"0xa2bfe8a14cf10364",
|
|
60160
|
+
"0xa81a664bbc423001",
|
|
60161
|
+
"0xc24b8b70d0f89791",
|
|
60162
|
+
"0xc76c51a30654be30",
|
|
60163
|
+
"0xd192e819d6ef5218",
|
|
60164
|
+
"0xd69906245565a910",
|
|
60165
|
+
"0xf40e35855771202a",
|
|
60166
|
+
"0x106aa07032bbd1b8",
|
|
60167
|
+
"0x19a4c116b8d2d0c8",
|
|
60168
|
+
"0x1e376c085141ab53",
|
|
60169
|
+
"0x2748774cdf8eeb99",
|
|
60170
|
+
"0x34b0bcb5e19b48a8",
|
|
60171
|
+
"0x391c0cb3c5c95a63",
|
|
60172
|
+
"0x4ed8aa4ae3418acb",
|
|
60173
|
+
"0x5b9cca4f7763e373",
|
|
60174
|
+
"0x682e6ff3d6b2b8a3",
|
|
60175
|
+
"0x748f82ee5defb2fc",
|
|
60176
|
+
"0x78a5636f43172f60",
|
|
60177
|
+
"0x84c87814a1f0ab72",
|
|
60178
|
+
"0x8cc702081a6439ec",
|
|
60179
|
+
"0x90befffa23631e28",
|
|
60180
|
+
"0xa4506cebde82bde9",
|
|
60181
|
+
"0xbef9a3f7b2c67915",
|
|
60182
|
+
"0xc67178f2e372532b",
|
|
60183
|
+
"0xca273eceea26619c",
|
|
60184
|
+
"0xd186b8c721c0c207",
|
|
60185
|
+
"0xeada7dd6cde0eb1e",
|
|
60186
|
+
"0xf57d4f7fee6ed178",
|
|
60187
|
+
"0x06f067aa72176fba",
|
|
60188
|
+
"0x0a637dc5a2c898a6",
|
|
60189
|
+
"0x113f9804bef90dae",
|
|
60190
|
+
"0x1b710b35131c471b",
|
|
60191
|
+
"0x28db77f523047d84",
|
|
60192
|
+
"0x32caab7b40c72493",
|
|
60193
|
+
"0x3c9ebe0a15c9bebc",
|
|
60194
|
+
"0x431d67c49c100d4c",
|
|
60195
|
+
"0x4cc5d4becb3e42b6",
|
|
60196
|
+
"0x597f299cfc657e2a",
|
|
60197
|
+
"0x5fcb6fab3ad6faec",
|
|
60198
|
+
"0x6c44198c4a475817"
|
|
60199
|
+
].map((n2) => BigInt(n2))))();
|
|
60200
|
+
SHA512_Kh2 = /* @__PURE__ */ (() => K5122[0])();
|
|
60201
|
+
SHA512_Kl2 = /* @__PURE__ */ (() => K5122[1])();
|
|
60202
|
+
SHA512_W_H2 = /* @__PURE__ */ new Uint32Array(80);
|
|
60203
|
+
SHA512_W_L2 = /* @__PURE__ */ new Uint32Array(80);
|
|
60204
|
+
SHA2_64B = class extends HashMD3 {
|
|
60205
|
+
constructor(outputLen) {
|
|
60206
|
+
super(128, outputLen, 16, false);
|
|
60207
|
+
}
|
|
60208
|
+
// prettier-ignore
|
|
60209
|
+
get() {
|
|
60210
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
60211
|
+
return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
|
|
60212
|
+
}
|
|
60213
|
+
// prettier-ignore
|
|
60214
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
60215
|
+
this.Ah = Ah | 0;
|
|
60216
|
+
this.Al = Al | 0;
|
|
60217
|
+
this.Bh = Bh | 0;
|
|
60218
|
+
this.Bl = Bl | 0;
|
|
60219
|
+
this.Ch = Ch | 0;
|
|
60220
|
+
this.Cl = Cl | 0;
|
|
60221
|
+
this.Dh = Dh | 0;
|
|
60222
|
+
this.Dl = Dl | 0;
|
|
60223
|
+
this.Eh = Eh | 0;
|
|
60224
|
+
this.El = El | 0;
|
|
60225
|
+
this.Fh = Fh | 0;
|
|
60226
|
+
this.Fl = Fl | 0;
|
|
60227
|
+
this.Gh = Gh | 0;
|
|
60228
|
+
this.Gl = Gl | 0;
|
|
60229
|
+
this.Hh = Hh | 0;
|
|
60230
|
+
this.Hl = Hl | 0;
|
|
60231
|
+
}
|
|
60232
|
+
process(view, offset) {
|
|
60233
|
+
for (let i2 = 0; i2 < 16; i2++, offset += 4) {
|
|
60234
|
+
SHA512_W_H2[i2] = view.getUint32(offset);
|
|
60235
|
+
SHA512_W_L2[i2] = view.getUint32(offset += 4);
|
|
60236
|
+
}
|
|
60237
|
+
for (let i2 = 16; i2 < 80; i2++) {
|
|
60238
|
+
const W15h = SHA512_W_H2[i2 - 15] | 0;
|
|
60239
|
+
const W15l = SHA512_W_L2[i2 - 15] | 0;
|
|
60240
|
+
const s0h = rotrSH3(W15h, W15l, 1) ^ rotrSH3(W15h, W15l, 8) ^ shrSH3(W15h, W15l, 7);
|
|
60241
|
+
const s0l = rotrSL3(W15h, W15l, 1) ^ rotrSL3(W15h, W15l, 8) ^ shrSL3(W15h, W15l, 7);
|
|
60242
|
+
const W2h = SHA512_W_H2[i2 - 2] | 0;
|
|
60243
|
+
const W2l = SHA512_W_L2[i2 - 2] | 0;
|
|
60244
|
+
const s1h = rotrSH3(W2h, W2l, 19) ^ rotrBH3(W2h, W2l, 61) ^ shrSH3(W2h, W2l, 6);
|
|
60245
|
+
const s1l = rotrSL3(W2h, W2l, 19) ^ rotrBL3(W2h, W2l, 61) ^ shrSL3(W2h, W2l, 6);
|
|
60246
|
+
const SUMl = add4L3(s0l, s1l, SHA512_W_L2[i2 - 7], SHA512_W_L2[i2 - 16]);
|
|
60247
|
+
const SUMh = add4H3(SUMl, s0h, s1h, SHA512_W_H2[i2 - 7], SHA512_W_H2[i2 - 16]);
|
|
60248
|
+
SHA512_W_H2[i2] = SUMh | 0;
|
|
60249
|
+
SHA512_W_L2[i2] = SUMl | 0;
|
|
60250
|
+
}
|
|
60251
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
60252
|
+
for (let i2 = 0; i2 < 80; i2++) {
|
|
60253
|
+
const sigma1h = rotrSH3(Eh, El, 14) ^ rotrSH3(Eh, El, 18) ^ rotrBH3(Eh, El, 41);
|
|
60254
|
+
const sigma1l = rotrSL3(Eh, El, 14) ^ rotrSL3(Eh, El, 18) ^ rotrBL3(Eh, El, 41);
|
|
60255
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
60256
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
60257
|
+
const T1ll = add5L3(Hl, sigma1l, CHIl, SHA512_Kl2[i2], SHA512_W_L2[i2]);
|
|
60258
|
+
const T1h = add5H3(T1ll, Hh, sigma1h, CHIh, SHA512_Kh2[i2], SHA512_W_H2[i2]);
|
|
60259
|
+
const T1l = T1ll | 0;
|
|
60260
|
+
const sigma0h = rotrSH3(Ah, Al, 28) ^ rotrBH3(Ah, Al, 34) ^ rotrBH3(Ah, Al, 39);
|
|
60261
|
+
const sigma0l = rotrSL3(Ah, Al, 28) ^ rotrBL3(Ah, Al, 34) ^ rotrBL3(Ah, Al, 39);
|
|
60262
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
60263
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
60264
|
+
Hh = Gh | 0;
|
|
60265
|
+
Hl = Gl | 0;
|
|
60266
|
+
Gh = Fh | 0;
|
|
60267
|
+
Gl = Fl | 0;
|
|
60268
|
+
Fh = Eh | 0;
|
|
60269
|
+
Fl = El | 0;
|
|
60270
|
+
({ h: Eh, l: El } = add3(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
60271
|
+
Dh = Ch | 0;
|
|
60272
|
+
Dl = Cl | 0;
|
|
60273
|
+
Ch = Bh | 0;
|
|
60274
|
+
Cl = Bl | 0;
|
|
60275
|
+
Bh = Ah | 0;
|
|
60276
|
+
Bl = Al | 0;
|
|
60277
|
+
const All = add3L3(T1l, sigma0l, MAJl);
|
|
60278
|
+
Ah = add3H3(All, T1h, sigma0h, MAJh);
|
|
60279
|
+
Al = All | 0;
|
|
60280
|
+
}
|
|
60281
|
+
({ h: Ah, l: Al } = add3(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
60282
|
+
({ h: Bh, l: Bl } = add3(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
60283
|
+
({ h: Ch, l: Cl } = add3(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
60284
|
+
({ h: Dh, l: Dl } = add3(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
60285
|
+
({ h: Eh, l: El } = add3(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
60286
|
+
({ h: Fh, l: Fl } = add3(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
60287
|
+
({ h: Gh, l: Gl } = add3(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
60288
|
+
({ h: Hh, l: Hl } = add3(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
60289
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
60290
|
+
}
|
|
60291
|
+
roundClean() {
|
|
60292
|
+
clean4(SHA512_W_H2, SHA512_W_L2);
|
|
60293
|
+
}
|
|
60294
|
+
destroy() {
|
|
60295
|
+
clean4(this.buffer);
|
|
60296
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
60297
|
+
}
|
|
60298
|
+
};
|
|
60299
|
+
_SHA512 = class extends SHA2_64B {
|
|
60300
|
+
Ah = SHA512_IV3[0] | 0;
|
|
60301
|
+
Al = SHA512_IV3[1] | 0;
|
|
60302
|
+
Bh = SHA512_IV3[2] | 0;
|
|
60303
|
+
Bl = SHA512_IV3[3] | 0;
|
|
60304
|
+
Ch = SHA512_IV3[4] | 0;
|
|
60305
|
+
Cl = SHA512_IV3[5] | 0;
|
|
60306
|
+
Dh = SHA512_IV3[6] | 0;
|
|
60307
|
+
Dl = SHA512_IV3[7] | 0;
|
|
60308
|
+
Eh = SHA512_IV3[8] | 0;
|
|
60309
|
+
El = SHA512_IV3[9] | 0;
|
|
60310
|
+
Fh = SHA512_IV3[10] | 0;
|
|
60311
|
+
Fl = SHA512_IV3[11] | 0;
|
|
60312
|
+
Gh = SHA512_IV3[12] | 0;
|
|
60313
|
+
Gl = SHA512_IV3[13] | 0;
|
|
60314
|
+
Hh = SHA512_IV3[14] | 0;
|
|
60315
|
+
Hl = SHA512_IV3[15] | 0;
|
|
60316
|
+
constructor() {
|
|
60317
|
+
super(64);
|
|
60318
|
+
}
|
|
60319
|
+
};
|
|
60320
|
+
_SHA384 = class extends SHA2_64B {
|
|
60321
|
+
Ah = SHA384_IV3[0] | 0;
|
|
60322
|
+
Al = SHA384_IV3[1] | 0;
|
|
60323
|
+
Bh = SHA384_IV3[2] | 0;
|
|
60324
|
+
Bl = SHA384_IV3[3] | 0;
|
|
60325
|
+
Ch = SHA384_IV3[4] | 0;
|
|
60326
|
+
Cl = SHA384_IV3[5] | 0;
|
|
60327
|
+
Dh = SHA384_IV3[6] | 0;
|
|
60328
|
+
Dl = SHA384_IV3[7] | 0;
|
|
60329
|
+
Eh = SHA384_IV3[8] | 0;
|
|
60330
|
+
El = SHA384_IV3[9] | 0;
|
|
60331
|
+
Fh = SHA384_IV3[10] | 0;
|
|
60332
|
+
Fl = SHA384_IV3[11] | 0;
|
|
60333
|
+
Gh = SHA384_IV3[12] | 0;
|
|
60334
|
+
Gl = SHA384_IV3[13] | 0;
|
|
60335
|
+
Hh = SHA384_IV3[14] | 0;
|
|
60336
|
+
Hl = SHA384_IV3[15] | 0;
|
|
60337
|
+
constructor() {
|
|
60338
|
+
super(48);
|
|
60339
|
+
}
|
|
60340
|
+
};
|
|
60341
|
+
sha2563 = /* @__PURE__ */ createHasher4(
|
|
60342
|
+
() => new _SHA256(),
|
|
60343
|
+
/* @__PURE__ */ oidNist2(1)
|
|
60344
|
+
);
|
|
60345
|
+
sha5123 = /* @__PURE__ */ createHasher4(
|
|
60346
|
+
() => new _SHA512(),
|
|
60347
|
+
/* @__PURE__ */ oidNist2(3)
|
|
60348
|
+
);
|
|
60349
|
+
sha3843 = /* @__PURE__ */ createHasher4(
|
|
60350
|
+
() => new _SHA384(),
|
|
60351
|
+
/* @__PURE__ */ oidNist2(2)
|
|
60352
|
+
);
|
|
60353
|
+
}
|
|
60354
|
+
});
|
|
60355
|
+
|
|
60356
|
+
// ../crypto/node_modules/@noble/hashes/hmac.js
|
|
60357
|
+
var _HMAC2, hmac3;
|
|
60358
|
+
var init_hmac3 = __esm({
|
|
60359
|
+
"../crypto/node_modules/@noble/hashes/hmac.js"() {
|
|
60360
|
+
init_utils4();
|
|
60361
|
+
_HMAC2 = class {
|
|
60362
|
+
oHash;
|
|
60363
|
+
iHash;
|
|
60364
|
+
blockLen;
|
|
60365
|
+
outputLen;
|
|
60366
|
+
finished = false;
|
|
60367
|
+
destroyed = false;
|
|
60368
|
+
constructor(hash2, key) {
|
|
60369
|
+
ahash3(hash2);
|
|
60370
|
+
abytes4(key, void 0, "key");
|
|
60371
|
+
this.iHash = hash2.create();
|
|
60372
|
+
if (typeof this.iHash.update !== "function")
|
|
60373
|
+
throw new Error("Expected instance of class which extends utils.Hash");
|
|
60374
|
+
this.blockLen = this.iHash.blockLen;
|
|
60375
|
+
this.outputLen = this.iHash.outputLen;
|
|
60376
|
+
const blockLen = this.blockLen;
|
|
60377
|
+
const pad = new Uint8Array(blockLen);
|
|
60378
|
+
pad.set(key.length > blockLen ? hash2.create().update(key).digest() : key);
|
|
60379
|
+
for (let i2 = 0; i2 < pad.length; i2++)
|
|
60380
|
+
pad[i2] ^= 54;
|
|
60381
|
+
this.iHash.update(pad);
|
|
60382
|
+
this.oHash = hash2.create();
|
|
60383
|
+
for (let i2 = 0; i2 < pad.length; i2++)
|
|
60384
|
+
pad[i2] ^= 54 ^ 92;
|
|
60385
|
+
this.oHash.update(pad);
|
|
60386
|
+
clean4(pad);
|
|
60387
|
+
}
|
|
60388
|
+
update(buf) {
|
|
60389
|
+
aexists4(this);
|
|
60390
|
+
this.iHash.update(buf);
|
|
60391
|
+
return this;
|
|
60392
|
+
}
|
|
60393
|
+
digestInto(out) {
|
|
60394
|
+
aexists4(this);
|
|
60395
|
+
abytes4(out, this.outputLen, "output");
|
|
60396
|
+
this.finished = true;
|
|
60397
|
+
this.iHash.digestInto(out);
|
|
60398
|
+
this.oHash.update(out);
|
|
60399
|
+
this.oHash.digestInto(out);
|
|
60400
|
+
this.destroy();
|
|
60401
|
+
}
|
|
60402
|
+
digest() {
|
|
60403
|
+
const out = new Uint8Array(this.oHash.outputLen);
|
|
60404
|
+
this.digestInto(out);
|
|
60405
|
+
return out;
|
|
60406
|
+
}
|
|
60407
|
+
_cloneInto(to) {
|
|
60408
|
+
to ||= Object.create(Object.getPrototypeOf(this), {});
|
|
60409
|
+
const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
|
|
60410
|
+
to = to;
|
|
60411
|
+
to.finished = finished;
|
|
60412
|
+
to.destroyed = destroyed;
|
|
60413
|
+
to.blockLen = blockLen;
|
|
60414
|
+
to.outputLen = outputLen;
|
|
60415
|
+
to.oHash = oHash._cloneInto(to.oHash);
|
|
60416
|
+
to.iHash = iHash._cloneInto(to.iHash);
|
|
60417
|
+
return to;
|
|
60418
|
+
}
|
|
60419
|
+
clone() {
|
|
60420
|
+
return this._cloneInto();
|
|
60421
|
+
}
|
|
60422
|
+
destroy() {
|
|
60423
|
+
this.destroyed = true;
|
|
60424
|
+
this.oHash.destroy();
|
|
60425
|
+
this.iHash.destroy();
|
|
60426
|
+
}
|
|
60427
|
+
};
|
|
60428
|
+
hmac3 = (hash2, key, message) => new _HMAC2(hash2, key).update(message).digest();
|
|
60429
|
+
hmac3.create = (hash2, key) => new _HMAC2(hash2, key);
|
|
60430
|
+
}
|
|
60431
|
+
});
|
|
60432
|
+
|
|
59767
60433
|
// ../crypto/node_modules/ts-mls/dist/src/crypto/implementation/noble/makeHashImpl.js
|
|
59768
60434
|
function makeHashImpl2(h2) {
|
|
59769
60435
|
return {
|
|
59770
60436
|
async digest(data) {
|
|
59771
60437
|
switch (h2) {
|
|
59772
60438
|
case "SHA-256":
|
|
59773
|
-
return
|
|
60439
|
+
return sha2563(data);
|
|
59774
60440
|
case "SHA-384":
|
|
59775
|
-
return
|
|
60441
|
+
return sha3843(data);
|
|
59776
60442
|
case "SHA-512":
|
|
59777
|
-
return
|
|
60443
|
+
return sha5123(data);
|
|
59778
60444
|
default:
|
|
59779
60445
|
throw new Error(`Unsupported hash algorithm: ${h2}`);
|
|
59780
60446
|
}
|
|
@@ -59782,11 +60448,11 @@ function makeHashImpl2(h2) {
|
|
|
59782
60448
|
async mac(key, data) {
|
|
59783
60449
|
switch (h2) {
|
|
59784
60450
|
case "SHA-256":
|
|
59785
|
-
return
|
|
60451
|
+
return hmac3(sha2563, key, data);
|
|
59786
60452
|
case "SHA-384":
|
|
59787
|
-
return
|
|
60453
|
+
return hmac3(sha3843, key, data);
|
|
59788
60454
|
case "SHA-512":
|
|
59789
|
-
return
|
|
60455
|
+
return hmac3(sha5123, key, data);
|
|
59790
60456
|
default:
|
|
59791
60457
|
throw new Error(`Unsupported hash algorithm: ${h2}`);
|
|
59792
60458
|
}
|
|
@@ -59799,8 +60465,8 @@ function makeHashImpl2(h2) {
|
|
|
59799
60465
|
}
|
|
59800
60466
|
var init_makeHashImpl2 = __esm({
|
|
59801
60467
|
"../crypto/node_modules/ts-mls/dist/src/crypto/implementation/noble/makeHashImpl.js"() {
|
|
59802
|
-
|
|
59803
|
-
|
|
60468
|
+
init_sha23();
|
|
60469
|
+
init_hmac3();
|
|
59804
60470
|
init_constantTimeCompare();
|
|
59805
60471
|
}
|
|
59806
60472
|
});
|
|
@@ -61877,6 +62543,8 @@ var init_channel = __esm({
|
|
|
61877
62543
|
_trustTokenInterval = null;
|
|
61878
62544
|
_pendingPollTimer = null;
|
|
61879
62545
|
_syncMessageIds = null;
|
|
62546
|
+
_deliveryHeartbeat = null;
|
|
62547
|
+
_deliveryPulling = false;
|
|
61880
62548
|
/** MLS group managers per room/conversation (roomId or conv:conversationId -> MLSGroupManager) */
|
|
61881
62549
|
_mlsGroups = /* @__PURE__ */ new Map();
|
|
61882
62550
|
/** Cached MLS KeyPackage bundle for this device (regenerated on each connect). */
|
|
@@ -63650,6 +64318,14 @@ var init_channel = __esm({
|
|
|
63650
64318
|
} catch (kpErr) {
|
|
63651
64319
|
console.warn("[SecureChannel] Failed to publish MLS KeyPackage:", kpErr);
|
|
63652
64320
|
}
|
|
64321
|
+
this._pullDeliveryQueue().catch((err) => {
|
|
64322
|
+
console.warn("[SecureChannel] Initial delivery pull failed:", err);
|
|
64323
|
+
});
|
|
64324
|
+
if (this._deliveryHeartbeat) clearInterval(this._deliveryHeartbeat);
|
|
64325
|
+
this._deliveryHeartbeat = setInterval(() => {
|
|
64326
|
+
this._pullDeliveryQueue().catch(() => {
|
|
64327
|
+
});
|
|
64328
|
+
}, 3e4);
|
|
63653
64329
|
for (const [convId, entry] of Object.entries(this._persisted?.mlsConversations ?? {})) {
|
|
63654
64330
|
if (entry.mlsGroupId) {
|
|
63655
64331
|
const mlsGroup = this._mlsGroups.get(`conv:${convId}`);
|
|
@@ -63814,6 +64490,11 @@ var init_channel = __esm({
|
|
|
63814
64490
|
console.error("[SecureChannel] MLS welcome handler failed:", mlsWelcomeErr);
|
|
63815
64491
|
}
|
|
63816
64492
|
}
|
|
64493
|
+
if (data.event === "mls_delivery") {
|
|
64494
|
+
this._pullDeliveryQueue().catch((err) => {
|
|
64495
|
+
console.warn("[SecureChannel] Delivery pull on ping failed:", err);
|
|
64496
|
+
});
|
|
64497
|
+
}
|
|
63817
64498
|
if (data.event === "mls_sync_response") {
|
|
63818
64499
|
try {
|
|
63819
64500
|
await this._handleMlsSyncResponse(data.data || data);
|
|
@@ -64060,6 +64741,10 @@ var init_channel = __esm({
|
|
|
64060
64741
|
this._stopPing();
|
|
64061
64742
|
this._stopWakeDetector();
|
|
64062
64743
|
this._stopPendingPoll();
|
|
64744
|
+
if (this._deliveryHeartbeat) {
|
|
64745
|
+
clearInterval(this._deliveryHeartbeat);
|
|
64746
|
+
this._deliveryHeartbeat = null;
|
|
64747
|
+
}
|
|
64063
64748
|
if (this._stopped) return;
|
|
64064
64749
|
this._setState("disconnected");
|
|
64065
64750
|
this._scheduleReconnect();
|
|
@@ -65257,6 +65942,128 @@ ${messageText}`;
|
|
|
65257
65942
|
console.error(`[SecureChannel] MLS welcome processing failed:`, err);
|
|
65258
65943
|
}
|
|
65259
65944
|
}
|
|
65945
|
+
/**
|
|
65946
|
+
* Pull pending MLS messages from the delivery queue and process them.
|
|
65947
|
+
* Called on WS connect, on mls_delivery ping, and every 30s heartbeat.
|
|
65948
|
+
*/
|
|
65949
|
+
async _pullDeliveryQueue() {
|
|
65950
|
+
if (!this._deviceId || !this._deviceJwt || this._deliveryPulling) return;
|
|
65951
|
+
this._deliveryPulling = true;
|
|
65952
|
+
try {
|
|
65953
|
+
const res = await fetch(
|
|
65954
|
+
`${this.config.apiUrl}/api/v1/mls/delivery?device_id=${this._deviceId}`,
|
|
65955
|
+
{ headers: { Authorization: `Bearer ${this._deviceJwt}` } }
|
|
65956
|
+
);
|
|
65957
|
+
if (!res.ok) {
|
|
65958
|
+
console.warn(`[SecureChannel] Delivery pull failed: ${res.status}`);
|
|
65959
|
+
return;
|
|
65960
|
+
}
|
|
65961
|
+
const { messages } = await res.json();
|
|
65962
|
+
if (!messages || messages.length === 0) return;
|
|
65963
|
+
const order = { welcome: 0, commit: 1, application: 2 };
|
|
65964
|
+
messages.sort((a2, b2) => {
|
|
65965
|
+
const ao = order[a2.message_type] ?? 2;
|
|
65966
|
+
const bo = order[b2.message_type] ?? 2;
|
|
65967
|
+
if (ao !== bo) return ao - bo;
|
|
65968
|
+
return new Date(a2.created_at).getTime() - new Date(b2.created_at).getTime();
|
|
65969
|
+
});
|
|
65970
|
+
const ackedIds = [];
|
|
65971
|
+
const nackedIds = [];
|
|
65972
|
+
for (const msg of messages) {
|
|
65973
|
+
try {
|
|
65974
|
+
if (msg.sender_device_id === this._deviceId) {
|
|
65975
|
+
ackedIds.push(msg.queue_id);
|
|
65976
|
+
continue;
|
|
65977
|
+
}
|
|
65978
|
+
if (msg.message_type === "welcome") {
|
|
65979
|
+
await this._handleMlsWelcome({
|
|
65980
|
+
group_id: msg.group_id,
|
|
65981
|
+
sender_device_id: msg.sender_device_id,
|
|
65982
|
+
payload: msg.payload,
|
|
65983
|
+
room_id: msg.room_id,
|
|
65984
|
+
conversation_id: msg.conversation_id,
|
|
65985
|
+
a2a_channel_id: msg.a2a_channel_id
|
|
65986
|
+
});
|
|
65987
|
+
} else if (msg.message_type === "commit") {
|
|
65988
|
+
await this._handleMlsCommit({
|
|
65989
|
+
group_id: msg.group_id,
|
|
65990
|
+
sender_device_id: msg.sender_device_id,
|
|
65991
|
+
epoch: msg.epoch,
|
|
65992
|
+
payload: msg.payload
|
|
65993
|
+
});
|
|
65994
|
+
} else if (msg.message_type === "application") {
|
|
65995
|
+
if (msg.room_id) {
|
|
65996
|
+
await this._handleRoomMessageMLS({
|
|
65997
|
+
message_id: msg.message_id,
|
|
65998
|
+
group_id: msg.group_id,
|
|
65999
|
+
sender_device_id: msg.sender_device_id,
|
|
66000
|
+
epoch: msg.epoch,
|
|
66001
|
+
payload: msg.payload,
|
|
66002
|
+
room_id: msg.room_id,
|
|
66003
|
+
created_at: msg.created_at
|
|
66004
|
+
});
|
|
66005
|
+
} else if (msg.a2a_channel_id) {
|
|
66006
|
+
await this._handleA2AMessageMLS({
|
|
66007
|
+
message_id: msg.message_id,
|
|
66008
|
+
group_id: msg.group_id,
|
|
66009
|
+
sender_device_id: msg.sender_device_id,
|
|
66010
|
+
epoch: msg.epoch,
|
|
66011
|
+
payload: msg.payload,
|
|
66012
|
+
a2a_channel_id: msg.a2a_channel_id,
|
|
66013
|
+
created_at: msg.created_at
|
|
66014
|
+
});
|
|
66015
|
+
} else if (msg.conversation_id) {
|
|
66016
|
+
await this._handleMessageMLS({
|
|
66017
|
+
message_id: msg.message_id,
|
|
66018
|
+
group_id: msg.group_id,
|
|
66019
|
+
sender_device_id: msg.sender_device_id,
|
|
66020
|
+
epoch: msg.epoch,
|
|
66021
|
+
payload: msg.payload,
|
|
66022
|
+
conversation_id: msg.conversation_id,
|
|
66023
|
+
created_at: msg.created_at
|
|
66024
|
+
});
|
|
66025
|
+
}
|
|
66026
|
+
}
|
|
66027
|
+
ackedIds.push(msg.queue_id);
|
|
66028
|
+
} catch (err) {
|
|
66029
|
+
console.warn(`[SecureChannel] Delivery ${msg.message_type} processing failed:`, err);
|
|
66030
|
+
nackedIds.push(msg.queue_id);
|
|
66031
|
+
}
|
|
66032
|
+
}
|
|
66033
|
+
if (nackedIds.length > 0) {
|
|
66034
|
+
try {
|
|
66035
|
+
await fetch(`${this.config.apiUrl}/api/v1/mls/delivery/nack`, {
|
|
66036
|
+
method: "POST",
|
|
66037
|
+
headers: {
|
|
66038
|
+
Authorization: `Bearer ${this._deviceJwt}`,
|
|
66039
|
+
"Content-Type": "application/json"
|
|
66040
|
+
},
|
|
66041
|
+
body: JSON.stringify({ queue_ids: nackedIds })
|
|
66042
|
+
});
|
|
66043
|
+
} catch {
|
|
66044
|
+
}
|
|
66045
|
+
}
|
|
66046
|
+
if (ackedIds.length > 0) {
|
|
66047
|
+
try {
|
|
66048
|
+
await fetch(`${this.config.apiUrl}/api/v1/mls/delivery/ack`, {
|
|
66049
|
+
method: "POST",
|
|
66050
|
+
headers: {
|
|
66051
|
+
Authorization: `Bearer ${this._deviceJwt}`,
|
|
66052
|
+
"Content-Type": "application/json"
|
|
66053
|
+
},
|
|
66054
|
+
body: JSON.stringify({ queue_ids: ackedIds, device_id: this._deviceId })
|
|
66055
|
+
});
|
|
66056
|
+
console.log(`[SecureChannel] Delivery acked ${ackedIds.length}/${messages.length}`);
|
|
66057
|
+
} catch (ackErr) {
|
|
66058
|
+
console.warn("[SecureChannel] Delivery ack failed:", ackErr);
|
|
66059
|
+
}
|
|
66060
|
+
}
|
|
66061
|
+
} catch (err) {
|
|
66062
|
+
console.warn("[SecureChannel] Delivery pull error:", err);
|
|
66063
|
+
} finally {
|
|
66064
|
+
this._deliveryPulling = false;
|
|
66065
|
+
}
|
|
66066
|
+
}
|
|
65260
66067
|
async _handleMlsSyncResponse(data) {
|
|
65261
66068
|
const action = data.action;
|
|
65262
66069
|
const groupId = data.group_id;
|
|
@@ -86158,7 +86965,7 @@ var init_mcp = __esm({
|
|
|
86158
86965
|
|
|
86159
86966
|
// ../../node_modules/@hono/node-server/dist/index.mjs
|
|
86160
86967
|
import { Readable as Readable2 } from "stream";
|
|
86161
|
-
import
|
|
86968
|
+
import crypto3 from "crypto";
|
|
86162
86969
|
var GlobalRequest, Request2, newHeadersFromIncoming, wrapBodyStream, newRequestFromIncoming, getRequestCache, requestCache, incomingKey, urlKey, headersKey, abortControllerKey, getAbortController, requestPrototype, responseCache, getResponseCache, cacheKey, GlobalResponse, Response2;
|
|
86163
86970
|
var init_dist2 = __esm({
|
|
86164
86971
|
"../../node_modules/@hono/node-server/dist/index.mjs"() {
|
|
@@ -86362,7 +87169,7 @@ var init_dist2 = __esm({
|
|
|
86362
87169
|
Object.setPrototypeOf(Response2, GlobalResponse);
|
|
86363
87170
|
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
|
|
86364
87171
|
if (typeof global.crypto === "undefined") {
|
|
86365
|
-
global.crypto =
|
|
87172
|
+
global.crypto = crypto3;
|
|
86366
87173
|
}
|
|
86367
87174
|
}
|
|
86368
87175
|
});
|
|
@@ -88137,21 +88944,22 @@ process.on("SIGINT", async () => {
|
|
|
88137
88944
|
|
|
88138
88945
|
@hpke/common/esm/src/curve/modular.js:
|
|
88139
88946
|
@hpke/common/esm/src/curve/montgomery.js:
|
|
88140
|
-
@noble/curves/utils.js:
|
|
88141
|
-
@noble/curves/abstract/modular.js:
|
|
88142
|
-
@noble/curves/abstract/curve.js:
|
|
88143
|
-
@noble/curves/abstract/edwards.js:
|
|
88144
|
-
@noble/curves/abstract/montgomery.js:
|
|
88145
|
-
@noble/curves/
|
|
88146
|
-
@noble/curves/
|
|
88147
|
-
@noble/curves/
|
|
88148
|
-
@noble/curves/
|
|
88149
|
-
@noble/curves/nist.js:
|
|
88947
|
+
@noble/curves/esm/utils.js:
|
|
88948
|
+
@noble/curves/esm/abstract/modular.js:
|
|
88949
|
+
@noble/curves/esm/abstract/curve.js:
|
|
88950
|
+
@noble/curves/esm/abstract/edwards.js:
|
|
88951
|
+
@noble/curves/esm/abstract/montgomery.js:
|
|
88952
|
+
@noble/curves/esm/ed25519.js:
|
|
88953
|
+
@noble/curves/esm/ed448.js:
|
|
88954
|
+
@noble/curves/esm/abstract/weierstrass.js:
|
|
88955
|
+
@noble/curves/esm/_shortw_utils.js:
|
|
88956
|
+
@noble/curves/esm/nist.js:
|
|
88150
88957
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
88151
88958
|
|
|
88152
88959
|
@noble/ciphers/utils.js:
|
|
88153
88960
|
(*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
|
|
88154
88961
|
|
|
88962
|
+
@noble/hashes/esm/utils.js:
|
|
88155
88963
|
@noble/hashes/utils.js:
|
|
88156
88964
|
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
88157
88965
|
*/
|