PHANTOM is an implementation of a new post-quantum cryptographic algorithm based on the research of Dr. Luu Hong Dung, as detailed in his paper "THE POST-QUANTUM CRYPTOGRAPHIC ALGORITHM BASED ON OTP CIPHER AND HASH FUNCTIONS". It combines OTP-like security with practical applicability for arbitrary message lengths, aiming to be resistant against quantum attacks. Unlike traditional OTP which requires a key as long as the message, PHANTOM can encrypt messages and files larger than the key size, making it practical for real-world use.
PHANTOM stands out:
- Perfect Secrecy: Inherits the "perfect secrecy" property from OTP, ensuring that there is no relationship between the plaintext and the ciphertext, making it impossible for an attacker to derive the plaintext from the ciphertext.
- Scalable for Large Messages: Encrypts messages/files larger than the key size, making it practical for real-world use.
- Quantum Resistance: Designed to resist attacks even with the assistance of quantum computers, making it a strong candidate for post-quantum cryptography.
This implementation of PHANTOM provides a practical realization of Dr. Luu's work.
- Post-quantum resistant encryption: Secure against quantum computing attacks.
- OTP-like security properties: Provides a high level of security inspired by the One-Time Pad.
- Supports large messages: Can encrypt messages/files larger than the key size.
- File encryption and decryption: Command-line tools for file encryption and decryption.
On AWS EC" t2.small (1vCPU and 2GB Memory)
- Encryption: 2.5 MB/s
- Decryption: 2.5 MB/s
( I have not spent much time on optimisations just yet, but currently using SHA256, and moving to Blake2 should yeild savings)
Prebuilt standalone binaries (with all dependencies included) are available for Debian 12 and should work on Ubuntu and other similar distributions.
- Download the prebuilt binaries from the 'build' folder.
- Run the binaries directly.
- OpenSSL (version 1.1.1 or newer)
- C++17 compatible compiler (e.g., g++)
- Make
-
Clone the repository:
git clone https://github.com/test-sum/phantom-encryption-crypto.git cd phantom-encryption-crypto/ -
Ensure OpenSSL, Make and g++ is installed. On Debian/Ubuntu, you can install it using:
sudo apt update sudo apt install git libssl-dev make g++
-
Build the project:
make
This will generate two executables: encrypt and decrypt.
To encrypt a file:
./encrypt <path to input file> <256-bit key in hex>Example:
./encrypt message.txt aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899This will produce ciphertext.json in the same directory.
To decrypt a file:
./decrypt <path to ciphertext JSON file> <256-bit key in hex>Example:
./decrypt ciphertext.json aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899This will produce the decrypted file with the prefix decrypted_ in the same directory.
- OpenSSL: Used for cryptographic functions (version 1.1.1 or newer)
- nlohmann/json: JSON library for C++ (included as
json.hpp)
- Key Management: Ensure your keys are kept secure and not reused.
- Nonce Usage: Each encryption must use a unique nonce to prevent replay attacks.
- File Security: Encrypted files should be transmitted and stored securely to prevent unauthorized access.
We welcome contributions to the PHANTOM project. Please fork the repository and submit pull requests for review.
- Follow the existing code style.
- Include tests for new features.
- Ensure all existing tests pass.
This implementation is based on the paper "THE POST-QUANTUM CRYPTOGRAPHIC ALGORITHM BASED ON OTP CIPHER AND HASH FUNCTIONS" by Dr. Luu Hong Dung. The original paper focuses on the theoretical aspects of a post-quantum cryptographic algorithm, while this implementation provides a practical realization with additional features such as file encryption, MAC for authentication, and nonce for replay attack prevention.
- Perfect Secrecy: According to Shannon's theory, if the key is a random bit sequence, there is no relationship between the plaintext and the ciphertext, achieving "perfect secrecy". This means that even with brute force, an attacker cannot find the plaintext from the ciphertext.
- Hash Function Utilization: The algorithm uses hash functions to generate encryption keys, ensuring randomness and resistance to attacks. Even if the one-way property of the hash function is broken, the attacker cannot derive the secret key.
- Spoofing Attack Resistance: Unlike traditional OTP, PHANTOM verifies the origin and integrity of the message using a MAC, preventing attackers from sending fake ciphertexts.
You can find the original research paper here: THE POST-QUANTUM CRYPTOGRAPHIC ALGORITHM BASED ON OTP CIPHER AND HASH FUNCTIONS
This project is licensed under the CC BY 4.0 License
For questions or collaboration, please reach out to [email protected] and [email protected]
- Dr. Luu Hong Dung: For the original research on which this implementation is based.
- Contributors to this repo: Jamie Gilchrist

