1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
// SPDX-License-Identifier: Apache-2.0
//! Origin Crypto SDK — Post-quantum and classical cryptographic primitives.
//!
//! A standalone Rust SDK for signing, encryption, key derivation, and
//! key encapsulation, with first-class support for both classical
//! (Ed25519, X25519) and post-quantum (Falcon-1024, SLH-DSA, ML-DSA,
//! NTRU Prime, Curve41417) primitives.
//!
//! # Quick start
//!
//! For most users, importing the [`prelude`] gives you everything:
//!
//! ```rust
//! use origin_crypto_sdk::prelude::*;
//!
//! // Hybrid Ed25519 + Falcon-1024 signature (recommended default)
//! let master_seed = [0x42u8; 32];
//! let bundle = HybridSigningKeyBundle::from_seed(&master_seed, "my-app")
//! .expect("valid seed");
//! let msg = b"sign this";
//! let sig = bundle.sign_hybrid(msg);
//! // sig is an Ed25519 + Falcon-1024 hybrid signature
//! ```
//!
//! For users who only need a single primitive:
//!
//! ```rust
//! use origin_crypto_sdk::signing::classical::Ed25519Signer;
//! use origin_crypto_sdk::signing::postquantum::Falcon1024Signer;
//!
//! // Just Ed25519
//! let ed = Ed25519Signer::from_seed(&[1u8; 32]);
//! let sig = ed.sign(b"hello");
//! assert!(ed.verify(b"hello", &sig));
//!
//! // Just Falcon-1024
//! let falcon = Falcon1024Signer::from_seed(&[1u8; 32]);
//! let sig = falcon.sign(b"hello").expect("Falcon sign");
//! assert!(falcon.verify(b"hello", &sig));
//! ```
//!
//! # Module organization
//!
//! - [`signing`] — Direct access to signing primitives, organized by family:
//! - [`signing::classical`] — Ed25519 (no PQ dependencies)
//! - [`signing::postquantum`] — Falcon-512/1024, SLH-DSA, ML-DSA
//! - [`signing::hybrid`] — Recommended default. Ed25519 + PQ combined.
//! - [`aead`] / [`chacha20_blake3`] — Symmetric encryption (committing & non-committing)
//! - [`kdf`] — Key derivation (Argon2id, HKDF-SHA3-256)
//! - [`pqc`] — Raw post-quantum primitives (advanced use)
//! - [`ec_schnorr`] — secp256k1 Schnorr signatures (native, no external deps)
//! - [`prelude`] — One-line import for common types
//!
//! # Security defaults
//!
//! - For **signatures**: use the hybrid (Ed25519 + PQ) — see [`signing::hybrid`].
//! Both must verify, so a vulnerability in one primitive does not break security.
//! - For **encryption**: prefer [`chacha20_blake3`] (committing AEAD).
//! Avoid XChaCha20-Poly1305 unless you specifically need the smaller tag
//! and accept the partitioning-oracle risk.
//! - For **key derivation**: use Argon2id (memory-hard) for password-based KDF,
//! HKDF-SHA3-256 for HKDF-style derivation.
//!
//! # Cargo features
//!
//! | Feature | Enables | Default |
//! |-----------|----------------------------------------|---------|
//! | `parallel` | Rayon-based parallel processing | **yes** |
//! | `slh-dsa` | SLH-DSA / SPHINCS+ signatures (FIPS 205) | no |
//! | `ml-dsa` | ML-DSA / Dilithium signatures (FIPS 204) | no |
//! | `pqc-simd` | SIMD acceleration for NTRU Prime | no |
//!
//! Low-level PQC primitives are always available through their modules
//! (`pqc::falcon1024`, `pqc::ed448`, etc.) — the features only gate the
//! optional FIPS schemes that pull in extra dependencies.
// ──────────────────────────────────────────────────────────────────────
// Public modules (matching the README map exactly)
// ──────────────────────────────────────────────────────────────────────
/// Error types and `Result` alias.
pub use ;
/// Test utilities for downstream users.
///
/// **Feature-gated** — enable with `features = ["test-utils"]`.
///
/// Provides deterministic seeds, keys, nonces, and byte generators so
/// users can write tests against the SDK without hitting real randomness.
///
/// # Example
///
/// ```ignore
/// use origin_crypto_sdk::test_utils::deterministic_seed;
/// let seed = deterministic_seed(42);
/// ```
/// Prelude — re-exports common types for `use origin_crypto_sdk::prelude::*`.
// ── Symmetric encryption ──
// ── Hashing & KDF ──
// ── Signatures ──
/// Signing primitives: classical, post-quantum, and hybrid.
///
/// **Recommended**: use [`signing::hybrid::HybridSigningKeyBundle`] for
/// new applications. It pairs Ed25519 with a post-quantum primitive so
/// the signature remains unforgeable even if one primitive is broken.
// Legacy flat `signing` API (pre-restructuring). Re-exported as
// `origin_crypto_sdk::signing_legacy` for callers that imported the
// old types directly. **Deprecated in 0.4, will be removed in 0.5**.
// See `signing_legacy` module docs for migration instructions.
// ── Randomness & DRBG ──
// ── Utility modules (hidden from docs) ──
/// Entropy analysis — internal utility.
/// Seed handling with TTL and memory security.
/// Merkle Mountain Range — internal utility.
/// Stealth address primitives (KDF + PoW).
/// Error correction codes — internal utility.
/// Low-level cryptographic primitives (hashes, ciphers, etc.).
///
/// **Internal use only.** Application code should use the higher-level
/// modules ([`chacha20_blake3`], [`kdf`], etc.) instead.
/// SipHash keyed hash — internal utility.
/// Compression utility — internal.
/// Blob storage — internal utility.
// ──────────────────────────────────────────────────────────────────────
// Internal modules (not part of public API; use at your own risk)
// ──────────────────────────────────────────────────────────────────────
// ──────────────────────────────────────────────────────────────────────
// Re-exports at crate root for convenience
// ──────────────────────────────────────────────────────────────────────
// Errors
pub use ;
// Encryption
pub use XChaCha20Poly1305;
// KDF
pub use Argon2id;
pub use ;
// MAC
pub use hmac_sha3_256;
// DRBG
pub use ChaCha20Drbg;
// Seed handling
pub use ;
// Signatures — re-exports (DEPRECATED, will be removed in 0.5)
pub use HybridSignatureOutput;
pub use HybridSigningKey;
pub use HybridVerifyingKey;
// Hybrid bundle (canonical PQ-hybrid signing)
pub use HybridSigningKeyBundle;
pub use falcon1024_keygen;
pub use ;
// PQC direct access — use `pqc::{falcon1024, falcon512, ed448, ...}::module` for raw types.
// Re-exports at crate root are intentionally omitted to keep the surface clean.
// Advanced users access via `origin_crypto_sdk::pqc::falcon1024::FalconPrivateKey` etc.
// Ed448 — RFC 8032 signature scheme on the 448-bit Goldilocks curve.
// Exposed at `origin_crypto_sdk::pqc::ed448`.
// Ed41417 — Daniel J. Bernstein's signature scheme on curve41417.
// pub use pqc::curve41417::ed41417 as ed41417_raw; // intentionally not re-exported
// SLH-DSA direct access (feature-gated)
pub use ;
// ML-DSA direct access (feature-gated)
pub use ;