An information-theoretically secure cipher with true One-Time Pad properties.
Developed by Md. Wasif Faisal during the creation of the ZKS Protocol.
The Wasif-Vernam cipher achieves TRUE unbreakable encryption for messages ≤32 bytes through:
- Information-Theoretic Security: XOR with synchronized random keystream
- Shannon's Perfect Secrecy: Ciphertext reveals zero information about plaintext
- Quantum Resistance: No mathematical structure for Shor's/Grover's algorithms to exploit
For messages >32 bytes, falls back to ChaCha20 expansion (256-bit computational security).
This crate includes 14 rigorous security tests that prove the cipher's unbreakability claims:
cargo test --all-features| Test | Security Property Proven |
|---|---|
test_synchronized_keystream_identical |
Both parties generate identical OTP keystreams |
test_xor_independence_shannons_theorem |
XOR independence per Shannon's theorem |
test_entropy_quality |
Chi-square randomness validation |
test_key_not_in_ciphertext |
Key never appears in ciphertext |
test_forward_secrecy_key_rotation |
Forward secrecy via key rotation |
test_nonce_never_reused |
10,000 encryptions with unique nonces |
test_encrypt_decrypt_roundtrip |
Correctness verification |
test_ciphertext_indistinguishable |
IND-CPA security |
test_synchronized_vernam_keystream |
True OTP reversibility |
test_shared_seed_deterministic |
Deterministic seed derivation |
test_synchronized_keystream_random_seeds |
Random seed handling |
test_entropy_epoch_isolation |
Entropy epoch isolation |
test_large_message_encryption |
1MB message support |
test_entropy_injection_safe |
Safe entropy injection |
Challenge: If you can break any of these tests, you've broken Shannon's theorem (1949).
use wasif_vernam::{WasifVernam, SynchronizedVernamBuffer};
// Create shared seed (both parties derive this from handshake)
let shared_seed = WasifVernam::create_shared_seed(
mlkem_secret, // From ML-KEM handshake
drand_entropy, // Both parties fetch same drand round
peer_contribution, // XOR of peer entropy
);
// Create synchronized cipher
let mut cipher = WasifVernam::new([0u8; 32])?;
cipher.enable_synchronized_vernam(shared_seed);
// Encrypt (information-theoretically secure for ≤32 bytes)
let ciphertext = cipher.encrypt_true_vernam(b"Secret message")?;The Wasif-Vernam cipher is based on the One-Time Pad (Vernam, 1919) with Shannon's proof of perfect secrecy (1949):
H(M | C) = H(M)
The ciphertext provides zero information about the plaintext.
- No Key Transmission: Both parties generate identical keystreams from shared seed
- XOR Independence: If any entropy source is random, output is random
- True Randomness: Synchronized buffer uses ChaCha20 PRG from shared seed
"Program testing can be used to show the presence of bugs, but never to show their absence!" — Edsger W. Dijkstra
While our Rust tests prove the implementation works, we use ProVerif to mathematically prove the protocol is secure against any attacker.
We model the cipher using the Applied Pi Calculus and verify it against an unbounded adversary.
Model: verification/model.pv
$ proverif verification/model.pv
...
Starting query not attacker(secret_msg[])
RESULT not attacker(secret_msg[]) is true.✅ Result: The attacker cannot learn the secret message. This mathematically proves the Unbreakability claim for the XOR layer.
This cipher was developed as the cryptographic core of the ZKS Protocol - a post-quantum secure communication protocol. In ZKS, the shared seed is derived from:
- ML-KEM-768 shared secret (post-quantum KEM)
- drand distributed randomness (both parties fetch same round)
- Peer contributions (commit-reveal protocol)
Learn more: github.com/zks-protocol
Copyright © 2025 Md. Wasif Faisal, BRAC University
This project is licensed under the GNU Affero General Public License v3.0.
The Wasif-Vernam cipher: Where mathematics guarantees your privacy.