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
// Copyright (c) 2026 John A Keeney, Entrouter. All rights reserved.
// Licensed under the Apache License, Version 2.0 with Additional Terms.
// NO COMMERCIAL USE without prior written authorization from Entrouter.
// Unauthorized commercial use will be prosecuted to the fullest extent of the law.
// See the LICENSE file in the project root for full license information.
// NOTICE: Removal of this header is a violation of the license.
//! # KK, Keeney Kode
//!
//! A novel cryptographic primitive where symbol values are temporal
//! functions of universal entropy.
//!
//! ## Core Principle
//!
//! In all existing cryptography, symbol 'A' has a fixed value and encryption
//! hides what 'A' means. In KK, symbol 'A' has no fixed value:
//!
//! ```text
//! KK(S) = S^ε where ε = universal entropy at moment of creation
//! ```
//!
//! The symbol's fundamental value is a function of the universe
//! at the instant it was born. The same symbol encoded twice produces
//! two cryptographically unrelated values.
//!
//! ## Quick Start
//!
//! ```rust
//! use kk_crypto::{encode, decode};
//!
//! // Both parties share a secret
//! let shared_secret = b"our-shared-secret";
//!
//! // Encode: symbol values become functions of this cosmic instant
//! let packet = encode(shared_secret, b"Hello KK!").unwrap();
//!
//! // Transmit packet.to_bytes() to receiver...
//!
//! // Decode: same secret, same moment reference, same values
//! let plaintext = decode(shared_secret, &packet).unwrap();
//! assert_eq!(plaintext, b"Hello KK!");
//! ```
//!
//! ## Architecture
//!
//! ```text
//! Entropy Sources → KK-Mix → Per-Symbol Derivation → Temporal Binding → Encoding
//! (entropy.rs) (kk_mix.rs) (kdf.rs) (temporal.rs) (codec.rs)
//! ```
//!
//! Every cryptographic operation is built from a single novel primitive:
//! the KK permutation (Multiply-Fold-Rotate sponge construction).
//! No SHA-256, no HKDF, no HMAC, 100% original KK.
//!
//! ## Security Model
//!
//! **Threat model:** KK assumes a pre-shared secret between sender and
//! receiver. An attacker may observe, replay, or modify ciphertext in
//! transit but does not know the shared secret.
//!
//! **Confidentiality:** Each encoding captures a unique `EntropySnapshot`
//! (CPU counters, thread jitter, OS randomness). The snapshot feeds the
//! KK-KDF to derive per-chunk keystream, ensuring the same plaintext
//! never produces the same ciphertext twice.
//!
//! **Integrity:** Every `KkPacket` carries a KK-MAC tag over
//! (ciphertext ‖ entropy snapshot). `decode` rejects any packet whose
//! tag does not verify, preventing silent tampering.
//!
//! **Temporal binding:** The `TemporalCommitment` in each packet commits
//! to the entropy used during encoding. The receiver re-derives the
//! commitment from the embedded snapshot and the shared secret, rejecting
//! packets if the commitment does not match.
//!
//! **Key hygiene:** Intermediate keys (commit keys, chunk keystream) are
//! zeroized via the `zeroize` crate immediately after use. The output
//! buffer is zeroized on error paths to prevent partial plaintext leaks.
//!
//! **Limitations:**
//! - KK is a novel, un-audited primitive, it has **not** been reviewed
//! by third-party cryptographers. Do not use for production security.
//! - The base codec has no forward secrecy. Use the `session` module's
//! Rope Ratchet (`encode_session`/`decode_session`) for ~192-bit
//! forward secrecy via 4-strand ratcheting.
//! - Replay protection is **not** built in; callers must add sequence
//! numbers or timestamps at the protocol layer.
//!
//! J.A. Keeney, Australia, 2026
extern crate alloc;
pub
// Re-export the primary API
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use EntropySnapshot;
pub use EntropyPool;
pub use KkError;
pub use ;
// Session (forward secrecy) re-exports
pub use ;
pub use ;
// QKD re-exports
pub use ;
// EKA (Entropy Key Agreement) re-exports
pub use ;
// RNG re-exports
pub use KkRng;
pub use KkRngPool;