@holoscript/core 6.0.2 → 6.0.4
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/README.md +38 -38
- package/dist/GLTFPipeline-DEN36VNK.js +12 -0
- package/dist/GLTFPipeline-YPCAK236.cjs +33 -0
- package/dist/{HoloScriptPlusParser-BZR5DELQ.js → HoloScriptPlusParser-BN6KVRCM.js} +5 -5
- package/dist/{HoloScriptPlusParser-SBMYDNXO.cjs → HoloScriptPlusParser-NC5FE6AL.cjs} +16 -16
- package/dist/{USDZExporter-YA55ZS35.js → USDZExporter-NTMBNTDB.js} +3 -3
- package/dist/{USDZExporter-MHEHXZB4.cjs → USDZExporter-UWGWNMMD.cjs} +3 -3
- package/dist/{chunk-32TWR3HE.js → chunk-2CWOLHTE.js} +3 -4
- package/dist/{chunk-2UX5LRAP.cjs → chunk-33LSUQDD.cjs} +33 -31
- package/dist/{chunk-LBPEZQAF.js → chunk-3FJCK5XA.js} +7 -7
- package/dist/{chunk-EGIZHYJP.cjs → chunk-3SAK5KFL.cjs} +2 -4
- package/dist/{chunk-PJMOXFPR.cjs → chunk-4XSNJCLC.cjs} +25 -27
- package/dist/{chunk-HKCVM6OK.cjs → chunk-5BGSECRJ.cjs} +21 -21
- package/dist/{chunk-EMO7HAKJ.cjs → chunk-5O6TQC6M.cjs} +26 -30
- package/dist/{chunk-XSUZMPVQ.cjs → chunk-5OEOHAAW.cjs} +26 -26
- package/dist/{chunk-EJA7G2C4.cjs → chunk-5WUNN6ZN.cjs} +2 -2
- package/dist/{chunk-CQDOF3G7.cjs → chunk-6TZPZCOJ.cjs} +18 -18
- package/dist/{chunk-NRUB55IT.cjs → chunk-6UEHYZ7V.cjs} +18 -16
- package/dist/{chunk-V42NTCFH.js → chunk-6XSERL6L.js} +4230 -2197
- package/dist/{chunk-X4YVN7H3.cjs → chunk-72EQECGT.cjs} +37 -17
- package/dist/{chunk-4KJ2R7VP.cjs → chunk-7AGYRWKW.cjs} +19 -19
- package/dist/{chunk-UQW6SLM5.js → chunk-A7PIMZGU.js} +110 -19
- package/dist/{chunk-RT7LJRSF.cjs → chunk-ATSKSYVE.cjs} +1013 -6708
- package/dist/{chunk-WN3YF33G.cjs → chunk-B5TCIAPQ.cjs} +9 -10
- package/dist/{chunk-AIUXRS74.cjs → chunk-BF2235SI.cjs} +4275 -2242
- package/dist/{chunk-DIEDKX5B.cjs → chunk-BND3ST2K.cjs} +18 -16
- package/dist/{chunk-EPWRXL6S.js → chunk-BU7VWW2K.js} +29 -29
- package/dist/{chunk-6OQBLABR.js → chunk-BWFJEM5A.js} +368 -189
- package/dist/{chunk-ARNKA274.cjs → chunk-CAUCGUEA.cjs} +6 -6
- package/dist/{chunk-YCMQQQ5U.cjs → chunk-CBJSLA2E.cjs} +398 -219
- package/dist/{chunk-BU5ZAFMC.js → chunk-CDPGV4DN.js} +6 -7
- package/dist/{chunk-CO2VM2DK.js → chunk-CS2EMTGF.js} +10 -9
- package/dist/{chunk-AW7WAELW.js → chunk-DMG7C4H2.js} +4 -4
- package/dist/{chunk-XSF76QRU.js → chunk-DXJQDCFL.js} +3 -3
- package/dist/{chunk-4FCZDTD5.js → chunk-E3FWRT3Z.js} +7 -9
- package/dist/{chunk-KYM4XRFG.js → chunk-E3UALNFA.js} +4 -4
- package/dist/{chunk-GC3YU46J.js → chunk-EONILVMF.js} +2 -2
- package/dist/{chunk-VJVCD5T5.cjs → chunk-EQV4R3EV.cjs} +22 -22
- package/dist/{chunk-FEFHPUEM.cjs → chunk-F3HH56EB.cjs} +74 -658
- package/dist/{chunk-WYH4GVZ5.js → chunk-F4IULT7N.js} +2 -2
- package/dist/{chunk-XDXZM3ZP.cjs → chunk-FFKU7BTK.cjs} +19 -19
- package/dist/{chunk-NKRKT6V2.js → chunk-FHQVYCH2.js} +11 -10
- package/dist/{chunk-7H5UNJZD.cjs → chunk-FSF7EQVA.cjs} +11 -10
- package/dist/{chunk-KUJRR4FJ.js → chunk-G4VZTCIB.js} +9 -7
- package/dist/{chunk-A6GO3DPZ.cjs → chunk-G7CT3EMP.cjs} +4 -4
- package/dist/{chunk-EUFLX2PI.js → chunk-GGHSW2NN.js} +989 -6611
- package/dist/chunk-GVUR45UF.cjs +777 -0
- package/dist/{chunk-ODGMVILH.js → chunk-H5Z7NASB.js} +3 -3
- package/dist/{chunk-7KPI4EKH.cjs → chunk-HE7ULERA.cjs} +45 -49
- package/dist/{chunk-26TLYBFD.js → chunk-HPS76H7Q.js} +3 -3
- package/dist/{chunk-RE3OKSYF.cjs → chunk-HQUEA5R6.cjs} +6 -6
- package/dist/{chunk-ZGTGVSTZ.js → chunk-HYNTS5CP.js} +2 -2
- package/dist/{chunk-PBA6NXCT.cjs → chunk-IBDG74G2.cjs} +6 -3
- package/dist/chunk-IFNQFCTM.js +3098 -0
- package/dist/{chunk-ZL6VJ6SN.js → chunk-IWI6J7FX.js} +5 -5
- package/dist/{chunk-3KEU5QYY.cjs → chunk-K3JDKWGI.cjs} +118 -23
- package/dist/{chunk-NLPSZT4C.js → chunk-K6EKD26I.js} +6 -6
- package/dist/chunk-KCQ5NDYC.cjs +3172 -0
- package/dist/{chunk-ELLQPFAF.js → chunk-KED34ILP.js} +11 -9
- package/dist/{chunk-BY3B7ZYV.cjs → chunk-KSGXLT74.cjs} +3 -3
- package/dist/{chunk-65RFOWZI.js → chunk-L4G4RLXX.js} +9 -7
- package/dist/{chunk-4SMUJFHL.js → chunk-LDP5OK6G.js} +6 -3
- package/dist/{chunk-VZNKJZTT.cjs → chunk-LGGRPKTV.cjs} +82 -96
- package/dist/{chunk-C2QHVHZF.js → chunk-LSW7P7ML.js} +23 -414
- package/dist/{chunk-HHS6FMOU.cjs → chunk-LXJ4667L.cjs} +83 -22
- package/dist/{chunk-H6WMMLQK.cjs → chunk-LZ266PCM.cjs} +20 -13
- package/dist/{chunk-V2ILLPHK.cjs → chunk-MD6KDHVE.cjs} +10 -10
- package/dist/{chunk-6WNCRE6F.js → chunk-MEASWI2Y.js} +5 -5
- package/dist/chunk-MPXBVFHQ.js +768 -0
- package/dist/{chunk-WUXIRGZP.cjs → chunk-NCUKG4SK.cjs} +304 -144
- package/dist/chunk-NDQNIJEH.js +1715 -0
- package/dist/{chunk-Y5MUAYTO.js → chunk-NOZZ46QU.js} +9 -8
- package/dist/{chunk-F5LVGHNT.js → chunk-OFKWH2IP.js} +3 -3
- package/dist/{chunk-SPDELRRV.cjs → chunk-PMGODDJA.cjs} +12 -12
- package/dist/{chunk-I3XGTIHM.cjs → chunk-Q4QX3AET.cjs} +2 -2
- package/dist/{chunk-Y7VK5TH3.cjs → chunk-Q5JT3YML.cjs} +10 -10
- package/dist/{chunk-TSWTWZ42.cjs → chunk-Q5SJOGHQ.cjs} +247 -205
- package/dist/{chunk-M6FU6S22.js → chunk-QGKNANZ3.js} +251 -91
- package/dist/{chunk-WFJIDI2N.cjs → chunk-QLEAOI3Q.cjs} +10 -10
- package/dist/{chunk-VK5AXKO3.js → chunk-R7MA7QWV.js} +70 -84
- package/dist/{chunk-W76ETJTI.js → chunk-RVYPEYPX.js} +6 -6
- package/dist/{chunk-MWEFR6YQ.js → chunk-S2N5TNMA.js} +7 -9
- package/dist/{chunk-NCUHGRTZ.js → chunk-S565K7NK.js} +7 -7
- package/dist/{chunk-AC4BSHFV.js → chunk-SDAMZIRE.js} +5 -5
- package/dist/{chunk-HBZYCASG.js → chunk-T36DDXSF.js} +75 -33
- package/dist/{chunk-BO2OKHIY.js → chunk-T4NKMBDL.js} +30 -611
- package/dist/{chunk-7X2IEJIE.cjs → chunk-T7LEXZUZ.cjs} +29 -29
- package/dist/{chunk-HUFNKFA6.js → chunk-TEWCN33Y.js} +8 -12
- package/dist/{chunk-L3Z2HIWJ.cjs → chunk-TQSZUOW5.cjs} +2 -2
- package/dist/chunk-TSH3MSQU.cjs +129 -0
- package/dist/{chunk-PLMYCCA4.js → chunk-UERJ3YJV.js} +6 -6
- package/dist/{chunk-7N3JIJMT.js → chunk-UPJBDCVF.js} +6 -6
- package/dist/{chunk-CMYAWUX3.js → chunk-V3NN3HPP.js} +12 -5
- package/dist/{chunk-SUCBB66F.js → chunk-WB4Z63GG.js} +3 -3
- package/dist/{chunk-PPULB4GG.cjs → chunk-WDW67DZB.cjs} +68 -68
- package/dist/chunk-WGMEAYBG.js +126 -0
- package/dist/{chunk-VSXOIUCF.cjs → chunk-X4ZF6CNE.cjs} +7 -7
- package/dist/{chunk-HF4OFY25.cjs → chunk-X6SEAXAX.cjs} +29 -445
- package/dist/{chunk-C7BNX4XJ.js → chunk-XCWFGZAA.js} +6 -6
- package/dist/{chunk-CNVM7J3M.js → chunk-XD6IYDUX.js} +34 -14
- package/dist/chunk-XG23EUQX.cjs +1717 -0
- package/dist/{chunk-DN7UFU63.cjs → chunk-XRKWN5PL.cjs} +12 -11
- package/dist/{chunk-XNMEH2BI.js → chunk-XUTX5CBW.js} +3 -3
- package/dist/{chunk-PQLGZKMC.cjs → chunk-XWPNTWDN.cjs} +26 -26
- package/dist/{chunk-NTMZSDXM.cjs → chunk-XXINBTZK.cjs} +43 -43
- package/dist/{chunk-74YCHHTE.js → chunk-YCXFCXDS.js} +8 -12
- package/dist/{chunk-KDB6BUMB.js → chunk-YQK5JNFK.js} +77 -18
- package/dist/{chunk-DH5G2JUA.cjs → chunk-Z34RLXRA.cjs} +44 -46
- package/dist/{chunk-XH7SE4HH.cjs → chunk-ZP4D3CSX.cjs} +19 -19
- package/dist/cli/holoscript-runner.cjs +33 -32
- package/dist/cli/holoscript-runner.js +13 -12
- package/dist/codebase/index.cjs +1 -1
- package/dist/codebase/index.d.ts +25 -0
- package/dist/codebase/index.js +1 -1
- package/dist/compiler/agent-inference.cjs +7 -8
- package/dist/compiler/agent-inference.js +3 -4
- package/dist/compiler/android-xr.cjs +7 -8
- package/dist/compiler/android-xr.js +5 -6
- package/dist/compiler/android.cjs +8 -9
- package/dist/compiler/android.js +6 -7
- package/dist/compiler/ar.cjs +6 -7
- package/dist/compiler/ar.js +4 -5
- package/dist/compiler/babylon.cjs +8 -9
- package/dist/compiler/babylon.js +7 -8
- package/dist/compiler/coco.cjs +1 -1
- package/dist/compiler/coco.js +1 -1
- package/dist/compiler/domain-block-utils.cjs +158 -151
- package/dist/compiler/domain-block-utils.js +4 -5
- package/dist/compiler/dtdl.cjs +7 -8
- package/dist/compiler/dtdl.js +4 -5
- package/dist/compiler/gltf-pipeline.cjs +9 -9
- package/dist/compiler/gltf-pipeline.js +2 -2
- package/dist/compiler/godot.cjs +6 -7
- package/dist/compiler/godot.js +5 -6
- package/dist/compiler/incremental.cjs +7 -8
- package/dist/compiler/incremental.js +2 -3
- package/dist/compiler/index.cjs +1934 -878
- package/dist/compiler/index.js +1904 -842
- package/dist/compiler/ios.cjs +8 -9
- package/dist/compiler/ios.js +6 -7
- package/dist/compiler/multi-layer.cjs +10 -17
- package/dist/compiler/multi-layer.js +9 -10
- package/dist/compiler/nodetoy.cjs +1 -1
- package/dist/compiler/nodetoy.js +1 -1
- package/dist/compiler/openxr.cjs +6 -7
- package/dist/compiler/openxr.js +5 -6
- package/dist/compiler/playcanvas.cjs +7 -8
- package/dist/compiler/playcanvas.js +6 -7
- package/dist/compiler/r3f.cjs +13 -14
- package/dist/compiler/r3f.js +8 -9
- package/dist/compiler/remotion.cjs +1 -1
- package/dist/compiler/remotion.js +1 -1
- package/dist/compiler/reproducibility.cjs +1 -1
- package/dist/compiler/reproducibility.js +1 -1
- package/dist/compiler/sdf.cjs +7 -8
- package/dist/compiler/sdf.js +5 -6
- package/dist/compiler/semantic-scene.cjs +7 -7
- package/dist/compiler/semantic-scene.js +2 -2
- package/dist/compiler/state.cjs +5 -6
- package/dist/compiler/state.js +3 -4
- package/dist/compiler/trait-composition.cjs +7 -8
- package/dist/compiler/trait-composition.js +3 -4
- package/dist/compiler/unity.cjs +6 -7
- package/dist/compiler/unity.js +5 -6
- package/dist/compiler/unreal.cjs +7 -8
- package/dist/compiler/unreal.js +5 -6
- package/dist/compiler/urdf.cjs +13 -14
- package/dist/compiler/urdf.js +5 -6
- package/dist/compiler/usd-physics.cjs +7 -8
- package/dist/compiler/usd-physics.js +4 -5
- package/dist/compiler/visionos.cjs +6 -7
- package/dist/compiler/visionos.js +5 -6
- package/dist/compiler/vrchat.cjs +7 -8
- package/dist/compiler/vrchat.js +5 -6
- package/dist/compiler/vrr.cjs +7 -8
- package/dist/compiler/vrr.js +5 -6
- package/dist/compiler/wasm.cjs +10 -11
- package/dist/compiler/wasm.js +5 -6
- package/dist/compiler/webgpu.cjs +6 -7
- package/dist/compiler/webgpu.js +5 -6
- package/dist/constants.d.ts +3 -0
- package/dist/debugger.cjs +7 -7
- package/dist/debugger.js +5 -5
- package/dist/entries/interop.cjs +1 -1
- package/dist/entries/interop.d.ts +9 -0
- package/dist/entries/interop.js +1 -1
- package/dist/entries/scripting.cjs +18 -17
- package/dist/entries/scripting.d.ts +7 -0
- package/dist/entries/scripting.js +8 -7
- package/dist/index.cjs +6773 -27555
- package/dist/index.d.ts +19 -0
- package/dist/index.js +5212 -26101
- package/dist/math/vec3.cjs +1 -1
- package/dist/math/vec3.js +1 -1
- package/dist/ml-dsa-PHCWUBPX.cjs +1178 -0
- package/dist/ml-dsa-WYLJHJO6.js +1178 -0
- package/dist/parser.cjs +11 -10
- package/dist/parser.js +8 -7
- package/dist/{playwright-BIZXMLD2.js → playwright-5OSAPTNH.js} +3 -3
- package/dist/{playwright-7DTEQCBD.cjs → playwright-RL6GY4F7.cjs} +1985 -1985
- package/dist/runtime.cjs +5 -5
- package/dist/runtime.js +4 -4
- package/dist/self-improvement/index.d.ts +0 -48
- package/dist/storage/index.cjs +1 -1
- package/dist/storage/index.d.ts +24 -0
- package/dist/storage/index.js +1 -1
- package/dist/tools/index.d.ts +12 -0
- package/dist/traits/index.cjs +925 -607
- package/dist/traits/index.js +137 -20
- package/dist/type-checker.cjs +4 -4
- package/dist/type-checker.js +2 -2
- package/package.json +54 -19
- package/LICENSE +0 -21
- package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
- package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
- package/dist/chunk-CN4NOESF.cjs +0 -416
- package/dist/chunk-DXVCEFZB.js +0 -2027
- package/dist/chunk-ENV7K6XA.js +0 -282
- package/dist/chunk-H7XMORZI.js +0 -2731
- package/dist/chunk-HAN4V3PF.cjs +0 -2037
- package/dist/chunk-LER4WXW5.cjs +0 -286
- package/dist/chunk-QHVVVN47.cjs +0 -2033
- package/dist/chunk-QWKUKVRE.js +0 -2026
- package/dist/chunk-UITWA6DV.cjs +0 -2829
- package/dist/chunk-X67XRI2T.js +0 -410
- package/dist/post-quantum-JTTAAGO3.cjs +0 -6
- package/dist/post-quantum-RVPVDEPI.js +0 -4
- package/dist/wot/index.cjs +0 -29
- package/dist/wot/index.js +0 -4
|
@@ -0,0 +1,1178 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk3SAK5KFL_cjs = require('./chunk-3SAK5KFL.cjs');
|
|
4
|
+
|
|
5
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/utils.js
|
|
6
|
+
function isBytes(a) {
|
|
7
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
8
|
+
}
|
|
9
|
+
function anumber(n, title = "") {
|
|
10
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
11
|
+
const prefix = title && `"${title}" `;
|
|
12
|
+
throw new Error(`${prefix}expected integer >= 0, got ${n}`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function abytes(value, length, title = "") {
|
|
16
|
+
const bytes = isBytes(value);
|
|
17
|
+
const len = value?.length;
|
|
18
|
+
const needsLen = length !== void 0;
|
|
19
|
+
if (!bytes || needsLen && len !== length) {
|
|
20
|
+
const prefix = title && `"${title}" `;
|
|
21
|
+
const ofLen = needsLen ? ` of length ${length}` : "";
|
|
22
|
+
const got = bytes ? `length=${len}` : `type=${typeof value}`;
|
|
23
|
+
throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
function aexists(instance, checkFinished = true) {
|
|
28
|
+
if (instance.destroyed)
|
|
29
|
+
throw new Error("Hash instance has been destroyed");
|
|
30
|
+
if (checkFinished && instance.finished)
|
|
31
|
+
throw new Error("Hash#digest() has already been called");
|
|
32
|
+
}
|
|
33
|
+
function aoutput(out, instance) {
|
|
34
|
+
abytes(out, void 0, "digestInto() output");
|
|
35
|
+
const min = instance.outputLen;
|
|
36
|
+
if (out.length < min) {
|
|
37
|
+
throw new Error('"digestInto() output" expected to be of length >=' + min);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function u32(arr) {
|
|
41
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
42
|
+
}
|
|
43
|
+
function clean(...arrays) {
|
|
44
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
45
|
+
arrays[i].fill(0);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function byteSwap(word) {
|
|
49
|
+
return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
|
|
50
|
+
}
|
|
51
|
+
function byteSwap32(arr) {
|
|
52
|
+
for (let i = 0; i < arr.length; i++) {
|
|
53
|
+
arr[i] = byteSwap(arr[i]);
|
|
54
|
+
}
|
|
55
|
+
return arr;
|
|
56
|
+
}
|
|
57
|
+
function concatBytes(...arrays) {
|
|
58
|
+
let sum = 0;
|
|
59
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
60
|
+
const a = arrays[i];
|
|
61
|
+
abytes(a);
|
|
62
|
+
sum += a.length;
|
|
63
|
+
}
|
|
64
|
+
const res = new Uint8Array(sum);
|
|
65
|
+
for (let i = 0, pad = 0; i < arrays.length; i++) {
|
|
66
|
+
const a = arrays[i];
|
|
67
|
+
res.set(a, pad);
|
|
68
|
+
pad += a.length;
|
|
69
|
+
}
|
|
70
|
+
return res;
|
|
71
|
+
}
|
|
72
|
+
function createHasher(hashCons, info = {}) {
|
|
73
|
+
const hashC = (msg, opts) => hashCons(opts).update(msg).digest();
|
|
74
|
+
const tmp = hashCons(void 0);
|
|
75
|
+
hashC.outputLen = tmp.outputLen;
|
|
76
|
+
hashC.blockLen = tmp.blockLen;
|
|
77
|
+
hashC.create = (opts) => hashCons(opts);
|
|
78
|
+
Object.assign(hashC, info);
|
|
79
|
+
return Object.freeze(hashC);
|
|
80
|
+
}
|
|
81
|
+
function randomBytes(bytesLength = 32) {
|
|
82
|
+
const cr = typeof globalThis === "object" ? globalThis.crypto : null;
|
|
83
|
+
if (typeof cr?.getRandomValues !== "function")
|
|
84
|
+
throw new Error("crypto.getRandomValues must be defined");
|
|
85
|
+
return cr.getRandomValues(new Uint8Array(bytesLength));
|
|
86
|
+
}
|
|
87
|
+
var isLE, swap32IfBE, oidNist;
|
|
88
|
+
var init_utils = chunk3SAK5KFL_cjs.__esm({
|
|
89
|
+
"../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/utils.js"() {
|
|
90
|
+
isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
91
|
+
swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
92
|
+
oidNist = (suffix) => ({
|
|
93
|
+
oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/utils.js
|
|
99
|
+
function abool(value, title = "") {
|
|
100
|
+
if (typeof value !== "boolean") {
|
|
101
|
+
const prefix = title && `"${title}" `;
|
|
102
|
+
throw new Error(prefix + "expected boolean, got type=" + typeof value);
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
var init_utils2 = chunk3SAK5KFL_cjs.__esm({
|
|
107
|
+
"../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/utils.js"() {
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js
|
|
112
|
+
function fromBig(n, le = false) {
|
|
113
|
+
if (le)
|
|
114
|
+
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
115
|
+
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
116
|
+
}
|
|
117
|
+
function split(lst, le = false) {
|
|
118
|
+
const len = lst.length;
|
|
119
|
+
let Ah = new Uint32Array(len);
|
|
120
|
+
let Al = new Uint32Array(len);
|
|
121
|
+
for (let i = 0; i < len; i++) {
|
|
122
|
+
const { h, l } = fromBig(lst[i], le);
|
|
123
|
+
[Ah[i], Al[i]] = [h, l];
|
|
124
|
+
}
|
|
125
|
+
return [Ah, Al];
|
|
126
|
+
}
|
|
127
|
+
var U32_MASK64, _32n, rotlSH, rotlSL, rotlBH, rotlBL;
|
|
128
|
+
var init_u64 = chunk3SAK5KFL_cjs.__esm({
|
|
129
|
+
"../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js"() {
|
|
130
|
+
U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
131
|
+
_32n = /* @__PURE__ */ BigInt(32);
|
|
132
|
+
rotlSH = (h, l, s) => h << s | l >>> 32 - s;
|
|
133
|
+
rotlSL = (h, l, s) => l << s | h >>> 32 - s;
|
|
134
|
+
rotlBH = (h, l, s) => l << s - 32 | h >>> 64 - s;
|
|
135
|
+
rotlBL = (h, l, s) => h << s - 32 | l >>> 64 - s;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
// ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/sha3.js
|
|
140
|
+
function keccakP(s, rounds = 24) {
|
|
141
|
+
const B = new Uint32Array(5 * 2);
|
|
142
|
+
for (let round = 24 - rounds; round < 24; round++) {
|
|
143
|
+
for (let x = 0; x < 10; x++)
|
|
144
|
+
B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
|
|
145
|
+
for (let x = 0; x < 10; x += 2) {
|
|
146
|
+
const idx1 = (x + 8) % 10;
|
|
147
|
+
const idx0 = (x + 2) % 10;
|
|
148
|
+
const B0 = B[idx0];
|
|
149
|
+
const B1 = B[idx0 + 1];
|
|
150
|
+
const Th = rotlH(B0, B1, 1) ^ B[idx1];
|
|
151
|
+
const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
|
|
152
|
+
for (let y = 0; y < 50; y += 10) {
|
|
153
|
+
s[x + y] ^= Th;
|
|
154
|
+
s[x + y + 1] ^= Tl;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
let curH = s[2];
|
|
158
|
+
let curL = s[3];
|
|
159
|
+
for (let t = 0; t < 24; t++) {
|
|
160
|
+
const shift = SHA3_ROTL[t];
|
|
161
|
+
const Th = rotlH(curH, curL, shift);
|
|
162
|
+
const Tl = rotlL(curH, curL, shift);
|
|
163
|
+
const PI = SHA3_PI[t];
|
|
164
|
+
curH = s[PI];
|
|
165
|
+
curL = s[PI + 1];
|
|
166
|
+
s[PI] = Th;
|
|
167
|
+
s[PI + 1] = Tl;
|
|
168
|
+
}
|
|
169
|
+
for (let y = 0; y < 50; y += 10) {
|
|
170
|
+
for (let x = 0; x < 10; x++)
|
|
171
|
+
B[x] = s[y + x];
|
|
172
|
+
for (let x = 0; x < 10; x++)
|
|
173
|
+
s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
|
|
174
|
+
}
|
|
175
|
+
s[0] ^= SHA3_IOTA_H[round];
|
|
176
|
+
s[1] ^= SHA3_IOTA_L[round];
|
|
177
|
+
}
|
|
178
|
+
clean(B);
|
|
179
|
+
}
|
|
180
|
+
var _0n, _1n, _2n, _7n, _256n, _0x71n, SHA3_PI, SHA3_ROTL, _SHA3_IOTA, IOTAS, SHA3_IOTA_H, SHA3_IOTA_L, rotlH, rotlL, Keccak, genShake, shake128, shake256;
|
|
181
|
+
var init_sha3 = chunk3SAK5KFL_cjs.__esm({
|
|
182
|
+
"../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/sha3.js"() {
|
|
183
|
+
init_u64();
|
|
184
|
+
init_utils();
|
|
185
|
+
_0n = BigInt(0);
|
|
186
|
+
_1n = BigInt(1);
|
|
187
|
+
_2n = BigInt(2);
|
|
188
|
+
_7n = BigInt(7);
|
|
189
|
+
_256n = BigInt(256);
|
|
190
|
+
_0x71n = BigInt(113);
|
|
191
|
+
SHA3_PI = [];
|
|
192
|
+
SHA3_ROTL = [];
|
|
193
|
+
_SHA3_IOTA = [];
|
|
194
|
+
for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
|
|
195
|
+
[x, y] = [y, (2 * x + 3 * y) % 5];
|
|
196
|
+
SHA3_PI.push(2 * (5 * y + x));
|
|
197
|
+
SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
|
|
198
|
+
let t = _0n;
|
|
199
|
+
for (let j = 0; j < 7; j++) {
|
|
200
|
+
R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
|
|
201
|
+
if (R & _2n)
|
|
202
|
+
t ^= _1n << (_1n << BigInt(j)) - _1n;
|
|
203
|
+
}
|
|
204
|
+
_SHA3_IOTA.push(t);
|
|
205
|
+
}
|
|
206
|
+
IOTAS = split(_SHA3_IOTA, true);
|
|
207
|
+
SHA3_IOTA_H = IOTAS[0];
|
|
208
|
+
SHA3_IOTA_L = IOTAS[1];
|
|
209
|
+
rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
|
|
210
|
+
rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
|
|
211
|
+
Keccak = class _Keccak {
|
|
212
|
+
// NOTE: we accept arguments in bytes instead of bits here.
|
|
213
|
+
constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
|
|
214
|
+
chunk3SAK5KFL_cjs.__publicField(this, "state");
|
|
215
|
+
chunk3SAK5KFL_cjs.__publicField(this, "pos", 0);
|
|
216
|
+
chunk3SAK5KFL_cjs.__publicField(this, "posOut", 0);
|
|
217
|
+
chunk3SAK5KFL_cjs.__publicField(this, "finished", false);
|
|
218
|
+
chunk3SAK5KFL_cjs.__publicField(this, "state32");
|
|
219
|
+
chunk3SAK5KFL_cjs.__publicField(this, "destroyed", false);
|
|
220
|
+
chunk3SAK5KFL_cjs.__publicField(this, "blockLen");
|
|
221
|
+
chunk3SAK5KFL_cjs.__publicField(this, "suffix");
|
|
222
|
+
chunk3SAK5KFL_cjs.__publicField(this, "outputLen");
|
|
223
|
+
chunk3SAK5KFL_cjs.__publicField(this, "enableXOF", false);
|
|
224
|
+
chunk3SAK5KFL_cjs.__publicField(this, "rounds");
|
|
225
|
+
this.blockLen = blockLen;
|
|
226
|
+
this.suffix = suffix;
|
|
227
|
+
this.outputLen = outputLen;
|
|
228
|
+
this.enableXOF = enableXOF;
|
|
229
|
+
this.rounds = rounds;
|
|
230
|
+
anumber(outputLen, "outputLen");
|
|
231
|
+
if (!(0 < blockLen && blockLen < 200))
|
|
232
|
+
throw new Error("only keccak-f1600 function is supported");
|
|
233
|
+
this.state = new Uint8Array(200);
|
|
234
|
+
this.state32 = u32(this.state);
|
|
235
|
+
}
|
|
236
|
+
clone() {
|
|
237
|
+
return this._cloneInto();
|
|
238
|
+
}
|
|
239
|
+
keccak() {
|
|
240
|
+
swap32IfBE(this.state32);
|
|
241
|
+
keccakP(this.state32, this.rounds);
|
|
242
|
+
swap32IfBE(this.state32);
|
|
243
|
+
this.posOut = 0;
|
|
244
|
+
this.pos = 0;
|
|
245
|
+
}
|
|
246
|
+
update(data) {
|
|
247
|
+
aexists(this);
|
|
248
|
+
abytes(data);
|
|
249
|
+
const { blockLen, state } = this;
|
|
250
|
+
const len = data.length;
|
|
251
|
+
for (let pos = 0; pos < len; ) {
|
|
252
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
253
|
+
for (let i = 0; i < take; i++)
|
|
254
|
+
state[this.pos++] ^= data[pos++];
|
|
255
|
+
if (this.pos === blockLen)
|
|
256
|
+
this.keccak();
|
|
257
|
+
}
|
|
258
|
+
return this;
|
|
259
|
+
}
|
|
260
|
+
finish() {
|
|
261
|
+
if (this.finished)
|
|
262
|
+
return;
|
|
263
|
+
this.finished = true;
|
|
264
|
+
const { state, suffix, pos, blockLen } = this;
|
|
265
|
+
state[pos] ^= suffix;
|
|
266
|
+
if ((suffix & 128) !== 0 && pos === blockLen - 1)
|
|
267
|
+
this.keccak();
|
|
268
|
+
state[blockLen - 1] ^= 128;
|
|
269
|
+
this.keccak();
|
|
270
|
+
}
|
|
271
|
+
writeInto(out) {
|
|
272
|
+
aexists(this, false);
|
|
273
|
+
abytes(out);
|
|
274
|
+
this.finish();
|
|
275
|
+
const bufferOut = this.state;
|
|
276
|
+
const { blockLen } = this;
|
|
277
|
+
for (let pos = 0, len = out.length; pos < len; ) {
|
|
278
|
+
if (this.posOut >= blockLen)
|
|
279
|
+
this.keccak();
|
|
280
|
+
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
281
|
+
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
282
|
+
this.posOut += take;
|
|
283
|
+
pos += take;
|
|
284
|
+
}
|
|
285
|
+
return out;
|
|
286
|
+
}
|
|
287
|
+
xofInto(out) {
|
|
288
|
+
if (!this.enableXOF)
|
|
289
|
+
throw new Error("XOF is not possible for this instance");
|
|
290
|
+
return this.writeInto(out);
|
|
291
|
+
}
|
|
292
|
+
xof(bytes) {
|
|
293
|
+
anumber(bytes);
|
|
294
|
+
return this.xofInto(new Uint8Array(bytes));
|
|
295
|
+
}
|
|
296
|
+
digestInto(out) {
|
|
297
|
+
aoutput(out, this);
|
|
298
|
+
if (this.finished)
|
|
299
|
+
throw new Error("digest() was already called");
|
|
300
|
+
this.writeInto(out);
|
|
301
|
+
this.destroy();
|
|
302
|
+
return out;
|
|
303
|
+
}
|
|
304
|
+
digest() {
|
|
305
|
+
return this.digestInto(new Uint8Array(this.outputLen));
|
|
306
|
+
}
|
|
307
|
+
destroy() {
|
|
308
|
+
this.destroyed = true;
|
|
309
|
+
clean(this.state);
|
|
310
|
+
}
|
|
311
|
+
_cloneInto(to) {
|
|
312
|
+
const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
|
|
313
|
+
to || (to = new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds));
|
|
314
|
+
to.state32.set(this.state32);
|
|
315
|
+
to.pos = this.pos;
|
|
316
|
+
to.posOut = this.posOut;
|
|
317
|
+
to.finished = this.finished;
|
|
318
|
+
to.rounds = rounds;
|
|
319
|
+
to.suffix = suffix;
|
|
320
|
+
to.outputLen = outputLen;
|
|
321
|
+
to.enableXOF = enableXOF;
|
|
322
|
+
to.destroyed = this.destroyed;
|
|
323
|
+
return to;
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
genShake = (suffix, blockLen, outputLen, info = {}) => createHasher((opts = {}) => new Keccak(blockLen, suffix, opts.dkLen === void 0 ? outputLen : opts.dkLen, true), info);
|
|
327
|
+
shake128 = /* @__PURE__ */ genShake(31, 168, 16, /* @__PURE__ */ oidNist(11));
|
|
328
|
+
shake256 = /* @__PURE__ */ genShake(31, 136, 32, /* @__PURE__ */ oidNist(12));
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
// ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/abstract/fft.js
|
|
333
|
+
function checkU32(n) {
|
|
334
|
+
if (!Number.isSafeInteger(n) || n < 0 || n > 4294967295)
|
|
335
|
+
throw new Error("wrong u32 integer:" + n);
|
|
336
|
+
return n;
|
|
337
|
+
}
|
|
338
|
+
function isPowerOfTwo(x) {
|
|
339
|
+
checkU32(x);
|
|
340
|
+
return (x & x - 1) === 0 && x !== 0;
|
|
341
|
+
}
|
|
342
|
+
function reverseBits(n, bits) {
|
|
343
|
+
checkU32(n);
|
|
344
|
+
let reversed = 0;
|
|
345
|
+
for (let i = 0; i < bits; i++, n >>>= 1)
|
|
346
|
+
reversed = reversed << 1 | n & 1;
|
|
347
|
+
return reversed;
|
|
348
|
+
}
|
|
349
|
+
function log2(n) {
|
|
350
|
+
checkU32(n);
|
|
351
|
+
return 31 - Math.clz32(n);
|
|
352
|
+
}
|
|
353
|
+
function bitReversalInplace(values) {
|
|
354
|
+
const n = values.length;
|
|
355
|
+
if (n < 2 || !isPowerOfTwo(n))
|
|
356
|
+
throw new Error("n must be a power of 2 and greater than 1. Got " + n);
|
|
357
|
+
const bits = log2(n);
|
|
358
|
+
for (let i = 0; i < n; i++) {
|
|
359
|
+
const j = reverseBits(i, bits);
|
|
360
|
+
if (i < j) {
|
|
361
|
+
const tmp = values[i];
|
|
362
|
+
values[i] = values[j];
|
|
363
|
+
values[j] = tmp;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return values;
|
|
367
|
+
}
|
|
368
|
+
var FFTCore;
|
|
369
|
+
var init_fft = chunk3SAK5KFL_cjs.__esm({
|
|
370
|
+
"../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/abstract/fft.js"() {
|
|
371
|
+
FFTCore = (F2, coreOpts) => {
|
|
372
|
+
const { N: N2, roots, dit, invertButterflies = false, skipStages = 0, brp = true } = coreOpts;
|
|
373
|
+
const bits = log2(N2);
|
|
374
|
+
if (!isPowerOfTwo(N2))
|
|
375
|
+
throw new Error("FFT: Polynomial size should be power of two");
|
|
376
|
+
const isDit = dit !== invertButterflies;
|
|
377
|
+
return (values) => {
|
|
378
|
+
if (values.length !== N2)
|
|
379
|
+
throw new Error("FFT: wrong Polynomial length");
|
|
380
|
+
if (dit && brp)
|
|
381
|
+
bitReversalInplace(values);
|
|
382
|
+
for (let i = 0, g = 1; i < bits - skipStages; i++) {
|
|
383
|
+
const s = dit ? i + 1 + skipStages : bits - i;
|
|
384
|
+
const m = 1 << s;
|
|
385
|
+
const m2 = m >> 1;
|
|
386
|
+
const stride = N2 >> s;
|
|
387
|
+
for (let k = 0; k < N2; k += m) {
|
|
388
|
+
for (let j = 0, grp = g++; j < m2; j++) {
|
|
389
|
+
const rootPos = invertButterflies ? dit ? N2 - grp : grp : j * stride;
|
|
390
|
+
const i0 = k + j;
|
|
391
|
+
const i1 = k + j + m2;
|
|
392
|
+
const omega = roots[rootPos];
|
|
393
|
+
const b = values[i1];
|
|
394
|
+
const a = values[i0];
|
|
395
|
+
if (isDit) {
|
|
396
|
+
const t = F2.mul(b, omega);
|
|
397
|
+
values[i0] = F2.add(a, t);
|
|
398
|
+
values[i1] = F2.sub(a, t);
|
|
399
|
+
} else if (invertButterflies) {
|
|
400
|
+
values[i0] = F2.add(b, a);
|
|
401
|
+
values[i1] = F2.mul(F2.sub(b, a), omega);
|
|
402
|
+
} else {
|
|
403
|
+
values[i0] = F2.add(a, b);
|
|
404
|
+
values[i1] = F2.mul(F2.sub(a, b), omega);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
if (!dit && brp)
|
|
410
|
+
bitReversalInplace(values);
|
|
411
|
+
return values;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// ../../node_modules/.pnpm/@noble+post-quantum@0.6.0/node_modules/@noble/post-quantum/utils.js
|
|
418
|
+
function equalBytes(a, b) {
|
|
419
|
+
if (a.length !== b.length)
|
|
420
|
+
return false;
|
|
421
|
+
let diff = 0;
|
|
422
|
+
for (let i = 0; i < a.length; i++)
|
|
423
|
+
diff |= a[i] ^ b[i];
|
|
424
|
+
return diff === 0;
|
|
425
|
+
}
|
|
426
|
+
function validateOpts(opts) {
|
|
427
|
+
if (Object.prototype.toString.call(opts) !== "[object Object]")
|
|
428
|
+
throw new TypeError("expected valid options object");
|
|
429
|
+
}
|
|
430
|
+
function validateVerOpts(opts) {
|
|
431
|
+
validateOpts(opts);
|
|
432
|
+
if (opts.context !== void 0)
|
|
433
|
+
abytes(opts.context, void 0, "opts.context");
|
|
434
|
+
}
|
|
435
|
+
function validateSigOpts(opts) {
|
|
436
|
+
validateVerOpts(opts);
|
|
437
|
+
if (opts.extraEntropy !== false && opts.extraEntropy !== void 0)
|
|
438
|
+
abytes(opts.extraEntropy, void 0, "opts.extraEntropy");
|
|
439
|
+
}
|
|
440
|
+
function splitCoder(label, ...lengths) {
|
|
441
|
+
const getLength = (c) => typeof c === "number" ? c : c.bytesLen;
|
|
442
|
+
const bytesLen = lengths.reduce((sum, a) => sum + getLength(a), 0);
|
|
443
|
+
return {
|
|
444
|
+
bytesLen,
|
|
445
|
+
encode: (bufs) => {
|
|
446
|
+
const res = new Uint8Array(bytesLen);
|
|
447
|
+
for (let i = 0, pos = 0; i < lengths.length; i++) {
|
|
448
|
+
const c = lengths[i];
|
|
449
|
+
const l = getLength(c);
|
|
450
|
+
const b = typeof c === "number" ? bufs[i] : c.encode(bufs[i]);
|
|
451
|
+
abytes(b, l, label);
|
|
452
|
+
res.set(b, pos);
|
|
453
|
+
if (typeof c !== "number")
|
|
454
|
+
b.fill(0);
|
|
455
|
+
pos += l;
|
|
456
|
+
}
|
|
457
|
+
return res;
|
|
458
|
+
},
|
|
459
|
+
decode: (buf) => {
|
|
460
|
+
abytes(buf, bytesLen, label);
|
|
461
|
+
const res = [];
|
|
462
|
+
for (const c of lengths) {
|
|
463
|
+
const l = getLength(c);
|
|
464
|
+
const b = buf.subarray(0, l);
|
|
465
|
+
res.push(typeof c === "number" ? b : c.decode(b));
|
|
466
|
+
buf = buf.subarray(l);
|
|
467
|
+
}
|
|
468
|
+
return res;
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function vecCoder(c, vecLen) {
|
|
473
|
+
const bytesLen = vecLen * c.bytesLen;
|
|
474
|
+
return {
|
|
475
|
+
bytesLen,
|
|
476
|
+
encode: (u) => {
|
|
477
|
+
if (u.length !== vecLen)
|
|
478
|
+
throw new RangeError(`vecCoder.encode: wrong length=${u.length}. Expected: ${vecLen}`);
|
|
479
|
+
const res = new Uint8Array(bytesLen);
|
|
480
|
+
for (let i = 0, pos = 0; i < u.length; i++) {
|
|
481
|
+
const b = c.encode(u[i]);
|
|
482
|
+
res.set(b, pos);
|
|
483
|
+
b.fill(0);
|
|
484
|
+
pos += b.length;
|
|
485
|
+
}
|
|
486
|
+
return res;
|
|
487
|
+
},
|
|
488
|
+
decode: (a) => {
|
|
489
|
+
abytes(a, bytesLen);
|
|
490
|
+
const r = [];
|
|
491
|
+
for (let i = 0; i < a.length; i += c.bytesLen)
|
|
492
|
+
r.push(c.decode(a.subarray(i, i + c.bytesLen)));
|
|
493
|
+
return r;
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
function cleanBytes(...list) {
|
|
498
|
+
for (const t of list) {
|
|
499
|
+
if (Array.isArray(t))
|
|
500
|
+
for (const b of t)
|
|
501
|
+
b.fill(0);
|
|
502
|
+
else
|
|
503
|
+
t.fill(0);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
function getMask(bits) {
|
|
507
|
+
if (!Number.isSafeInteger(bits) || bits < 0 || bits > 32)
|
|
508
|
+
throw new RangeError(`expected bits in [0..32], got ${bits}`);
|
|
509
|
+
return bits === 32 ? 4294967295 : ~(-1 << bits) >>> 0;
|
|
510
|
+
}
|
|
511
|
+
function getMessage(msg, ctx = EMPTY) {
|
|
512
|
+
abytes(msg);
|
|
513
|
+
abytes(ctx);
|
|
514
|
+
if (ctx.length > 255)
|
|
515
|
+
throw new RangeError("context should be 255 bytes or less");
|
|
516
|
+
return concatBytes(new Uint8Array([0, ctx.length]), ctx, msg);
|
|
517
|
+
}
|
|
518
|
+
function checkHash(hash, requiredStrength = 0) {
|
|
519
|
+
if (!hash.oid || !equalBytes(hash.oid.subarray(0, 10), oidNistP))
|
|
520
|
+
throw new Error("hash.oid is invalid: expected NIST hash");
|
|
521
|
+
const collisionResistance = hash.outputLen * 8 / 2;
|
|
522
|
+
if (requiredStrength > collisionResistance) {
|
|
523
|
+
throw new Error("Pre-hash security strength too low: " + collisionResistance + ", required: " + requiredStrength);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function getMessagePrehash(hash, msg, ctx = EMPTY) {
|
|
527
|
+
abytes(msg);
|
|
528
|
+
abytes(ctx);
|
|
529
|
+
if (ctx.length > 255)
|
|
530
|
+
throw new RangeError("context should be 255 bytes or less");
|
|
531
|
+
const hashed = hash(msg);
|
|
532
|
+
return concatBytes(new Uint8Array([1, ctx.length]), ctx, hash.oid, hashed);
|
|
533
|
+
}
|
|
534
|
+
var abytesDoc, randomBytes2, EMPTY, oidNistP;
|
|
535
|
+
var init_utils3 = chunk3SAK5KFL_cjs.__esm({
|
|
536
|
+
"../../node_modules/.pnpm/@noble+post-quantum@0.6.0/node_modules/@noble/post-quantum/utils.js"() {
|
|
537
|
+
init_utils();
|
|
538
|
+
abytesDoc = abytes;
|
|
539
|
+
randomBytes2 = randomBytes;
|
|
540
|
+
EMPTY = /* @__PURE__ */ Uint8Array.of();
|
|
541
|
+
oidNistP = /* @__PURE__ */ Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2]);
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
// ../../node_modules/.pnpm/@noble+post-quantum@0.6.0/node_modules/@noble/post-quantum/_crystals.js
|
|
546
|
+
var genCrystals, createXofShake, XOF128, XOF256;
|
|
547
|
+
var init_crystals = chunk3SAK5KFL_cjs.__esm({
|
|
548
|
+
"../../node_modules/.pnpm/@noble+post-quantum@0.6.0/node_modules/@noble/post-quantum/_crystals.js"() {
|
|
549
|
+
init_fft();
|
|
550
|
+
init_sha3();
|
|
551
|
+
init_utils3();
|
|
552
|
+
genCrystals = (opts) => {
|
|
553
|
+
const { newPoly: newPoly2, N: N2, Q: Q2, F: F2, ROOT_OF_UNITY: ROOT_OF_UNITY2, brvBits, isKyber } = opts;
|
|
554
|
+
const mod = (a, modulo = Q2) => {
|
|
555
|
+
const result = a % modulo | 0;
|
|
556
|
+
return (result >= 0 ? result | 0 : modulo + result | 0) | 0;
|
|
557
|
+
};
|
|
558
|
+
const smod = (a, modulo = Q2) => {
|
|
559
|
+
const r = mod(a, modulo) | 0;
|
|
560
|
+
return (r > modulo >> 1 ? r - modulo | 0 : r) | 0;
|
|
561
|
+
};
|
|
562
|
+
function getZettas() {
|
|
563
|
+
const out = newPoly2(N2);
|
|
564
|
+
for (let i = 0; i < N2; i++) {
|
|
565
|
+
const b = reverseBits(i, brvBits);
|
|
566
|
+
const p = BigInt(ROOT_OF_UNITY2) ** BigInt(b) % BigInt(Q2);
|
|
567
|
+
out[i] = Number(p) | 0;
|
|
568
|
+
}
|
|
569
|
+
return out;
|
|
570
|
+
}
|
|
571
|
+
const nttZetas = getZettas();
|
|
572
|
+
const field = {
|
|
573
|
+
add: (a, b) => mod((a | 0) + (b | 0)) | 0,
|
|
574
|
+
sub: (a, b) => mod((a | 0) - (b | 0)) | 0,
|
|
575
|
+
mul: (a, b) => mod((a | 0) * (b | 0)) | 0,
|
|
576
|
+
inv: (_a) => {
|
|
577
|
+
throw new Error("not implemented");
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
const nttOpts = {
|
|
581
|
+
N: N2,
|
|
582
|
+
roots: nttZetas,
|
|
583
|
+
invertButterflies: true,
|
|
584
|
+
skipStages: isKyber ? 1 : 0,
|
|
585
|
+
brp: false
|
|
586
|
+
};
|
|
587
|
+
const dif = FFTCore(field, { dit: false, ...nttOpts });
|
|
588
|
+
const dit = FFTCore(field, { dit: true, ...nttOpts });
|
|
589
|
+
const NTT = {
|
|
590
|
+
encode: (r) => {
|
|
591
|
+
return dif(r);
|
|
592
|
+
},
|
|
593
|
+
decode: (r) => {
|
|
594
|
+
dit(r);
|
|
595
|
+
for (let i = 0; i < r.length; i++)
|
|
596
|
+
r[i] = mod(F2 * r[i]);
|
|
597
|
+
return r;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
const bitsCoder = (d, c) => {
|
|
601
|
+
const mask = getMask(d);
|
|
602
|
+
const bytesLen = d * (N2 / 8);
|
|
603
|
+
return {
|
|
604
|
+
bytesLen,
|
|
605
|
+
encode: (poly) => {
|
|
606
|
+
const r = new Uint8Array(bytesLen);
|
|
607
|
+
for (let i = 0, buf = 0, bufLen = 0, pos = 0; i < poly.length; i++) {
|
|
608
|
+
buf |= (c.encode(poly[i]) & mask) << bufLen;
|
|
609
|
+
bufLen += d;
|
|
610
|
+
for (; bufLen >= 8; bufLen -= 8, buf >>= 8)
|
|
611
|
+
r[pos++] = buf & getMask(bufLen);
|
|
612
|
+
}
|
|
613
|
+
return r;
|
|
614
|
+
},
|
|
615
|
+
decode: (bytes) => {
|
|
616
|
+
const r = newPoly2(N2);
|
|
617
|
+
for (let i = 0, buf = 0, bufLen = 0, pos = 0; i < bytes.length; i++) {
|
|
618
|
+
buf |= bytes[i] << bufLen;
|
|
619
|
+
bufLen += 8;
|
|
620
|
+
for (; bufLen >= d; bufLen -= d, buf >>= d)
|
|
621
|
+
r[pos++] = c.decode(buf & mask);
|
|
622
|
+
}
|
|
623
|
+
return r;
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
};
|
|
627
|
+
return { mod, smod, nttZetas, NTT, bitsCoder };
|
|
628
|
+
};
|
|
629
|
+
createXofShake = (shake) => (seed, blockLen) => {
|
|
630
|
+
if (!blockLen)
|
|
631
|
+
blockLen = shake.blockLen;
|
|
632
|
+
const _seed = new Uint8Array(seed.length + 2);
|
|
633
|
+
_seed.set(seed);
|
|
634
|
+
const seedLen = seed.length;
|
|
635
|
+
const buf = new Uint8Array(blockLen);
|
|
636
|
+
let h = shake.create({});
|
|
637
|
+
let calls = 0;
|
|
638
|
+
let xofs = 0;
|
|
639
|
+
return {
|
|
640
|
+
stats: () => ({ calls, xofs }),
|
|
641
|
+
get: (x, y) => {
|
|
642
|
+
_seed[seedLen + 0] = x;
|
|
643
|
+
_seed[seedLen + 1] = y;
|
|
644
|
+
h.destroy();
|
|
645
|
+
h = shake.create({}).update(_seed);
|
|
646
|
+
calls++;
|
|
647
|
+
return () => {
|
|
648
|
+
xofs++;
|
|
649
|
+
return h.xofInto(buf);
|
|
650
|
+
};
|
|
651
|
+
},
|
|
652
|
+
clean: () => {
|
|
653
|
+
h.destroy();
|
|
654
|
+
cleanBytes(buf, _seed);
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
};
|
|
658
|
+
XOF128 = /* @__PURE__ */ createXofShake(shake128);
|
|
659
|
+
XOF256 = /* @__PURE__ */ createXofShake(shake256);
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
|
|
663
|
+
// ../../node_modules/.pnpm/@noble+post-quantum@0.6.0/node_modules/@noble/post-quantum/ml-dsa.js
|
|
664
|
+
function validateInternalOpts(opts) {
|
|
665
|
+
validateOpts(opts);
|
|
666
|
+
if (opts.externalMu !== void 0)
|
|
667
|
+
abool(opts.externalMu, "opts.externalMu");
|
|
668
|
+
}
|
|
669
|
+
function RejNTTPoly(xof) {
|
|
670
|
+
const r = newPoly(N);
|
|
671
|
+
for (let j = 0; j < N; ) {
|
|
672
|
+
const b = xof();
|
|
673
|
+
if (b.length % 3)
|
|
674
|
+
throw new Error("RejNTTPoly: unaligned block");
|
|
675
|
+
for (let i = 0; j < N && i <= b.length - 3; i += 3) {
|
|
676
|
+
const t = (b[i + 0] | b[i + 1] << 8 | b[i + 2] << 16) & 8388607;
|
|
677
|
+
if (t < Q)
|
|
678
|
+
r[j++] = t;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
return r;
|
|
682
|
+
}
|
|
683
|
+
function getDilithium(opts) {
|
|
684
|
+
const { K, L, GAMMA1, GAMMA2, TAU, ETA, OMEGA } = opts;
|
|
685
|
+
const { CRH_BYTES, TR_BYTES, C_TILDE_BYTES, XOF128: XOF1282, XOF256: XOF2562, securityLevel } = opts;
|
|
686
|
+
if (![2, 4].includes(ETA))
|
|
687
|
+
throw new Error("Wrong ETA");
|
|
688
|
+
if (![1 << 17, 1 << 19].includes(GAMMA1))
|
|
689
|
+
throw new Error("Wrong GAMMA1");
|
|
690
|
+
if (![GAMMA2_1, GAMMA2_2].includes(GAMMA2))
|
|
691
|
+
throw new Error("Wrong GAMMA2");
|
|
692
|
+
const BETA = TAU * ETA;
|
|
693
|
+
const decompose = (r) => {
|
|
694
|
+
const rPlus = crystals.mod(r);
|
|
695
|
+
const r0 = crystals.smod(rPlus, 2 * GAMMA2) | 0;
|
|
696
|
+
if (rPlus - r0 === Q - 1)
|
|
697
|
+
return { r1: 0 | 0, r0: r0 - 1 | 0 };
|
|
698
|
+
const r1 = Math.floor((rPlus - r0) / (2 * GAMMA2)) | 0;
|
|
699
|
+
return { r1, r0 };
|
|
700
|
+
};
|
|
701
|
+
const HighBits = (r) => decompose(r).r1;
|
|
702
|
+
const LowBits = (r) => decompose(r).r0;
|
|
703
|
+
const MakeHint = (z, r) => {
|
|
704
|
+
const res0 = z <= GAMMA2 || z > Q - GAMMA2 || z === Q - GAMMA2 && r === 0 ? 0 : 1;
|
|
705
|
+
return res0;
|
|
706
|
+
};
|
|
707
|
+
const UseHint = (h, r) => {
|
|
708
|
+
const m = Math.floor((Q - 1) / (2 * GAMMA2));
|
|
709
|
+
const { r1, r0 } = decompose(r);
|
|
710
|
+
if (h === 1)
|
|
711
|
+
return r0 > 0 ? crystals.mod(r1 + 1, m) | 0 : crystals.mod(r1 - 1, m) | 0;
|
|
712
|
+
return r1 | 0;
|
|
713
|
+
};
|
|
714
|
+
const Power2Round = (r) => {
|
|
715
|
+
const rPlus = crystals.mod(r);
|
|
716
|
+
const r0 = crystals.smod(rPlus, 2 ** D) | 0;
|
|
717
|
+
return { r1: Math.floor((rPlus - r0) / 2 ** D) | 0, r0 };
|
|
718
|
+
};
|
|
719
|
+
const hintCoder = {
|
|
720
|
+
bytesLen: OMEGA + K,
|
|
721
|
+
encode: (h) => {
|
|
722
|
+
if (h === false)
|
|
723
|
+
throw new Error("hint.encode: hint is false");
|
|
724
|
+
const res = new Uint8Array(OMEGA + K);
|
|
725
|
+
for (let i = 0, k = 0; i < K; i++) {
|
|
726
|
+
for (let j = 0; j < N; j++)
|
|
727
|
+
if (h[i][j] !== 0)
|
|
728
|
+
res[k++] = j;
|
|
729
|
+
res[OMEGA + i] = k;
|
|
730
|
+
}
|
|
731
|
+
return res;
|
|
732
|
+
},
|
|
733
|
+
decode: (buf) => {
|
|
734
|
+
const h = [];
|
|
735
|
+
let k = 0;
|
|
736
|
+
for (let i = 0; i < K; i++) {
|
|
737
|
+
const hi = newPoly(N);
|
|
738
|
+
if (buf[OMEGA + i] < k || buf[OMEGA + i] > OMEGA)
|
|
739
|
+
return false;
|
|
740
|
+
for (let j = k; j < buf[OMEGA + i]; j++) {
|
|
741
|
+
if (j > k && buf[j] <= buf[j - 1])
|
|
742
|
+
return false;
|
|
743
|
+
hi[buf[j]] = 1;
|
|
744
|
+
}
|
|
745
|
+
k = buf[OMEGA + i];
|
|
746
|
+
h.push(hi);
|
|
747
|
+
}
|
|
748
|
+
for (let j = k; j < OMEGA; j++)
|
|
749
|
+
if (buf[j] !== 0)
|
|
750
|
+
return false;
|
|
751
|
+
return h;
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
const ETACoder = polyCoder(ETA === 2 ? 3 : 4, (i) => ETA - i, (i) => {
|
|
755
|
+
if (!(-ETA <= i && i <= ETA))
|
|
756
|
+
throw new Error(`malformed key s1/s3 ${i} outside of ETA range [${-ETA}, ${ETA}]`);
|
|
757
|
+
return i;
|
|
758
|
+
});
|
|
759
|
+
const T0Coder = polyCoder(13, (i) => (1 << D - 1) - i);
|
|
760
|
+
const T1Coder = polyCoder(10);
|
|
761
|
+
const ZCoder = polyCoder(GAMMA1 === 1 << 17 ? 18 : 20, (i) => crystals.smod(GAMMA1 - i));
|
|
762
|
+
const W1Coder = polyCoder(GAMMA2 === GAMMA2_1 ? 6 : 4);
|
|
763
|
+
const W1Vec = vecCoder(W1Coder, K);
|
|
764
|
+
const publicCoder = splitCoder("publicKey", 32, vecCoder(T1Coder, K));
|
|
765
|
+
const secretCoder = splitCoder("secretKey", 32, 32, TR_BYTES, vecCoder(ETACoder, L), vecCoder(ETACoder, K), vecCoder(T0Coder, K));
|
|
766
|
+
const sigCoder = splitCoder("signature", C_TILDE_BYTES, vecCoder(ZCoder, L), hintCoder);
|
|
767
|
+
const CoefFromHalfByte = ETA === 2 ? (n) => n < 15 ? 2 - n % 5 : false : (n) => n < 9 ? 4 - n : false;
|
|
768
|
+
function RejBoundedPoly(xof) {
|
|
769
|
+
const r = newPoly(N);
|
|
770
|
+
for (let j = 0; j < N; ) {
|
|
771
|
+
const b = xof();
|
|
772
|
+
for (let i = 0; j < N && i < b.length; i += 1) {
|
|
773
|
+
const d1 = CoefFromHalfByte(b[i] & 15);
|
|
774
|
+
const d2 = CoefFromHalfByte(b[i] >> 4 & 15);
|
|
775
|
+
if (d1 !== false)
|
|
776
|
+
r[j++] = d1;
|
|
777
|
+
if (j < N && d2 !== false)
|
|
778
|
+
r[j++] = d2;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
return r;
|
|
782
|
+
}
|
|
783
|
+
const SampleInBall = (seed) => {
|
|
784
|
+
const pre = newPoly(N);
|
|
785
|
+
const s = shake256.create({}).update(seed);
|
|
786
|
+
const buf = new Uint8Array(shake256.blockLen);
|
|
787
|
+
s.xofInto(buf);
|
|
788
|
+
const masks = buf.slice(0, 8);
|
|
789
|
+
for (let i = N - TAU, pos = 8, maskPos = 0, maskBit = 0; i < N; i++) {
|
|
790
|
+
let b = i + 1;
|
|
791
|
+
for (; b > i; ) {
|
|
792
|
+
b = buf[pos++];
|
|
793
|
+
if (pos < shake256.blockLen)
|
|
794
|
+
continue;
|
|
795
|
+
s.xofInto(buf);
|
|
796
|
+
pos = 0;
|
|
797
|
+
}
|
|
798
|
+
pre[i] = pre[b];
|
|
799
|
+
pre[b] = 1 - ((masks[maskPos] >> maskBit++ & 1) << 1);
|
|
800
|
+
if (maskBit >= 8) {
|
|
801
|
+
maskPos++;
|
|
802
|
+
maskBit = 0;
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
return pre;
|
|
806
|
+
};
|
|
807
|
+
const polyPowerRound = (p) => {
|
|
808
|
+
const res0 = newPoly(N);
|
|
809
|
+
const res1 = newPoly(N);
|
|
810
|
+
for (let i = 0; i < p.length; i++) {
|
|
811
|
+
const { r0, r1 } = Power2Round(p[i]);
|
|
812
|
+
res0[i] = r0;
|
|
813
|
+
res1[i] = r1;
|
|
814
|
+
}
|
|
815
|
+
return { r0: res0, r1: res1 };
|
|
816
|
+
};
|
|
817
|
+
const polyUseHint = (u, h) => {
|
|
818
|
+
for (let i = 0; i < N; i++)
|
|
819
|
+
u[i] = UseHint(h[i], u[i]);
|
|
820
|
+
return u;
|
|
821
|
+
};
|
|
822
|
+
const polyMakeHint = (a, b) => {
|
|
823
|
+
const v = newPoly(N);
|
|
824
|
+
let cnt = 0;
|
|
825
|
+
for (let i = 0; i < N; i++) {
|
|
826
|
+
const h = MakeHint(a[i], b[i]);
|
|
827
|
+
v[i] = h;
|
|
828
|
+
cnt += h;
|
|
829
|
+
}
|
|
830
|
+
return { v, cnt };
|
|
831
|
+
};
|
|
832
|
+
const signRandBytes = 32;
|
|
833
|
+
const seedCoder = splitCoder("seed", 32, 64, 32);
|
|
834
|
+
const internal = {
|
|
835
|
+
info: { type: "internal-ml-dsa" },
|
|
836
|
+
lengths: {
|
|
837
|
+
secretKey: secretCoder.bytesLen,
|
|
838
|
+
publicKey: publicCoder.bytesLen,
|
|
839
|
+
seed: 32,
|
|
840
|
+
signature: sigCoder.bytesLen,
|
|
841
|
+
signRand: signRandBytes
|
|
842
|
+
},
|
|
843
|
+
keygen: (seed) => {
|
|
844
|
+
const seedDst = new Uint8Array(32 + 2);
|
|
845
|
+
const randSeed = seed === void 0;
|
|
846
|
+
if (randSeed)
|
|
847
|
+
seed = randomBytes2(32);
|
|
848
|
+
abytesDoc(seed, 32, "seed");
|
|
849
|
+
seedDst.set(seed);
|
|
850
|
+
if (randSeed)
|
|
851
|
+
cleanBytes(seed);
|
|
852
|
+
seedDst[32] = K;
|
|
853
|
+
seedDst[33] = L;
|
|
854
|
+
const [rho, rhoPrime, K_] = seedCoder.decode(shake256(seedDst, { dkLen: seedCoder.bytesLen }));
|
|
855
|
+
const xofPrime = XOF2562(rhoPrime);
|
|
856
|
+
const s1 = [];
|
|
857
|
+
for (let i = 0; i < L; i++)
|
|
858
|
+
s1.push(RejBoundedPoly(xofPrime.get(i & 255, i >> 8 & 255)));
|
|
859
|
+
const s2 = [];
|
|
860
|
+
for (let i = L; i < L + K; i++)
|
|
861
|
+
s2.push(RejBoundedPoly(xofPrime.get(i & 255, i >> 8 & 255)));
|
|
862
|
+
const s1Hat = s1.map((i) => crystals.NTT.encode(i.slice()));
|
|
863
|
+
const t0 = [];
|
|
864
|
+
const t1 = [];
|
|
865
|
+
const xof = XOF1282(rho);
|
|
866
|
+
const t = newPoly(N);
|
|
867
|
+
for (let i = 0; i < K; i++) {
|
|
868
|
+
cleanBytes(t);
|
|
869
|
+
for (let j = 0; j < L; j++) {
|
|
870
|
+
const aij = RejNTTPoly(xof.get(j, i));
|
|
871
|
+
polyAdd(t, MultiplyNTTs(aij, s1Hat[j]));
|
|
872
|
+
}
|
|
873
|
+
crystals.NTT.decode(t);
|
|
874
|
+
const { r0, r1 } = polyPowerRound(polyAdd(t, s2[i]));
|
|
875
|
+
t0.push(r0);
|
|
876
|
+
t1.push(r1);
|
|
877
|
+
}
|
|
878
|
+
const publicKey = publicCoder.encode([rho, t1]);
|
|
879
|
+
const tr = shake256(publicKey, { dkLen: TR_BYTES });
|
|
880
|
+
const secretKey = secretCoder.encode([rho, K_, tr, s1, s2, t0]);
|
|
881
|
+
xof.clean();
|
|
882
|
+
xofPrime.clean();
|
|
883
|
+
cleanBytes(rho, rhoPrime, K_, s1, s2, s1Hat, t, t0, t1, tr, seedDst);
|
|
884
|
+
return { publicKey, secretKey };
|
|
885
|
+
},
|
|
886
|
+
getPublicKey: (secretKey) => {
|
|
887
|
+
const [rho, _K, _tr, s1, s2, _t0] = secretCoder.decode(secretKey);
|
|
888
|
+
const xof = XOF1282(rho);
|
|
889
|
+
const s1Hat = s1.map((p) => crystals.NTT.encode(p.slice()));
|
|
890
|
+
const t1 = [];
|
|
891
|
+
const tmp = newPoly(N);
|
|
892
|
+
for (let i = 0; i < K; i++) {
|
|
893
|
+
tmp.fill(0);
|
|
894
|
+
for (let j = 0; j < L; j++) {
|
|
895
|
+
const aij = RejNTTPoly(xof.get(j, i));
|
|
896
|
+
polyAdd(tmp, MultiplyNTTs(aij, s1Hat[j]));
|
|
897
|
+
}
|
|
898
|
+
crystals.NTT.decode(tmp);
|
|
899
|
+
polyAdd(tmp, s2[i]);
|
|
900
|
+
const { r1 } = polyPowerRound(tmp);
|
|
901
|
+
t1.push(r1);
|
|
902
|
+
}
|
|
903
|
+
xof.clean();
|
|
904
|
+
cleanBytes(tmp, s1Hat, _t0, s1, s2);
|
|
905
|
+
return publicCoder.encode([rho, t1]);
|
|
906
|
+
},
|
|
907
|
+
// NOTE: random is optional.
|
|
908
|
+
sign: (msg, secretKey, opts2 = {}) => {
|
|
909
|
+
validateSigOpts(opts2);
|
|
910
|
+
validateInternalOpts(opts2);
|
|
911
|
+
let { extraEntropy: random, externalMu = false } = opts2;
|
|
912
|
+
const [rho, _K, tr, s1, s2, t0] = secretCoder.decode(secretKey);
|
|
913
|
+
const A = [];
|
|
914
|
+
const xof = XOF1282(rho);
|
|
915
|
+
for (let i = 0; i < K; i++) {
|
|
916
|
+
const pv = [];
|
|
917
|
+
for (let j = 0; j < L; j++)
|
|
918
|
+
pv.push(RejNTTPoly(xof.get(j, i)));
|
|
919
|
+
A.push(pv);
|
|
920
|
+
}
|
|
921
|
+
xof.clean();
|
|
922
|
+
for (let i = 0; i < L; i++)
|
|
923
|
+
crystals.NTT.encode(s1[i]);
|
|
924
|
+
for (let i = 0; i < K; i++) {
|
|
925
|
+
crystals.NTT.encode(s2[i]);
|
|
926
|
+
crystals.NTT.encode(t0[i]);
|
|
927
|
+
}
|
|
928
|
+
const mu = externalMu ? msg : (
|
|
929
|
+
// 6: µ ← H(tr||M, 512)
|
|
930
|
+
// ▷ Compute message representative µ
|
|
931
|
+
shake256.create({ dkLen: CRH_BYTES }).update(tr).update(msg).digest()
|
|
932
|
+
);
|
|
933
|
+
const rnd = random === false ? new Uint8Array(32) : random === void 0 ? randomBytes2(signRandBytes) : random;
|
|
934
|
+
abytesDoc(rnd, 32, "extraEntropy");
|
|
935
|
+
const rhoprime = shake256.create({ dkLen: CRH_BYTES }).update(_K).update(rnd).update(mu).digest();
|
|
936
|
+
abytesDoc(rhoprime, CRH_BYTES);
|
|
937
|
+
const x256 = XOF2562(rhoprime, ZCoder.bytesLen);
|
|
938
|
+
main_loop: for (let kappa = 0; ; ) {
|
|
939
|
+
const y = [];
|
|
940
|
+
for (let i = 0; i < L; i++, kappa++)
|
|
941
|
+
y.push(ZCoder.decode(x256.get(kappa & 255, kappa >> 8)()));
|
|
942
|
+
const z = y.map((i) => crystals.NTT.encode(i.slice()));
|
|
943
|
+
const w = [];
|
|
944
|
+
for (let i = 0; i < K; i++) {
|
|
945
|
+
const wi = newPoly(N);
|
|
946
|
+
for (let j = 0; j < L; j++)
|
|
947
|
+
polyAdd(wi, MultiplyNTTs(A[i][j], z[j]));
|
|
948
|
+
crystals.NTT.decode(wi);
|
|
949
|
+
w.push(wi);
|
|
950
|
+
}
|
|
951
|
+
const w1 = w.map((j) => j.map(HighBits));
|
|
952
|
+
const cTilde = shake256.create({ dkLen: C_TILDE_BYTES }).update(mu).update(W1Vec.encode(w1)).digest();
|
|
953
|
+
const cHat = crystals.NTT.encode(SampleInBall(cTilde));
|
|
954
|
+
const cs1 = s1.map((i) => MultiplyNTTs(i, cHat));
|
|
955
|
+
for (let i = 0; i < L; i++) {
|
|
956
|
+
polyAdd(crystals.NTT.decode(cs1[i]), y[i]);
|
|
957
|
+
if (polyChknorm(cs1[i], GAMMA1 - BETA))
|
|
958
|
+
continue main_loop;
|
|
959
|
+
}
|
|
960
|
+
let cnt = 0;
|
|
961
|
+
const h = [];
|
|
962
|
+
for (let i = 0; i < K; i++) {
|
|
963
|
+
const cs2 = crystals.NTT.decode(MultiplyNTTs(s2[i], cHat));
|
|
964
|
+
const r0 = polySub(w[i], cs2).map(LowBits);
|
|
965
|
+
if (polyChknorm(r0, GAMMA2 - BETA))
|
|
966
|
+
continue main_loop;
|
|
967
|
+
const ct0 = crystals.NTT.decode(MultiplyNTTs(t0[i], cHat));
|
|
968
|
+
if (polyChknorm(ct0, GAMMA2))
|
|
969
|
+
continue main_loop;
|
|
970
|
+
polyAdd(r0, ct0);
|
|
971
|
+
const hint = polyMakeHint(r0, w1[i]);
|
|
972
|
+
h.push(hint.v);
|
|
973
|
+
cnt += hint.cnt;
|
|
974
|
+
}
|
|
975
|
+
if (cnt > OMEGA)
|
|
976
|
+
continue;
|
|
977
|
+
x256.clean();
|
|
978
|
+
const res = sigCoder.encode([cTilde, cs1, h]);
|
|
979
|
+
cleanBytes(cTilde, cs1, h, cHat, w1, w, z, y, rhoprime, s1, s2, t0, ...A);
|
|
980
|
+
if (!externalMu)
|
|
981
|
+
cleanBytes(mu);
|
|
982
|
+
return res;
|
|
983
|
+
}
|
|
984
|
+
throw new Error("Unreachable code path reached, report this error");
|
|
985
|
+
},
|
|
986
|
+
verify: (sig, msg, publicKey, opts2 = {}) => {
|
|
987
|
+
validateInternalOpts(opts2);
|
|
988
|
+
const { externalMu = false } = opts2;
|
|
989
|
+
const [rho, t1] = publicCoder.decode(publicKey);
|
|
990
|
+
const tr = shake256(publicKey, { dkLen: TR_BYTES });
|
|
991
|
+
if (sig.length !== sigCoder.bytesLen)
|
|
992
|
+
return false;
|
|
993
|
+
const [cTilde, z, h] = sigCoder.decode(sig);
|
|
994
|
+
if (h === false)
|
|
995
|
+
return false;
|
|
996
|
+
for (let i = 0; i < L; i++)
|
|
997
|
+
if (polyChknorm(z[i], GAMMA1 - BETA))
|
|
998
|
+
return false;
|
|
999
|
+
const mu = externalMu ? msg : (
|
|
1000
|
+
// 7: µ ← H(tr||M, 512)
|
|
1001
|
+
shake256.create({ dkLen: CRH_BYTES }).update(tr).update(msg).digest()
|
|
1002
|
+
);
|
|
1003
|
+
const c = crystals.NTT.encode(SampleInBall(cTilde));
|
|
1004
|
+
const zNtt = z.map((i) => i.slice());
|
|
1005
|
+
for (let i = 0; i < L; i++)
|
|
1006
|
+
crystals.NTT.encode(zNtt[i]);
|
|
1007
|
+
const wTick1 = [];
|
|
1008
|
+
const xof = XOF1282(rho);
|
|
1009
|
+
for (let i = 0; i < K; i++) {
|
|
1010
|
+
const ct12d = MultiplyNTTs(crystals.NTT.encode(polyShiftl(t1[i])), c);
|
|
1011
|
+
const Az = newPoly(N);
|
|
1012
|
+
for (let j = 0; j < L; j++) {
|
|
1013
|
+
const aij = RejNTTPoly(xof.get(j, i));
|
|
1014
|
+
polyAdd(Az, MultiplyNTTs(aij, zNtt[j]));
|
|
1015
|
+
}
|
|
1016
|
+
const wApprox = crystals.NTT.decode(polySub(Az, ct12d));
|
|
1017
|
+
wTick1.push(polyUseHint(wApprox, h[i]));
|
|
1018
|
+
}
|
|
1019
|
+
xof.clean();
|
|
1020
|
+
const c2 = shake256.create({ dkLen: C_TILDE_BYTES }).update(mu).update(W1Vec.encode(wTick1)).digest();
|
|
1021
|
+
for (const t of h) {
|
|
1022
|
+
const sum = t.reduce((acc, i) => acc + i, 0);
|
|
1023
|
+
if (!(sum <= OMEGA))
|
|
1024
|
+
return false;
|
|
1025
|
+
}
|
|
1026
|
+
for (const t of z)
|
|
1027
|
+
if (polyChknorm(t, GAMMA1 - BETA))
|
|
1028
|
+
return false;
|
|
1029
|
+
return equalBytes(cTilde, c2);
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
return {
|
|
1033
|
+
info: { type: "ml-dsa" },
|
|
1034
|
+
internal,
|
|
1035
|
+
securityLevel,
|
|
1036
|
+
keygen: internal.keygen,
|
|
1037
|
+
lengths: internal.lengths,
|
|
1038
|
+
getPublicKey: internal.getPublicKey,
|
|
1039
|
+
sign: (msg, secretKey, opts2 = {}) => {
|
|
1040
|
+
validateSigOpts(opts2);
|
|
1041
|
+
const M = getMessage(msg, opts2.context);
|
|
1042
|
+
const res = internal.sign(M, secretKey, opts2);
|
|
1043
|
+
cleanBytes(M);
|
|
1044
|
+
return res;
|
|
1045
|
+
},
|
|
1046
|
+
verify: (sig, msg, publicKey, opts2 = {}) => {
|
|
1047
|
+
validateVerOpts(opts2);
|
|
1048
|
+
return internal.verify(sig, getMessage(msg, opts2.context), publicKey);
|
|
1049
|
+
},
|
|
1050
|
+
prehash: (hash) => {
|
|
1051
|
+
checkHash(hash, securityLevel);
|
|
1052
|
+
return {
|
|
1053
|
+
info: { type: "hashml-dsa" },
|
|
1054
|
+
securityLevel,
|
|
1055
|
+
lengths: internal.lengths,
|
|
1056
|
+
keygen: internal.keygen,
|
|
1057
|
+
getPublicKey: internal.getPublicKey,
|
|
1058
|
+
sign: (msg, secretKey, opts2 = {}) => {
|
|
1059
|
+
validateSigOpts(opts2);
|
|
1060
|
+
const M = getMessagePrehash(hash, msg, opts2.context);
|
|
1061
|
+
const res = internal.sign(M, secretKey, opts2);
|
|
1062
|
+
cleanBytes(M);
|
|
1063
|
+
return res;
|
|
1064
|
+
},
|
|
1065
|
+
verify: (sig, msg, publicKey, opts2 = {}) => {
|
|
1066
|
+
validateVerOpts(opts2);
|
|
1067
|
+
return internal.verify(sig, getMessagePrehash(hash, msg, opts2.context), publicKey);
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
var N, Q, ROOT_OF_UNITY, F, D, GAMMA2_1, GAMMA2_2; exports.PARAMS = void 0; var newPoly, crystals, id, polyCoder, polyAdd, polySub, polyShiftl, polyChknorm, MultiplyNTTs; exports.ml_dsa44 = void 0; exports.ml_dsa65 = void 0; exports.ml_dsa87 = void 0;
|
|
1074
|
+
var init_ml_dsa = chunk3SAK5KFL_cjs.__esm({
|
|
1075
|
+
"../../node_modules/.pnpm/@noble+post-quantum@0.6.0/node_modules/@noble/post-quantum/ml-dsa.js"() {
|
|
1076
|
+
init_utils2();
|
|
1077
|
+
init_sha3();
|
|
1078
|
+
init_crystals();
|
|
1079
|
+
init_utils3();
|
|
1080
|
+
N = 256;
|
|
1081
|
+
Q = 8380417;
|
|
1082
|
+
ROOT_OF_UNITY = 1753;
|
|
1083
|
+
F = 8347681;
|
|
1084
|
+
D = 13;
|
|
1085
|
+
GAMMA2_1 = Math.floor((Q - 1) / 88) | 0;
|
|
1086
|
+
GAMMA2_2 = Math.floor((Q - 1) / 32) | 0;
|
|
1087
|
+
exports.PARAMS = /* @__PURE__ */ (() => ({
|
|
1088
|
+
2: { K: 4, L: 4, D, GAMMA1: 2 ** 17, GAMMA2: GAMMA2_1, TAU: 39, ETA: 2, OMEGA: 80 },
|
|
1089
|
+
3: { K: 6, L: 5, D, GAMMA1: 2 ** 19, GAMMA2: GAMMA2_2, TAU: 49, ETA: 4, OMEGA: 55 },
|
|
1090
|
+
5: { K: 8, L: 7, D, GAMMA1: 2 ** 19, GAMMA2: GAMMA2_2, TAU: 60, ETA: 2, OMEGA: 75 }
|
|
1091
|
+
}))();
|
|
1092
|
+
newPoly = (n) => new Int32Array(n);
|
|
1093
|
+
crystals = /* @__PURE__ */ genCrystals({
|
|
1094
|
+
N,
|
|
1095
|
+
Q,
|
|
1096
|
+
F,
|
|
1097
|
+
ROOT_OF_UNITY,
|
|
1098
|
+
newPoly,
|
|
1099
|
+
isKyber: false,
|
|
1100
|
+
brvBits: 8
|
|
1101
|
+
});
|
|
1102
|
+
id = (n) => n;
|
|
1103
|
+
polyCoder = (d, compress = id, verify = id) => crystals.bitsCoder(d, {
|
|
1104
|
+
encode: (i) => compress(verify(i)),
|
|
1105
|
+
decode: (i) => verify(compress(i))
|
|
1106
|
+
});
|
|
1107
|
+
polyAdd = (a, b) => {
|
|
1108
|
+
for (let i = 0; i < a.length; i++)
|
|
1109
|
+
a[i] = crystals.mod(a[i] + b[i]);
|
|
1110
|
+
return a;
|
|
1111
|
+
};
|
|
1112
|
+
polySub = (a, b) => {
|
|
1113
|
+
for (let i = 0; i < a.length; i++)
|
|
1114
|
+
a[i] = crystals.mod(a[i] - b[i]);
|
|
1115
|
+
return a;
|
|
1116
|
+
};
|
|
1117
|
+
polyShiftl = (p) => {
|
|
1118
|
+
for (let i = 0; i < N; i++)
|
|
1119
|
+
p[i] <<= D;
|
|
1120
|
+
return p;
|
|
1121
|
+
};
|
|
1122
|
+
polyChknorm = (p, B) => {
|
|
1123
|
+
for (let i = 0; i < N; i++)
|
|
1124
|
+
if (Math.abs(crystals.smod(p[i])) >= B)
|
|
1125
|
+
return true;
|
|
1126
|
+
return false;
|
|
1127
|
+
};
|
|
1128
|
+
MultiplyNTTs = (a, b) => {
|
|
1129
|
+
const c = newPoly(N);
|
|
1130
|
+
for (let i = 0; i < a.length; i++)
|
|
1131
|
+
c[i] = crystals.mod(a[i] * b[i]);
|
|
1132
|
+
return c;
|
|
1133
|
+
};
|
|
1134
|
+
exports.ml_dsa44 = /* @__PURE__ */ (() => getDilithium({
|
|
1135
|
+
...exports.PARAMS[2],
|
|
1136
|
+
CRH_BYTES: 64,
|
|
1137
|
+
TR_BYTES: 64,
|
|
1138
|
+
C_TILDE_BYTES: 32,
|
|
1139
|
+
XOF128,
|
|
1140
|
+
XOF256,
|
|
1141
|
+
securityLevel: 128
|
|
1142
|
+
}))();
|
|
1143
|
+
exports.ml_dsa65 = /* @__PURE__ */ (() => getDilithium({
|
|
1144
|
+
...exports.PARAMS[3],
|
|
1145
|
+
CRH_BYTES: 64,
|
|
1146
|
+
TR_BYTES: 64,
|
|
1147
|
+
C_TILDE_BYTES: 48,
|
|
1148
|
+
XOF128,
|
|
1149
|
+
XOF256,
|
|
1150
|
+
securityLevel: 192
|
|
1151
|
+
}))();
|
|
1152
|
+
exports.ml_dsa87 = /* @__PURE__ */ (() => getDilithium({
|
|
1153
|
+
...exports.PARAMS[5],
|
|
1154
|
+
CRH_BYTES: 64,
|
|
1155
|
+
TR_BYTES: 64,
|
|
1156
|
+
C_TILDE_BYTES: 64,
|
|
1157
|
+
XOF128,
|
|
1158
|
+
XOF256,
|
|
1159
|
+
securityLevel: 256
|
|
1160
|
+
}))();
|
|
1161
|
+
}
|
|
1162
|
+
});
|
|
1163
|
+
init_ml_dsa();
|
|
1164
|
+
/*! Bundled license information:
|
|
1165
|
+
|
|
1166
|
+
@noble/hashes/utils.js:
|
|
1167
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1168
|
+
|
|
1169
|
+
@noble/curves/utils.js:
|
|
1170
|
+
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
1171
|
+
|
|
1172
|
+
@noble/post-quantum/utils.js:
|
|
1173
|
+
@noble/post-quantum/_crystals.js:
|
|
1174
|
+
@noble/post-quantum/ml-dsa.js:
|
|
1175
|
+
(*! noble-post-quantum - MIT License (c) 2024 Paul Miller (paulmillr.com) *)
|
|
1176
|
+
*/
|
|
1177
|
+
//# sourceMappingURL=ml-dsa-PHCWUBPX.cjs.map
|
|
1178
|
+
//# sourceMappingURL=ml-dsa-PHCWUBPX.cjs.map
|