Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Post-Quantum Inspired Secure Communication Simulator in C++

I built this project to connect three things I have been trying to bring together: linear algebra, cryptography, and electrical engineering.

At the center of the project is a small toy version of Learning With Errors-style encryption. The encryption part is based on modular matrix-vector arithmetic, and the communication part treats the encrypted ciphertext like something that actually has to move through a noisy channel.

The goal is not to build real production cryptography. The goal is to understand what happens when encrypted data is not just stored somewhere perfectly, but has to survive transmission through a signal system.

In this simulation, ciphertext is encrypted, converted into bits, modulated using QPSK, passed through an additive white Gaussian noise channel, demodulated, reconstructed, and then decrypted.

The experiment looks at how signal-to-noise ratio affects:

  • bit error rate
  • ciphertext corruption
  • decryption failure probability

Note: This is an educational project. It does not implement real ML-KEM, Kyber, or any standardized post-quantum cryptographic scheme. It is a toy simulator meant to connect the math behind lattice-style cryptography with signal processing ideas from electrical engineering.

Core Question

If encrypted data is transmitted through a noisy channel, how much noise can it take before decryption starts failing?

Motivation

A lot of cryptography projects stop at encryption and decryption. I wanted to go one step further and ask what happens after encryption, when the ciphertext has to be transmitted physically through a communication system.

Post-quantum cryptography is especially interesting to me because it takes linear algebra very seriously. Problems like Learning With Errors are built around the idea that certain noisy linear systems are computationally hard to reverse.

This project uses a simplified version of that idea. It is not trying to be secure, but it does show the structure:

b = A s + e mod q

That equation is what made the project interesting to me. It looks like linear algebra, but it also becomes cryptography once the noise term makes the system hard to cleanly invert.

Then I added the electrical engineering layer. Instead of treating ciphertext like abstract data, I send it through a simulated channel and measure how transmission noise affects the final decrypted result.

Mathematical Model

The toy cryptographic system is based on noisy linear measurements:

b = A s + e mod q

where:

  • A is a public random matrix
  • s is the secret vector
  • e is a small error vector
  • q is the modulus
  • b is the public noisy linear measurement

Encryption produces a ciphertext over integers modulo q. That ciphertext is then serialized into bits so it can be transmitted through the communication layer.

Engineering Pipeline

message bit
    ↓
toy LWE encryption
    ↓
ciphertext vector
    ↓
binary serialization
    ↓
QPSK modulation
    ↓
AWGN noisy channel
    ↓
QPSK demodulation
    ↓
ciphertext reconstruction
    ↓
LWE decryption
    ↓
decryption success/failure analysis

Repository Structure

lwe-wireless-crypto-cpp/
│
├── CMakeLists.txt
├── README.md
├── LICENSE
├── .gitignore
│
├── include/
│   ├── Types.hpp
│   ├── LWE.hpp
│   ├── QPSK.hpp
│   ├── Channel.hpp
│   └── Utils.hpp
│
├── src/
│   ├── main.cpp
│   ├── LWE.cpp
│   ├── QPSK.cpp
│   ├── Channel.cpp
│   └── Utils.cpp
│
├── scripts/
│   └── plot_results.py
│
├── docs/
│   └── project_report.md
│
└── results/
    └── .gitkeep

Build Instructions

Requirements

  • C++17 compiler
  • CMake 3.16 or newer

Build

mkdir build
cd build
cmake ..
cmake --build .

Run

From the project root:

./build/lwe_wireless_crypto results/snr_results.csv

Or from the build folder:

./lwe_wireless_crypto ../results/snr_results.csv

The program prints the results as a CSV table and also writes them to:

results/snr_results.csv

Example Output

The exact numbers will change each time because the key generation and channel noise are random.

snr_db,bit_error_rate,decryption_failure_rate
0,0.156000,0.900000
2,0.102000,0.830000
4,0.058000,0.610000
6,0.023000,0.340000
8,0.007000,0.130000
10,0.002000,0.040000
12,0.000400,0.006000
14,0.000000,0.000000
16,0.000000,0.000000
18,0.000000,0.000000
20,0.000000,0.000000

Plot Results

After generating the CSV file, run:

python scripts/plot_results.py

This creates:

results/ber_vs_snr.png
results/decryption_failure_vs_snr.png

What This Project Shows

This project brings together:

  • modular arithmetic
  • matrix-vector multiplication
  • toy lattice-based cryptography
  • C++ systems programming
  • QPSK digital modulation
  • AWGN channel modeling
  • signal-to-noise ratio experiments
  • bit error rate analysis
  • decryption failure analysis

The part I found most interesting is that the same ciphertext can be mathematically valid at the cryptography level, but still fail because the signal layer corrupts the transmitted bits.

That makes the project feel less like “just encryption” and more like a secure communication system.

Limitations

This project is intentionally simplified.

It does not provide real cryptographic security, and it should not be used as a real encryption library.

Main limitations:

  • parameters are small
  • the noise distribution is simplified
  • the message is currently one bit
  • there is no real key encapsulation mechanism
  • there is no constant-time implementation
  • there is no side-channel protection
  • it does not implement a standardized post-quantum algorithm

Future Improvements

Some directions I would like to add next:

  • forward error correction
  • BPSK, QPSK, and 16-QAM comparison
  • Rayleigh fading channel model
  • larger LWE dimensions
  • multi-bit message encoding
  • runtime benchmarking as parameters grow
  • Python notebooks for visualization
  • possible embedded or hardware-oriented version

Resume Bullet

Built a C++ secure communication simulator that combines toy Learning With Errors-style cryptography with QPSK/AWGN channel modeling. Implemented modular matrix-vector operations, ciphertext serialization, and SNR sweep experiments to study bit error rate and decryption failure probability.

References

  • NIST FIPS 203: Module-Lattice-Based Key-Encapsulation Mechanism Standard
  • Learning With Errors and lattice-based cryptography background
  • Digital communication concepts: QPSK modulation, AWGN channels, and bit error rate analysis

About

C++ secure communication simulator combining toy LWE-style cryptography, QPSK modulation, AWGN channel modeling, and SNR-based reliability analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages