@lib-q/cb-kem 0.0.2 → 0.0.5

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/web/README.md CHANGED
@@ -1,322 +1,329 @@
1
- # lib-Q - Post-Quantum Cryptography Library
2
-
3
- A Rust cryptography workspace focused on **NIST-standardized post-quantum** key exchange and signatures, **SHA-3-family** hashes and XOFs, and a **transparent STARK**–based zero-knowledge stack. CI enforces `cargo check --workspace --exclude lib-q-examples --exclude lib-q-sca-test --target wasm32-unknown-unknown` (with the `getrandom` wasm_js cfg) so the **publishable library workspace** compiles for the WebAssembly target; npm bundles are produced for the `@lib-q/*` packages listed below (see [docs/npm-packages.md](docs/npm-packages.md)). For build modes, feature flags, and browser baselines, see [docs/wasm-compilation.md](docs/wasm-compilation.md).
4
-
5
- ## Mission
6
-
7
- lib-Q provides a coherent Rust API surface over NIST-track post-quantum primitives, SHA-3–family hashing, Saturnin AEAD, HPKE, and optional STARK-based proofs, with the goal of keeping advanced cryptography approachable without hiding residual implementation risk.
8
-
9
- ## Key features
10
-
11
- - **Post-quantum first**: Post-quantum KEMs and signatures with tiered symmetric options
12
- - **Standards-aligned**: PQC KEMs and signatures track NIST-standardized modules (e.g. FIPS 203/204/205/206, HQC, Classic McEliece–family CB-KEM); hashes and XOFs use the SHA-3 family; symmetric design centers on Saturnin; ZKPs use a transparent STARK stack (complementary to the NIST PQC algorithm set)
13
- - **Memory safe**: Built in Rust with zero-cost abstractions
14
- - **Cross-platform**: Native Rust + WASM compilation
15
- - **Intuitive API**: Clean, consistent interface designed for modern development
16
- - **Self-contained algorithms**: No external non-Rust tooling required for core use
17
- - **Three security tiers**: Ultra-secure, balanced, and performance-optimized options
18
- - **Modular design**: Use only what you need with individual crates and npm packages
19
-
20
- ## no_std, embedded, and WebAssembly
21
-
22
- - **Umbrella `lib-q` crate**: Disabling default features applies `#![no_std]` to this crate's own code, but some path dependencies are still declared with `std` enabled (for example unified signature support via `lib-q-sig`). The final artifact may still link the standard library. For a **true** `no_std` + `alloc` dependency tree, use the **workspace crates you need** (`lib-q-core`, `lib-q-kem`, `lib-q-ml-dsa`, etc.) with `--no-default-features` and each crate's `alloc` / algorithm features. Per-crate READMEs describe WASM and `no_std` where relevant (for example [lib-q-saturnin/README.md](lib-q-saturnin/README.md)).
23
-
24
- - **WASM and `getrandom`**: Match CI when compiling for `wasm32-unknown-unknown`: set `CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS` to `--cfg getrandom_backend="wasm_js" -C panic=abort` (see [.github/actions/wasm-build/action.yml](.github/actions/wasm-build/action.yml), [scripts/build-wasm.ps1](scripts/build-wasm.ps1), [scripts/security-check.ps1](scripts/security-check.ps1)).
25
-
26
- - **`lib-q-zkp`**: Ships a `cdylib` + `wasm` feature for `wasm-pack` / `@lib-q/zkp`; CI also `cargo check`s the ZKP stack on `wasm32-unknown-unknown`.
27
-
28
- ### Browser example
29
-
30
- The minimal browser demo in [`examples/wasm-browser-demo`](examples/wasm-browser-demo) exposes an ML-DSA-44 smoke API:
31
-
32
- ```javascript
33
- import init, { wasm_smoke_ml_dsa_sign_verify } from "./pkg/wasm_browser_demo.js";
34
-
35
- await init();
36
- const ok = await wasm_smoke_ml_dsa_sign_verify();
37
- console.log("ML-DSA wasm smoke:", ok);
38
- ```
39
-
40
- ## Package structure
41
-
42
- lib-Q is organized as a Rust workspace with individual crates and npm packages:
43
-
44
- ### Rust workspace crates
45
-
46
- Publishing to [crates.io](https://crates.io/) is driven by [`.github/workflows/cd.yml`](.github/workflows/cd.yml) in dependency order. The `examples` umbrella and `examples/wasm-browser-demo` are integration harnesses (`publish = false` where set); other members follow `[workspace].members` in [Cargo.toml](Cargo.toml). The workspace-wide WASM compile gate excludes those example crates and `lib-q-sca-test`.
47
-
48
- | Crate | Role |
49
- |-------|------|
50
- | **`lib-q`** | Umbrella library (feature-gated re-exports) |
51
- | **`lib-q-types`** | Shared type definitions |
52
- | **`lib-q-core`** | Core types, traits, provider surface, validation |
53
- | **`lib-q-keccak`** | Keccak-f / sponge building blocks |
54
- | **`lib-q-k12`** | KangarooTwelve (K12) |
55
- | **`lib-q-sha3`** | SHA-3 / SHAKE / cSHAKE core |
56
- | **`lib-q-keccak-digest`** | Digest adapter over Keccak |
57
- | **`lib-q-kem`** | KEM façade (ML-KEM, CB-KEM, HQC integration) |
58
- | **`lib-q-ml-kem`** | ML-KEM (FIPS 203) |
59
- | **`lib-q-ml-dsa`** | ML-DSA (FIPS 204) |
60
- | **`lib-q-ring`** | Negacyclic ring / NTT layer for ML-DSA |
61
- | **`lib-q-sca-test`** | Statistical side-channel harness (TVLA-style) |
62
- | **`lib-q-lattice-zkp`** | Module-lattice commitments / sigma research |
63
- | **`lib-q-ring-sig`** | Ring-style openings / DualRing pilots |
64
- | **`lib-q-prf`** | Legendre / Gold PRF building blocks |
65
- | **`lib-q-platform`** | Platform helpers |
66
- | **`lib-q-intrinsics`** | SIMD / intrinsics helpers |
67
- | **`lib-q-sig`** | Signature façade (ML-DSA, SLH-DSA) |
68
- | **`lib-q-hash`** | Hash façade (SHAKE, KMAC, TupleHash, etc.) |
69
- | **`lib-q-aead`** | AEAD façade (Saturnin, Romulus, duplex, tweak) |
70
- | **`lib-q-saturnin`** | Saturnin suite |
71
- | **`lib-q-duplex-aead`** | Duplex-sponge AEAD |
72
- | **`lib-q-tweak-aead`** | Tweakable CTR AEAD over Keccak |
73
- | **`lib-q-romulus`** | Romulus AEAD (Skinny-based) |
74
- | **`lib-q-hpke`** | HPKE (RFC 9180) |
75
- | **`lib-q-utils`** | Shared utilities |
76
- | **`lib-q-zkp`** | ZKP public API (STARK-backed) |
77
- | **`lib-q-fn-dsa`** | FN-DSA (FIPS 206) |
78
- | **`lib-q-slh-dsa`** | SLH-DSA (FIPS 205) |
79
- | **`lib-q-cb-kem`** | Classic McEliece–family CB-KEM |
80
- | **`lib-q-random`** | Randomness / entropy helpers |
81
- | **`lib-q-hqc`** | HQC KEM |
82
- | **`lib-q-hqc-traits`** | HQC shared traits (`lib-q-hqc/traits`) |
83
- | **`lib-q-stark`** | STARK prover stack (top-level) |
84
- | **`lib-q-stark-air`** | AIR definitions |
85
- | **`lib-q-stark-challenger`** | Fiat–Shamir challenger |
86
- | **`lib-q-stark-commit`** | Commitment layer |
87
- | **`lib-q-stark-dft`** | DFT / NTT for STARKs |
88
- | **`lib-q-stark-field`** | Field arithmetic |
89
- | **`lib-q-stark-field-testing`** | Field test helpers |
90
- | **`lib-q-stark-fri`** | FRI |
91
- | **`lib-q-stark-interpolation`** | Interpolation |
92
- | **`lib-q-stark-matrix`** | Matrix ops |
93
- | **`lib-q-stark-mds`** | MDS layer |
94
- | **`lib-q-stark-merkle`** | Merkle trees |
95
- | **`lib-q-stark-mersenne31`** | Mersenne-31 field |
96
- | **`lib-q-stark-monty31`** | Monty-31 field |
97
- | **`lib-q-stark-rayon`** | Optional Rayon parallelism |
98
- | **`lib-q-stark-symmetric`** | Symmetric primitives for STARKs |
99
- | **`lib-q-stark-util`** | STARK utilities |
100
- | **`lib-q-stark-shake256`** | SHAKE256 bindings |
101
- | **`lib-q-stark-shake128`** | SHAKE128 bindings |
102
- | **`lib-q-stark-sha3-256`** | SHA3-256 bindings |
103
- | **`lib-q-poseidon`** | Poseidon permutation |
104
- | **`lib-q-plonky-multilinear-util`** | Plonky3 multilinear utilities |
105
- | **`lib-q-plonky-keccak-air`** | Keccak AIR |
106
- | **`lib-q-plonky-lookup`** | Lookup argument support |
107
- | **`lib-q-plonky-uni-stark`** | Univariate STARK |
108
- | **`lib-q-plonky-batch-stark`** | Batch STARK |
109
- | **`lib-q-plonky`** | Plonky3-derived integration |
110
-
111
- ### npm packages (npmjs.com)
112
-
113
- These packages are built with `wasm-pack` in CD and correspond to stable JS entry points; other crates are **Rust-only** on crates.io but still participate in the workspace wasm compile gate.
114
-
115
- - **`@lib-q/core`** — Umbrella WASM bundle (all algorithms path used in CD)
116
- - **`@lib-q/ml-kem`** — ML-KEM (FIPS 203) only
117
- - **`@lib-q/kem`** — Post-quantum KEM façade
118
- - **`@lib-q/sig`** — Post-quantum signatures (ML-DSA path in CD)
119
- - **`@lib-q/fn-dsa`** — FN-DSA (FIPS 206)
120
- - **`@lib-q/hash`** — SHA-3–family hash façade
121
- - **`@lib-q/utils`** — Utilities
122
- - **`@lib-q/aead`** — Post-quantum AEAD (Saturnin, Romulus, duplex-sponge)
123
- - **`@lib-q/hpke`** — Post-quantum HPKE (RFC 9180)
124
- - **`@lib-q/zkp`** — ZKP / STARK proofs (high-level JSON API)
125
- - **`@lib-q/random`** — Secure random bytes (`getrandom` / wasm_js)
126
- - **`@lib-q/hqc`** — HQC KEM
127
- - **`@lib-q/slh-dsa`** — SLH-DSA (FIPS 205)
128
- - **`@lib-q/cb-kem`** — Classic McEliece CB-KEM (single compile-time parameter set per build)
129
- - **`@lib-q/ring-sig`** — Federation / DualRing-LB pilot bindings
130
- - **`@lib-q/prf`** — Legendre / Gold PRF pilots
131
-
132
- ## Installation
133
-
134
- ### Rust (Complete Library)
135
- ```bash
136
- cargo add lib-q
137
- ```
138
-
139
- ### Rust (Individual Crates)
140
- ```bash
141
- # For KEM operations only
142
- cargo add lib-q-kem
143
-
144
- # For signatures only
145
- cargo add lib-q-sig
146
-
147
- # For FN-DSA signatures only
148
- cargo add lib-q-fn-dsa
149
-
150
- # For hash functions only
151
- cargo add lib-q-hash
152
-
153
- # For utilities only
154
- cargo add lib-q-utils
155
- ```
156
-
157
- ### Node.js (Complete Library)
158
- ```bash
159
- npm install @lib-q/core
160
- ```
161
-
162
- ### Node.js (Individual Packages)
163
- ```bash
164
- # For ML-KEM only
165
- npm install @lib-q/ml-kem
166
-
167
- # For KEM operations only
168
- npm install @lib-q/kem
169
-
170
- # For signatures only
171
- npm install @lib-q/sig
172
-
173
- # For FN-DSA signatures only
174
- npm install @lib-q/fn-dsa
175
-
176
- # For hash functions only
177
- npm install @lib-q/hash
178
-
179
- # For utilities only
180
- npm install @lib-q/utils
181
-
182
- # AEAD, HPKE, ZKP, RNG, HQC, SLH-DSA, CB-KEM, ring-sig, PRF
183
- npm install @lib-q/aead @lib-q/hpke @lib-q/zkp @lib-q/random @lib-q/hqc @lib-q/slh-dsa @lib-q/cb-kem @lib-q/ring-sig @lib-q/prf
184
- ```
185
-
186
- ## Supported algorithms
187
-
188
- ### Key encapsulation mechanisms (KEMs)
189
- - **ML-KEM** (FIPS 203; security levels 1, 3, and 5)
190
- - **CB-KEM** (code-based KEM in the Classic McEliece family; five NIST parameter sets, selectable via crate features)
191
- - **HQC** (NIST-standardized code-based KEM; parameter sets HQC-128, HQC-192, and HQC-256, corresponding to levels 1, 3, and 5)
192
-
193
- ### Digital signatures
194
- - **ML-DSA** (FIPS 204; levels 1, 3, and 5)
195
- - **FN-DSA** (FIPS 206; levels 1 and 5)
196
- - **SLH-DSA** (FIPS 205; levels 1, 3, and 5)
197
-
198
- ### Hash functions
199
- - **SHAKE256**, **SHAKE128**, **cSHAKE256** (SHA-3 family; used across signatures, KDFs, and protocols)
200
- - Additional SHA-3–family APIs where exposed by `lib-q-hash` and related workspace crates (see crate documentation)
201
-
202
- ### Authenticated encryption
203
- - **Saturnin** (post-quantum symmetric suite: AEAD, block cipher, hash, and stream modes)
204
-
205
- ### Hybrid public-key encryption (HPKE)
206
- - **Tier 1: Ultra-Secure** (Pure post-quantum with SHAKE256-based AEAD)
207
- - **Tier 2: Balanced** (Post-quantum KEM + Saturnin AEAD)
208
- - **Tier 3: Performance** (Post-quantum KEM + optimized Saturnin)
209
-
210
- ### Zero-knowledge proofs (ZKPs)
211
- - **zk-STARKs** (transparent, post-quantum-friendly proof system used in this stack)
212
- - **Proof generation and verification** via `lib-q-zkp` (built on the workspace STARK crates)
213
- - **WASM**: `lib-q-zkp` is checked for `wasm32-unknown-unknown` in CI when the relevant features are enabled
214
- - **Deeper stack**: `lib-q-plonky` and related crates host the Plonky3-derived STARK pipeline (including univariate and batch STARK, Keccak AIR, and lookup support), gated by features for selective compilation
215
-
216
- ## Architecture
217
-
218
- The workspace is centered on the umbrella **`lib-q`** crate and splits algorithms and infrastructure across focused crates. Conceptually:
219
-
220
- ```
221
- lib-Q/ (repository root)
222
- ├── lib-q/ # Umbrella library (feature-gated re-exports)
223
- ├── lib-q-core/ # Types, traits, provider surface, validation
224
- ├── lib-q-kem/ # KEM façade and integrations
225
- ├── lib-q-ml-kem/, lib-q-cb-kem/, lib-q-hqc/ # Concrete KEM implementations
226
- ├── lib-q-ring/ # ML-DSA field / NTT shared layer
227
- ├── lib-q-prf/, lib-q-ring-sig/ # PRF pilots + lattice-backed ring-style openings (research)
228
- ├── lib-q-sig/, lib-q-ml-dsa/, lib-q-slh-dsa/, lib-q-fn-dsa/
229
- ├── lib-q-lattice-zkp/ # Module-lattice ZKP research (sigma, commitments)
230
- ├── lib-q-sca-test/ # SCA screening tooling
231
- ├── lib-q-hash/, lib-q-sha3/, lib-q-keccak/, lib-q-k12/
232
- ├── lib-q-aead/, lib-q-saturnin/
233
- ├── lib-q-hpke/
234
- ├── lib-q-zkp/, lib-q-stark*/, lib-q-plonky*/
235
- ├── lib-q-utils/, lib-q-random/, lib-q-platform/,
236
- └── examples/
237
- ```
238
-
239
- The table above is the authoritative crate list; the `[workspace].members` table in [Cargo.toml](Cargo.toml) is the same set plus the non-published `examples` member.
240
-
241
- ## Security model
242
-
243
- - **Post-quantum asymmetric**: No classical public-key schemes (RSA, ECC, etc.) for those roles; asymmetric modules track NIST PQC (see [SECURITY.md](SECURITY.md)).
244
- - **Hashes / XOFs**: Cryptographic design targets the SHA-3 family; symmetric constructions center on Saturnin and SHAKE-based options as documented per crate.
245
- - **Constant-time intent**: Critical paths are written for constant-time behavior; full guarantees require platform-specific review and tooling (see [ROADMAP.md](ROADMAP.md)).
246
- - **Secure memory**: Sensitive buffers use explicit zeroization where the type system allows.
247
- - **Side-channel awareness**: Design and review target timing and cache behavior; formal side-channel certification is not yet claimed.
248
-
249
- ## Development status
250
-
251
- **Active development.** Major algorithms are implemented and covered by automated tests; the library remains **pre-production** until independent audit and release hardening (see [SECURITY.md](SECURITY.md)).
252
-
253
- ### Implemented capabilities
254
- - **ML-DSA** (FIPS 204; parameter sets ML-DSA-44, ML-DSA-65, ML-DSA-87) with provider-style integration
255
- - **FN-DSA** (FIPS 206) with CI coverage
256
- - **SLH-DSA** (FIPS 205) including all twelve SLH-DSA parameter sets
257
- - **ML-KEM** (FIPS 203; levels 1, 3, and 5)
258
- - **CB-KEM** (Classic McEliece–family; five parameter sets, feature-selected)
259
- - **HQC** (HQC-128, HQC-192, HQC-256)
260
- - **Saturnin** (AEAD, block, hash, stream modes)
261
- - **HPKE** (RFC 9180) with post-quantum KEM and AEAD options
262
- - **Hash and XOF suite** (SHA-3 family, including SHAKE and cSHAKE, as exposed by workspace crates)
263
- - **ZKP / STARK stack** (`lib-q-zkp` and supporting `lib-q-stark*` / `lib-q-plonky*` crates)
264
- - **Lattice infrastructure** (`lib-q-ring` for ML-DSA field arithmetic; `lib-q-lattice-zkp` for research-grade module-lattice proofs, separate from STARKs)
265
- - **PRF and ring-style opening pilots** (`lib-q-prf`, `lib-q-ring-sig`; research crates layered on lattice commitments—see per-crate READMEs)
266
- - **Side-channel tooling** (`lib-q-sca-test` for statistical leakage screening, not a certification claim)
267
- - **WASM** build paths for core scenarios (see CI and scripts referenced in the [no_std and WASM](#no_std-embedded-and-webassembly) section)
268
- - **Engineering**: consistent error types, security validation utilities, and GitHub Actions for build, test, coverage, and security checks
269
-
270
- ### Near-term focus
271
- - **Performance and ergonomics** for CB-KEM and other large-key KEMs
272
- - **Assurance**: expanded fuzzing, constant-time verification where feasible, and third-party security review
273
- - **ZKP**: documentation, API stability, and production-oriented hardening of the STARK pipeline
274
-
275
- ## Testing
276
-
277
- ### `lib-q-sig` and SLH-DSA features
278
-
279
- `lib-q-sig` separates **algorithm enablement** from **who supplies randomness**:
280
-
281
- - **`slh-dsa`**: SLH-DSA with caller-supplied randomness (suitable for `no_std` and tests that pass explicit buffers).
282
- - **`slh-dsa-std`**: The above plus OS-backed entropy when APIs use `None` for randomness on std targets.
283
-
284
- Run crate integration tests accordingly:
285
-
286
- ```bash
287
- cargo test -p lib-q-sig --features slh-dsa
288
- cargo test -p lib-q-sig --features slh-dsa-std
289
- ```
290
-
291
- The second command includes end-to-end tests that rely on implicit RNG wiring (`lib-q-random`); the first is appropriate when you only need explicit-randomness coverage.
292
-
293
- ## Documentation
294
-
295
- - [ROADMAP](ROADMAP.md)
296
- - [Security policy](SECURITY.md)
297
- - [Security model (technical)](docs/security.md)
298
- - [ZKP Implementation and Library Layout](docs/zkp-implementation.md) (includes STARK stack and `lib-q-lattice-zkp`)
299
- - [API Design](docs/api-design.md)
300
- - [HPKE Architecture](docs/hpke-architecture.md)
301
- - [Memory Architecture](docs/memory-architecture.md)
302
- - [Interoperability](docs/interoperability.md)
303
- - [Entropy Validation](docs/entropy-validation.md)
304
- - [Test Coverage](docs/test-coverage.md)
305
- - [AI-Generated Wiki](https://deepwiki.com/Enkom-Tech/libQ)
306
-
307
- ## License
308
-
309
- Apache 2.0 License - see [LICENSE](LICENSE) for details.
310
-
311
- ## Contributing
312
-
313
- We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
314
-
315
- ## Security notice
316
-
317
- This project ships real cryptographic code but is **not positioned as production-ready**. Treat it as suitable for research, education, interoperability experiments, and internal prototypes until:
318
-
319
- - An independent security audit of the code you enable has been completed, and
320
- - Your own integration testing, threat modeling, and operational controls are in place.
321
-
322
- Absence of a published vulnerability report does not constitute a warranty. Track [SECURITY.md](SECURITY.md) for supported branches, reporting, and update policy.
1
+ # lib-Q - Post-Quantum Cryptography Library
2
+
3
+ A Rust cryptography workspace focused on **NIST-standardized post-quantum** key exchange and signatures, **SHA-3-family** hashes and XOFs, and a **transparent STARK**–based zero-knowledge stack. CI enforces `cargo check --workspace --exclude lib-q-examples --exclude lib-q-sca-test --target wasm32-unknown-unknown` (with the `getrandom` wasm_js cfg) so the **publishable library workspace** compiles for the WebAssembly target; npm bundles are produced for the `@lib-q/*` packages listed below (see [docs/npm-packages.md](docs/npm-packages.md)). For build modes, feature flags, and browser baselines, see [docs/wasm-compilation.md](docs/wasm-compilation.md).
4
+
5
+ ## Mission
6
+
7
+ lib-Q provides a coherent Rust API surface over NIST-track post-quantum primitives, SHA-3–family hashing, Saturnin AEAD, HPKE, and optional STARK-based proofs, with the goal of keeping advanced cryptography approachable without hiding residual implementation risk.
8
+
9
+ ## Key features
10
+
11
+ - **Post-quantum first**: Post-quantum KEMs and signatures with tiered symmetric options
12
+ - **Standards-aligned**: PQC KEMs and signatures track NIST-standardized modules (e.g. FIPS 203/204/205/206, HQC, Classic McEliece–family CB-KEM); hashes and XOFs use the SHA-3 family; symmetric design centers on Saturnin; ZKPs use a transparent STARK stack (complementary to the NIST PQC algorithm set)
13
+ - **Memory safe**: Built in Rust with zero-cost abstractions
14
+ - **Cross-platform**: Native Rust + WASM compilation
15
+ - **Intuitive API**: Clean, consistent interface designed for modern development
16
+ - **Self-contained algorithms**: No external non-Rust tooling required for core use
17
+ - **Three security tiers**: Ultra-secure, balanced, and performance-optimized options
18
+ - **Modular design**: Use only what you need with individual crates and npm packages
19
+
20
+ ## no_std, embedded, and WebAssembly
21
+
22
+ - **Umbrella `lib-q` crate**: Disabling default features applies `#![no_std]` to this crate's own code, but some path dependencies are still declared with `std` enabled (for example unified signature support via `lib-q-sig`). The final artifact may still link the standard library. For a **true** `no_std` + `alloc` dependency tree, use the **workspace crates you need** (`lib-q-core`, `lib-q-kem`, `lib-q-ml-dsa`, etc.) with `--no-default-features` and each crate's `alloc` / algorithm features. Per-crate READMEs describe WASM and `no_std` where relevant (for example [lib-q-saturnin/README.md](lib-q-saturnin/README.md)).
23
+
24
+ - **WASM and `getrandom`**: Match CI when compiling for `wasm32-unknown-unknown`: set `CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUSTFLAGS` to `--cfg getrandom_backend="wasm_js" -C panic=abort` (see [.github/actions/wasm-build/action.yml](.github/actions/wasm-build/action.yml), [scripts/build-wasm.ps1](scripts/build-wasm.ps1), [scripts/security-check.ps1](scripts/security-check.ps1)).
25
+
26
+ - **`lib-q-zkp`**: Ships a `cdylib` + `wasm` feature for `wasm-pack` / `@lib-q/zkp`; CI also `cargo check`s the ZKP stack on `wasm32-unknown-unknown`.
27
+
28
+ ### Browser example
29
+
30
+ The minimal browser demo in [`examples/wasm-browser-demo`](examples/wasm-browser-demo) exposes an ML-DSA-44 smoke API:
31
+
32
+ ```javascript
33
+ import init, { wasm_smoke_ml_dsa_sign_verify } from "./pkg/wasm_browser_demo.js";
34
+
35
+ await init();
36
+ const ok = await wasm_smoke_ml_dsa_sign_verify();
37
+ console.log("ML-DSA wasm smoke:", ok);
38
+ ```
39
+
40
+ ## Package structure
41
+
42
+ lib-Q is organized as a Rust workspace with individual crates and npm packages:
43
+
44
+ ### Rust workspace crates
45
+
46
+ Publishing to [crates.io](https://crates.io/) is driven by [`.github/workflows/cd.yml`](.github/workflows/cd.yml) in dependency order. The `examples` umbrella and `examples/wasm-browser-demo` are integration harnesses (`publish = false` where set); other members follow `[workspace].members` in [Cargo.toml](Cargo.toml). The workspace-wide WASM compile gate excludes those example crates and `lib-q-sca-test`.
47
+
48
+ | Crate | Role |
49
+ |-------|------|
50
+ | **`lib-q`** | Umbrella library (feature-gated re-exports) |
51
+ | **`lib-q-types`** | Shared type definitions |
52
+ | **`lib-q-core`** | Core types, traits, provider surface, validation |
53
+ | **`lib-q-keccak`** | Keccak-f / sponge building blocks |
54
+ | **`lib-q-k12`** | KangarooTwelve (K12) |
55
+ | **`lib-q-sha3`** | SHA-3 / SHAKE / cSHAKE core |
56
+ | **`lib-q-keccak-digest`** | Digest adapter over Keccak |
57
+ | **`lib-q-kem`** | KEM façade (ML-KEM, CB-KEM, HQC integration) |
58
+ | **`lib-q-ml-kem`** | ML-KEM (FIPS 203) |
59
+ | **`lib-q-ml-dsa`** | ML-DSA (FIPS 204) |
60
+ | **`lib-q-ring`** | Negacyclic ring / NTT layer for ML-DSA |
61
+ | **`lib-q-sca-test`** | Statistical side-channel harness (TVLA-style) |
62
+ | **`lib-q-lattice-zkp`** | Module-lattice commitments / sigma research |
63
+ | **`lib-q-ring-sig`** | Ring-style openings / DualRing pilots |
64
+ | **`lib-q-prf`** | Legendre / Gold PRF building blocks |
65
+ | **`lib-q-platform`** | Platform helpers |
66
+ | **`lib-q-intrinsics`** | SIMD / intrinsics helpers |
67
+ | **`lib-q-sig`** | Signature façade (ML-DSA, SLH-DSA) |
68
+ | **`lib-q-hash`** | Hash façade (SHAKE, KMAC, TupleHash, etc.) |
69
+ | **`lib-q-aead`** | AEAD façade (Saturnin, Romulus, duplex, tweak) |
70
+ | **`lib-q-saturnin`** | Saturnin suite |
71
+ | **`lib-q-duplex-aead`** | Duplex-sponge AEAD |
72
+ | **`lib-q-tweak-aead`** | Tweakable CTR AEAD over Keccak |
73
+ | **`lib-q-romulus`** | Romulus AEAD (Skinny-based) |
74
+ | **`lib-q-hpke`** | HPKE (RFC 9180) |
75
+ | **`lib-q-utils`** | Shared utilities |
76
+ | **`lib-q-zkp`** | ZKP public API (STARK-backed) |
77
+ | **`lib-q-fn-dsa`** | FN-DSA (FIPS 206) |
78
+ | **`lib-q-slh-dsa`** | SLH-DSA (FIPS 205) |
79
+ | **`lib-q-cb-kem`** | Classic McEliece–family CB-KEM |
80
+ | **`lib-q-random`** | Randomness / entropy helpers |
81
+ | **`lib-q-hqc`** | HQC KEM |
82
+ | **`lib-q-hqc-traits`** | HQC shared traits (`lib-q-hqc/traits`) |
83
+ | **`lib-q-stark`** | STARK prover stack (top-level) |
84
+ | **`lib-q-stark-air`** | AIR definitions |
85
+ | **`lib-q-stark-challenger`** | Fiat–Shamir challenger |
86
+ | **`lib-q-stark-commit`** | Commitment layer |
87
+ | **`lib-q-stark-dft`** | DFT / NTT for STARKs |
88
+ | **`lib-q-stark-field`** | Field arithmetic |
89
+ | **`lib-q-stark-field-testing`** | Field test helpers |
90
+ | **`lib-q-stark-fri`** | FRI |
91
+ | **`lib-q-stark-interpolation`** | Interpolation |
92
+ | **`lib-q-stark-matrix`** | Matrix ops |
93
+ | **`lib-q-stark-mds`** | MDS layer |
94
+ | **`lib-q-stark-merkle`** | Merkle trees |
95
+ | **`lib-q-stark-mersenne31`** | Mersenne-31 field |
96
+ | **`lib-q-stark-monty31`** | Monty-31 field |
97
+ | **`lib-q-stark-rayon`** | Optional Rayon parallelism |
98
+ | **`lib-q-stark-symmetric`** | Symmetric primitives for STARKs |
99
+ | **`lib-q-stark-util`** | STARK utilities |
100
+ | **`lib-q-stark-shake256`** | SHAKE256 bindings |
101
+ | **`lib-q-stark-shake128`** | SHAKE128 bindings |
102
+ | **`lib-q-stark-sha3-256`** | SHA3-256 bindings |
103
+ | **`lib-q-poseidon`** | Poseidon permutation |
104
+ | **`lib-q-plonky-multilinear-util`** | Plonky3 multilinear utilities |
105
+ | **`lib-q-plonky-keccak-air`** | Keccak AIR |
106
+ | **`lib-q-plonky-lookup`** | Lookup argument support |
107
+ | **`lib-q-plonky-uni-stark`** | Univariate STARK |
108
+ | **`lib-q-plonky-batch-stark`** | Batch STARK |
109
+ | **`lib-q-plonky`** | Plonky3-derived integration |
110
+
111
+ ### npm packages (npmjs.com)
112
+
113
+ **22** `@lib-q/*` packages are built with `wasm-pack` in CD. See [docs/npm-coverage.md](docs/npm-coverage.md) for how npm maps to the Rust workspace (STARK/Plonky subcrates stay Rust-only; umbrella npm packages cover the JS surface).
114
+
115
+ - **`@lib-q/core`** — Umbrella WASM bundle (all algorithms path used in CD)
116
+ - **`@lib-q/ml-kem`** — ML-KEM (FIPS 203) only
117
+ - **`@lib-q/kem`** — Post-quantum KEM façade
118
+ - **`@lib-q/sig`** — Post-quantum signatures (ML-DSA path in CD)
119
+ - **`@lib-q/fn-dsa`** — FN-DSA (FIPS 206)
120
+ - **`@lib-q/hash`** — SHA-3–family hash façade
121
+ - **`@lib-q/utils`** — Utilities
122
+ - **`@lib-q/aead`** — Post-quantum AEAD (Saturnin, Romulus, duplex-sponge)
123
+ - **`@lib-q/hpke`** — Post-quantum HPKE (RFC 9180)
124
+ - **`@lib-q/zkp`** — ZKP / STARK proofs (high-level JSON API)
125
+ - **`@lib-q/random`** — Secure random bytes (`getrandom` / wasm_js)
126
+ - **`@lib-q/hqc`** — HQC KEM
127
+ - **`@lib-q/slh-dsa`** — SLH-DSA (FIPS 205)
128
+ - **`@lib-q/cb-kem`** — Classic McEliece CB-KEM (single compile-time parameter set per build)
129
+ - **`@lib-q/ring-sig`** — Federation / DualRing-LB pilot bindings
130
+ - **`@lib-q/prf`** — Legendre / Gold PRF pilots
131
+ - **`@lib-q/stark`** — STARK framework (metadata; use **`@lib-q/zkp`** for preimage prove/verify in JS)
132
+ - **`@lib-q/plonky`** — Plonky3-derived STARK components
133
+ - **`@lib-q/poseidon`** — Poseidon-128 for STARK fields
134
+ - **`@lib-q/lattice-zkp`** Module-lattice / sigma research APIs
135
+ - **`@lib-q/ring`** — ML-DSA ring arithmetic \(R_q\)
136
+
137
+ API reference: [docs/npm-wasm-api.md](docs/npm-wasm-api.md).
138
+
139
+ ## Installation
140
+
141
+ ### Rust (Complete Library)
142
+ ```bash
143
+ cargo add lib-q
144
+ ```
145
+
146
+ ### Rust (Individual Crates)
147
+ ```bash
148
+ # For KEM operations only
149
+ cargo add lib-q-kem
150
+
151
+ # For signatures only
152
+ cargo add lib-q-sig
153
+
154
+ # For FN-DSA signatures only
155
+ cargo add lib-q-fn-dsa
156
+
157
+ # For hash functions only
158
+ cargo add lib-q-hash
159
+
160
+ # For utilities only
161
+ cargo add lib-q-utils
162
+ ```
163
+
164
+ ### Node.js (Complete Library)
165
+ ```bash
166
+ npm install @lib-q/core
167
+ ```
168
+
169
+ ### Node.js (Individual Packages)
170
+ ```bash
171
+ # For ML-KEM only
172
+ npm install @lib-q/ml-kem
173
+
174
+ # For KEM operations only
175
+ npm install @lib-q/kem
176
+
177
+ # For signatures only
178
+ npm install @lib-q/sig
179
+
180
+ # For FN-DSA signatures only
181
+ npm install @lib-q/fn-dsa
182
+
183
+ # For hash functions only
184
+ npm install @lib-q/hash
185
+
186
+ # For utilities only
187
+ npm install @lib-q/utils
188
+
189
+ # AEAD, HPKE, ZKP, RNG, HQC, SLH-DSA, CB-KEM, ring-sig, PRF
190
+ npm install @lib-q/aead @lib-q/hpke @lib-q/zkp @lib-q/random @lib-q/hqc @lib-q/slh-dsa @lib-q/cb-kem @lib-q/ring-sig @lib-q/prf
191
+ ```
192
+
193
+ ## Supported algorithms
194
+
195
+ ### Key encapsulation mechanisms (KEMs)
196
+ - **ML-KEM** (FIPS 203; security levels 1, 3, and 5)
197
+ - **CB-KEM** (code-based KEM in the Classic McEliece family; five NIST parameter sets, selectable via crate features)
198
+ - **HQC** (NIST-standardized code-based KEM; parameter sets HQC-128, HQC-192, and HQC-256, corresponding to levels 1, 3, and 5)
199
+
200
+ ### Digital signatures
201
+ - **ML-DSA** (FIPS 204; levels 1, 3, and 5)
202
+ - **FN-DSA** (FIPS 206; levels 1 and 5)
203
+ - **SLH-DSA** (FIPS 205; levels 1, 3, and 5)
204
+
205
+ ### Hash functions
206
+ - **SHAKE256**, **SHAKE128**, **cSHAKE256** (SHA-3 family; used across signatures, KDFs, and protocols)
207
+ - Additional SHA-3–family APIs where exposed by `lib-q-hash` and related workspace crates (see crate documentation)
208
+
209
+ ### Authenticated encryption
210
+ - **Saturnin** (post-quantum symmetric suite: AEAD, block cipher, hash, and stream modes)
211
+
212
+ ### Hybrid public-key encryption (HPKE)
213
+ - **Tier 1: Ultra-Secure** (Pure post-quantum with SHAKE256-based AEAD)
214
+ - **Tier 2: Balanced** (Post-quantum KEM + Saturnin AEAD)
215
+ - **Tier 3: Performance** (Post-quantum KEM + optimized Saturnin)
216
+
217
+ ### Zero-knowledge proofs (ZKPs)
218
+ - **zk-STARKs** (transparent, post-quantum-friendly proof system used in this stack)
219
+ - **Proof generation and verification** via `lib-q-zkp` (built on the workspace STARK crates)
220
+ - **WASM**: `lib-q-zkp` is checked for `wasm32-unknown-unknown` in CI when the relevant features are enabled
221
+ - **Deeper stack**: `lib-q-plonky` and related crates host the Plonky3-derived STARK pipeline (including univariate and batch STARK, Keccak AIR, and lookup support), gated by features for selective compilation
222
+
223
+ ## Architecture
224
+
225
+ The workspace is centered on the umbrella **`lib-q`** crate and splits algorithms and infrastructure across focused crates. Conceptually:
226
+
227
+ ```
228
+ lib-Q/ (repository root)
229
+ ├── lib-q/ # Umbrella library (feature-gated re-exports)
230
+ ├── lib-q-core/ # Types, traits, provider surface, validation
231
+ ├── lib-q-kem/ # KEM façade and integrations
232
+ ├── lib-q-ml-kem/, lib-q-cb-kem/, lib-q-hqc/ # Concrete KEM implementations
233
+ ├── lib-q-ring/ # ML-DSA field / NTT shared layer
234
+ ├── lib-q-prf/, lib-q-ring-sig/ # PRF pilots + lattice-backed ring-style openings (research)
235
+ ├── lib-q-sig/, lib-q-ml-dsa/, lib-q-slh-dsa/, lib-q-fn-dsa/
236
+ ├── lib-q-lattice-zkp/ # Module-lattice ZKP research (sigma, commitments)
237
+ ├── lib-q-sca-test/ # SCA screening tooling
238
+ ├── lib-q-hash/, lib-q-sha3/, lib-q-keccak/, lib-q-k12/
239
+ ├── lib-q-aead/, lib-q-saturnin/
240
+ ├── lib-q-hpke/
241
+ ├── lib-q-zkp/, lib-q-stark*/, lib-q-plonky*/
242
+ ├── lib-q-utils/, lib-q-random/, lib-q-platform/, …
243
+ └── examples/
244
+ ```
245
+
246
+ The table above is the authoritative crate list; the `[workspace].members` table in [Cargo.toml](Cargo.toml) is the same set plus the non-published `examples` member.
247
+
248
+ ## Security model
249
+
250
+ - **Post-quantum asymmetric**: No classical public-key schemes (RSA, ECC, etc.) for those roles; asymmetric modules track NIST PQC (see [SECURITY.md](SECURITY.md)).
251
+ - **Hashes / XOFs**: Cryptographic design targets the SHA-3 family; symmetric constructions center on Saturnin and SHAKE-based options as documented per crate.
252
+ - **Constant-time intent**: Critical paths are written for constant-time behavior; full guarantees require platform-specific review and tooling (see [ROADMAP.md](ROADMAP.md)).
253
+ - **Secure memory**: Sensitive buffers use explicit zeroization where the type system allows.
254
+ - **Side-channel awareness**: Design and review target timing and cache behavior; formal side-channel certification is not yet claimed.
255
+
256
+ ## Development status
257
+
258
+ **Active development.** Major algorithms are implemented and covered by automated tests; the library remains **pre-production** until independent audit and release hardening (see [SECURITY.md](SECURITY.md)).
259
+
260
+ ### Implemented capabilities
261
+ - **ML-DSA** (FIPS 204; parameter sets ML-DSA-44, ML-DSA-65, ML-DSA-87) with provider-style integration
262
+ - **FN-DSA** (FIPS 206) with CI coverage
263
+ - **SLH-DSA** (FIPS 205) including all twelve SLH-DSA parameter sets
264
+ - **ML-KEM** (FIPS 203; levels 1, 3, and 5)
265
+ - **CB-KEM** (Classic McEliece–family; five parameter sets, feature-selected)
266
+ - **HQC** (HQC-128, HQC-192, HQC-256)
267
+ - **Saturnin** (AEAD, block, hash, stream modes)
268
+ - **HPKE** (RFC 9180) with post-quantum KEM and AEAD options
269
+ - **Hash and XOF suite** (SHA-3 family, including SHAKE and cSHAKE, as exposed by workspace crates)
270
+ - **ZKP / STARK stack** (`lib-q-zkp` and supporting `lib-q-stark*` / `lib-q-plonky*` crates)
271
+ - **Lattice infrastructure** (`lib-q-ring` for ML-DSA field arithmetic; `lib-q-lattice-zkp` for research-grade module-lattice proofs, separate from STARKs)
272
+ - **PRF and ring-style opening pilots** (`lib-q-prf`, `lib-q-ring-sig`; research crates layered on lattice commitments—see per-crate READMEs)
273
+ - **Side-channel tooling** (`lib-q-sca-test` for statistical leakage screening, not a certification claim)
274
+ - **WASM** build paths for core scenarios (see CI and scripts referenced in the [no_std and WASM](#no_std-embedded-and-webassembly) section)
275
+ - **Engineering**: consistent error types, security validation utilities, and GitHub Actions for build, test, coverage, and security checks
276
+
277
+ ### Near-term focus
278
+ - **Performance and ergonomics** for CB-KEM and other large-key KEMs
279
+ - **Assurance**: expanded fuzzing, constant-time verification where feasible, and third-party security review
280
+ - **ZKP**: documentation, API stability, and production-oriented hardening of the STARK pipeline
281
+
282
+ ## Testing
283
+
284
+ ### `lib-q-sig` and SLH-DSA features
285
+
286
+ `lib-q-sig` separates **algorithm enablement** from **who supplies randomness**:
287
+
288
+ - **`slh-dsa`**: SLH-DSA with caller-supplied randomness (suitable for `no_std` and tests that pass explicit buffers).
289
+ - **`slh-dsa-std`**: The above plus OS-backed entropy when APIs use `None` for randomness on std targets.
290
+
291
+ Run crate integration tests accordingly:
292
+
293
+ ```bash
294
+ cargo test -p lib-q-sig --features slh-dsa
295
+ cargo test -p lib-q-sig --features slh-dsa-std
296
+ ```
297
+
298
+ The second command includes end-to-end tests that rely on implicit RNG wiring (`lib-q-random`); the first is appropriate when you only need explicit-randomness coverage.
299
+
300
+ ## Documentation
301
+
302
+ - [ROADMAP](ROADMAP.md)
303
+ - [Security policy](SECURITY.md)
304
+ - [Security model (technical)](docs/security.md)
305
+ - [ZKP Implementation and Library Layout](docs/zkp-implementation.md) (includes STARK stack and `lib-q-lattice-zkp`)
306
+ - [API Design](docs/api-design.md)
307
+ - [HPKE Architecture](docs/hpke-architecture.md)
308
+ - [Memory Architecture](docs/memory-architecture.md)
309
+ - [Interoperability](docs/interoperability.md)
310
+ - [Entropy Validation](docs/entropy-validation.md)
311
+ - [Test Coverage](docs/test-coverage.md)
312
+ - [AI-Generated Wiki](https://deepwiki.com/Enkom-Tech/libQ)
313
+
314
+ ## License
315
+
316
+ Apache 2.0 License - see [LICENSE](LICENSE) for details.
317
+
318
+ ## Contributing
319
+
320
+ We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
321
+
322
+ ## Security notice
323
+
324
+ This project ships real cryptographic code but is **not positioned as production-ready**. Treat it as suitable for research, education, interoperability experiments, and internal prototypes until:
325
+
326
+ - An independent security audit of the code you enable has been completed, and
327
+ - Your own integration testing, threat modeling, and operational controls are in place.
328
+
329
+ Absence of a published vulnerability report does not constitute a warranty. Track [SECURITY.md](SECURITY.md) for supported branches, reporting, and update policy.