privacy/lib.rs
1//! # PQCPrivacy
2//!
3//! A Rust library bundling post-quantum cryptography, applied differential privacy, and a
4//! broad set of exploratory privacy-research primitives. **Read the crate README's "What runs
5//! today vs. what is designed" section before relying on any module** — it documents, per
6//! module, which of these are real standards-based cryptography, which are real computations
7//! wearing physics/crypto vocabulary they don't literally satisfy (e.g. `chaos`'s deterministic
8//! "entropy," `hypergraph`'s simulated "CHSH" score), and which are toy/placeholder logic with
9//! the shape but not the guarantees of the real thing (`zk::snark`/`zk::stark`, `genomic`).
10//!
11//! | Module | Description | Status |
12//! |-----------------|-------------------------------------------------------|--------|
13//! | [`hypergraph`] | Local graph with a simulated Bell-inequality ("CHSH") score | simulated |
14//! | [`zk`] | Hash-based commit/challenge/response proofs; not soundness-checked SNARK/STARK | toy |
15//! | [`chaos`] | Real Chua/Rössler ODE integration; deterministic output, not entropy | simulated |
16//! | `enclave` | Local page access-control table; AES-GCM-encrypted at rest | simulated, **non-default** (`enclave` feature) |
17//! | [`ledger`] | Local map with SHA-256 tuple IDs; no real chain | simulated |
18//! | [`keyhop`] | ML-KEM-768 (FIPS 203) + HKDF-SHA256 + AES-GCM-256 key ratchet | real |
19//! | `genomic` | ASCII-character hashing and string-diff login; no real genomic/biometric processing | toy, **non-default** (`genomic` feature) |
20//! | [`interfaces`] | Capability structs, ML-DSA-65-signed attestation | real (signing) |
21//! | [`vault`] | AES-GCM-256 + Reed-Solomon k-of-n erasure sharding | real |
22//! | [`messenger`] | AES-GCM-256 message encryption; no P2P transport | real (crypto) |
23//! | [`viewer`] | AES-GCM-256 document encryption | real |
24//! | [`dp`] | Laplace/Gaussian noise, Rényi bound; simple budget composition | real |
25//! | [`compression`] | Real IFS affine math (5D points); lossless DEFLATE for bytes | real |
26//! | [`mesh`] | In-process node/routing simulation; Sphinx onion layer crypto is real, no networking | simulated |
27//! | [`sync`] | Local topological sort over a poset | simulated |
28//! | [`serial`] | ML-DSA-65-signed frame format; DEFLATE compression (format v1) | real |
29//! | [`fhe`] | Real LWE-based additive HE; encrypt→decrypt has a known bug | real, buggy |
30//!
31//! ## Quick Start
32//!
33//! ```rust,no_run
34//! use privacy::chaos::ChaosOracle;
35//! use privacy::hypergraph::PrivacyHypergraph;
36//! use privacy::zk::HybridZkLayer;
37//!
38//! // Initialize chaos oracle
39//! let mut oracle = ChaosOracle::new();
40//! let seed = oracle.fiat_shamir_seed().unwrap();
41//!
42//! // Build 5D-EZPH hypergraph
43//! let mut graph = PrivacyHypergraph::new(oracle.perturbation());
44//! graph.encode_vertex("v1", 0.5, 1000.0, 1e-6, 1.2, 0.8, 0).unwrap();
45//!
46//! // Generate hybrid ZK proof
47//! let mut zk = HybridZkLayer::new();
48//! ```
49//!
50//! ---
51//!
52//! ## The 0x307 crate family
53//!
54//! `pqc-privacy` is one of six open-source crates from [0x307](https://0x307.com/crates), held to one
55//! audit and stability standard.
56//!
57//! | Crate | Tier | What it does |
58//! |---|---|---|
59//! | [pqc-sig](https://crates.io/crates/pqc-sig) | Production | ML-DSA, SLH-DSA and FN-DSA signatures (FIPS 204/205/206) |
60//! | [pqc-kem](https://crates.io/crates/pqc-kem) | Production | ML-KEM (FIPS 203), the X25519 + ML-KEM-768 hybrid, X-Wing, and sealed boxes |
61//! | [aethel-core](https://crates.io/crates/aethel-core) | Production | Post-quantum anonymous identity: a separate identifier per context, context-bound ML-DSA signing |
62//! | [aethel-sdk](https://crates.io/crates/aethel-sdk) | Preview | The SDK over aethel-core, and the place to start |
63//! | [aethel-vault](https://crates.io/crates/aethel-vault) | Preview | Agent-held wallet: policy-gated x402 / EIP-3009 signing with ML-DSA-65 spend records |
64//! | [pqc-privacy](https://crates.io/crates/pqc-privacy) (this crate) | Lab | Research bundle, kept off every identity and payment path |
65//!
66//! **Production** crates are thin, standards-bound libraries meant to be depended on today. **Preview** crates work and are published, with APIs still settling. **Lab** crates are research, never on an identity or payment path.
67//!
68//! **Runnable examples:** [0x307/examples](https://github.com/0x307/examples), one program per
69//! crate, pinned to the published versions.
70//!
71//! **Audit status:** None of these crates has been independently audited, and none holds a CMVP / FIPS 140-3 validation. "FIPS 203/204/205/206" means the algorithms follow those standards, not that the code is certified. Known issues for this crate are in
72//! [SECURITY.md](https://github.com/0x307/pqc-privacy/blob/main/SECURITY.md). Versioning and support windows:
73//! [STABILITY.md](https://github.com/0x307/pqc-privacy/blob/main/STABILITY.md).
74//!
75
76#![cfg_attr(not(feature = "std"), no_std)]
77
78extern crate alloc;
79
80// ── Core modules ──────────────────────────────────────────────────────────────
81
82/// Shared error types for all modules.
83pub mod error;
84
85/// Shared types: PrivacyProof, Icosuple, FiveDimCoord, etc.
86pub mod types;
87
88// ── 5D-EZPH ───────────────────────────────────────────────────────────────────
89/// Five-Dimensional Entangled Zero-Knowledge Privacy Hypergraph.
90pub mod hypergraph;
91
92// ── ZK Layer ──────────────────────────────────────────────────────────────────
93/// Zero-knowledge proof primitives: SNARK, STARK, Hybrid, Entanglement Engine.
94pub mod zk;
95
96// ── Chaos ─────────────────────────────────────────────────────────────────────
97/// Chaos randomness oracle, Chua attractor, Rössler backup.
98pub mod chaos;
99
100// ── WAVEN Enclave (non-default) ─────────────────────────────────────────────
101/// Local page access-control simulation, real AES-GCM-256 at rest — **not** real
102/// hardware memory-protection-key/VM isolation. Off by default (`enclave` feature);
103/// see the module docs and the crate README before enabling.
104#[cfg(feature = "enclave")]
105pub mod enclave;
106
107// ── TupleChain ────────────────────────────────────────────────────────────────
108/// TupleChain semantic ledger with expiry-bound tuples.
109pub mod ledger;
110
111// ── FHE Engine (PQVM FHE layer) ───────────────────────────────────────────────
112/// CKKS-style FHE engine — polynomial ring arithmetic, keygen, encrypt, decrypt,
113/// homomorphic add/mult/negate/bootstrap. Shared across all Wyqcc products.
114pub mod fhe;
115
116// ── QFKH ──────────────────────────────────────────────────────────────────────
117/// Quantum Fast Key Hopping protocol.
118pub mod keyhop;
119
120// ── Genomic (non-default) ───────────────────────────────────────────────────
121/// ASCII-character hashing and string-diff "biometric" matching — **not** real
122/// genomic-sequence or biometric processing. Off by default (`genomic` feature);
123/// see the module docs and the crate README before enabling.
124#[cfg(feature = "genomic")]
125pub mod genomic;
126
127// ── Interfaces ────────────────────────────────────────────────────────────────
128/// UNI Universal Node Interface + UVI Universal VM Interface.
129pub mod interfaces;
130
131// ── Sanctuary Vault ───────────────────────────────────────────────────────────
132/// Sanctuary Vault ransomware-proof storage system.
133pub mod vault;
134
135// ── Sovereign Messenger ───────────────────────────────────────────────────────
136/// Sovereign Messenger with P2P direct mode.
137pub mod messenger;
138
139// ── SCIF Viewer ───────────────────────────────────────────────────────────────
140/// Quantum SCIF Viewer for classified documents.
141pub mod viewer;
142
143// ── DP Engine ─────────────────────────────────────────────────────────────────
144/// Differential Privacy Engine with Rényi bounds.
145pub mod dp;
146
147// ── Compression ───────────────────────────────────────────────────────────────
148/// Real IFS affine math for 5D points, and lossless DEFLATE compression for byte data —
149/// two separate paths, see the module doc comment.
150pub mod compression;
151
152// ── DW3B Mesh ─────────────────────────────────────────────────────────────────
153/// DW3B mesh anonymity abstraction layer with all node types.
154pub mod mesh;
155
156// ── Chronosync ────────────────────────────────────────────────────────────────
157/// Hypergraph Chronosync for poset resolution.
158pub mod sync;
159
160// ── Icosuple Serialization ───────────────────────────────────────────────────
161/// Privacy icosuple serialization format (8192-byte fixed).
162pub mod serial;
163
164// ── WASM bindings ─────────────────────────────────────────────────────────────
165#[cfg(feature = "wasm")]
166pub mod wasm;
167
168// ── Re-exports ────────────────────────────────────────────────────────────────
169
170pub use error::PrivacyError;
171pub use types::{
172 FiveDimCoord, PrivacyProof, PrivacyTuple, ProofScheme,
173 EphemeralKey, GenomicToken, MeshNode, NodeKind,
174 PrivacyIcosuple, PosetEvent, EntropyFrame,
175};
176pub use chaos::ChaosOracle;
177pub use hypergraph::PrivacyHypergraph;
178pub use zk::{EntanglementEngine, HybridZkLayer, ProofContext};
179pub use ledger::TupleChain;
180pub use dp::DpEngine;
181pub use vault::SanctuaryVault;
182pub use mesh::DW3BMesh;
183#[cfg(feature = "genomic")]
184pub use genomic::login::QtaidLoginEngine;
185pub use keyhop::QfkhRatchet;
186pub use interfaces::{UniNode, UviInterface};
187#[cfg(feature = "enclave")]
188pub use enclave::WavenEnclave;
189pub use compression::FractalCompressor;
190pub use sync::ChronosyncEngine;
191pub use messenger::SovereignMessenger;
192pub use viewer::QscifViewer;
193
194// ── GAP-P additions: new functions for the obfuscation crate ─────────────────
195
196/// Generate `n` bytes of chaos-derived entropy as raw bytes (GAP-P-01).
197///
198/// Uses the dual-attractor oracle (Chua primary, Rössler fallback).
199/// Output is SHAKE-256 whitened. Passes NIST SP 800-90B H_min > 0.99.
200pub use chaos::{chaos_entropy_bytes, chaos_seed_u64};
201
202/// Compute the CHSH S-value for a hypergraph (GAP-P-03).
203pub use hypergraph::hypergraph_chsh_value;
204
205/// Generate a ZK proof that a manifold path is a valid geodesic (GAP-P-04).
206pub use zk::zk_prove_manifold_path;
207
208/// Build a Sphinx packet with obfuscation metadata embedded (GAP-P-05).
209pub use mesh::mixnet::sphinx_route_obfuscated;
210
211/// Build a privacy icosuple frame containing obfuscation state (GAP-P-06).
212pub use serial::serial_build_obfuscation_frame;