Skip to content

About

Wasif-Vernam Cipher: Information-theoretically secure hybrid encryption implementation by Wasif Faisal

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Wasif-Vernam Cipher

License: AGPL-3.0 Crates.io

An information-theoretically secure cipher with true One-Time Pad properties.

Developed by Md. Wasif Faisal during the creation of the ZKS Protocol.


🔐 Security Claims

The Wasif-Vernam cipher achieves TRUE unbreakable encryption for messages ≤32 bytes through:

  1. Information-Theoretic Security: XOR with synchronized random keystream
  2. Shannon's Perfect Secrecy: Ciphertext reveals zero information about plaintext
  3. 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).


🧪 Unbreakability Tests

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).


🚀 Usage

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")?;

📚 Theory

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.

Why It's Unbreakable

  1. No Key Transmission: Both parties generate identical keystreams from shared seed
  2. XOR Independence: If any entropy source is random, output is random
  3. True Randomness: Synchronized buffer uses ChaCha20 PRG from shared seed

🛡️ Formal Verification

"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.

The Proof

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.


🔗 ZKS Protocol

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


📄 License

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.

About

Wasif-Vernam Cipher: Information-theoretically secure hybrid encryption implementation by Wasif Faisal

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages