PQ-WB-KEM: Toward a White-Box Construction of ML-KEM-768 with Arithmetic Masking for M2M Communications
Mathematics (MDPI) — Under review, 2026
Author
Ugur Coruh - Recep Tayyip Erdogan University
Project Structure
research-whitebox-mlkem_supplementary/
├── README.md
├── README-supplementary.md # Archive guide & reproduction instructions
├── LICENSE
├── code/ # Implementation & documentation
│ ├── requirements.txt # Python dependencies
│ ├── python/ # Experiment & benchmark scripts
│ │ ├── run_all.py # Run every experiment -> results/
│ │ ├── baseline_benchmark.py # Reference ML-KEM-768 timing (liboqs)
│ │ ├── wallclock_ci.py # Wall-clock N=20 mean±CI (two environments)
│ │ ├── dca_simulation.py # DCA resistance simulation
│ │ ├── share_statistics.py # Masking share statistics
│ │ ├── overhead_calculation.py # White-box overhead ratio
│ │ ├── scaling_analysis.py # 512/768/1024 scaling projections
│ │ ├── concrete_security_bounds.py # Bit-security estimates
│ │ ├── entry_determinacy.py # Entry-determinacy degree d, budget M*, PRF control
│ │ ├── table_extraction_witness.py # 1,536 B (B) / 0 B (A) extraction witness
│ │ ├── encoding_layer_entropy.py # Encoding sublayer: storage vs entropy
│ │ ├── algebraic_attack_analysis.py # Algebraic attack resistance
│ │ ├── obfuscation_storage.py # Shuffle (3 KB) + masking (0 B) storage; deployment total
│ │ ├── whitebox_reference.py # Base-multiply table footprints (A/B) + NTT correctness
│ │ ├── whitebox_encoded.py # Encoding sublayer + encoding-unaware recovery
│ │ └── arm64_aggregate.py # aarch64/QEMU N=20 mean±CI (separate; not in run_all)
│ ├── sage/ # SageMath NTT verification
│ ├── c/ # C micro-benchmarks (primitive, cache)
│ └── docs/ # Doxygen output (HTML/LaTeX) + config
├── results/ # Experimental results
│ ├── SIMULATION_SUMMARY.md # Human-readable results summary
│ ├── experiment_summary.json # Aggregate run manifest
│ └── *.json # Per-experiment measurements
└── ... # (this archive ships the full code/ and results/ trees)
The development repository additionally carries submission, reference, and review folders that are not part of this archive.
Key Results
| Metric | Value |
| ARM64 QEMU Decaps (baseline) | 0.310 ms (N=20 mean) |
| Masking overhead (measured, N=20) | ~1.55× (Win 1.55±0.08, WSL 1.60±0.03); baked-table lookup + share recombination, mask-RNG excluded — a lower bound |
| White-Box Overhead (deployment projection) | ~47× (native-C 4.30× protected primitive × ~11× cache, Construction B); ~17× (~1.55× RNG-excluded masking floor × ~11× cache) is the explicitly-labeled lower bound |
| Protected Decaps (projection) | ~10 ms (7–14 ms with the ±35% band) on the x86-64 host (0.213 ms × 47); no ARM-device measurement; Construction A is not projected |
| Storage (core tables) | 25.57 MB (A) / 11.08 MB (B); deployed 11-26 MB (measured) |
| DCA Resistance (3-share) | ρ_max = 0.011 at 10,000 traces (vs ~0.86 unmasked) |
Wall-clock note. Timing/overhead figures are means ± 95% CI over N=20 runs, measured in two environments (Windows-native + WSL/Linux) on an i9-13980HX; liboqs absolute times are build- and platform-specific, so the ratios are the comparable metric. See code/python/wallclock_ci.py and results/wallclock_statistics_{windows,wsl}.json. Deterministic results (DCA ρ, masking χ², 768-recovery, footprints, NTT) reproduce exactly.
Concrete Security Estimates
| Property | Measured Value | Estimate |
| DCA resistance | ρ_max = 0.011 at 10,000 traces (near 1/√N = 0.01 floor) | ~2^12 first-order trace-complexity estimate (1/ρ²; not a security proof) |
| Core table footprint | 25.57 MB (A) / 11.08 MB (B) core tables | ~2^24.6 (A) / ~2^23.4 (B) byte-reads to copy the core; a deployment size, not a security figure |
| Table extraction (measured) | 1,536 B (B) / 0 B (A) of table reads reproduce the functionality | no bound; the budget carries no table-size term |
| Timing (constant-time) | no secret-dependent branches/variable-latency | structural; cache-line constant-time not claimed |
ML-KEM Parameter Scaling (Projections)
| Parameter | ML-KEM-512 | ML-KEM-768 | ML-KEM-1024 |
| Module rank k | 2 | 3 | 4 |
| NIST Level | 1 | 3 | 5 |
| NTT tables | 128 | 128 | 128 |
| Construction-B core | ~9 MB | ~11 MB | ~14 MB |
| Overhead | ~30× | ~47× | ~64× |
| Decaps time | 4-9 ms | 7-14 ms | 9-18 ms |
The overhead row reports deployment projections computed by scaling_analysis.py directly from the ~47× ML-KEM-768 anchor with an assumed k^1.1 superlinear rule (computed, not measured). The size row is the Construction-B core (base multiply plus the 3.41 MB encoding sublayer), which scales with module rank k. Construction A is k-independent at a 25.57 MB core (a ~26 MB deployment total, the same for every parameter set), so the deployment envelope is 11-26 MB and the security-level ordering is carried by the Construction-B core.
Higher-Order Masking Trade-offs
| Masking | Memory | Performance | Security |
| 3-share | 1.0× | 1.0× | ~2^12* |
| 5-share | 2.8× | 2.8× | ~2^24* |
| 7-share | 5.4× | 5.4× | ~2^36* |
*Estimated DCA order (noise-floor lower bound), not a security proof.
Both columns are relative to the 3-share configuration and both scale as O(t²), so they coincide; scaling_analysis.py reports the un-normalized performance factors as 1.45× (3-share), 4.03× (5-share) and 7.91× (7-share). Applied to the ~17× RNG-excluded floor, 5-share projects to a ~47× floor; applied to the ~47× deployment headline (native-C 4.30× × ~11× cache), the 5-share configuration scales it by the same ~2.8× factor.
Table of Contents
- Abstract
- System Requirements
- Installation Steps
- Running Experiments
- Interpreting Results
- Troubleshooting
Abstract
This paper is a feasibility study (design-space exploration) of white-box techniques for ML-KEM-768 (FIPS 203); the two constructions deliver DCA resistance of share observation and division-timing freedom in hostile environments — it does not claim key confidentiality against the full white-box adversary:
- Table-Based NTT: Precomputed lookup tables for all 128 irreducible degree-2 factors of X^256 + 1
- 3-Share Arithmetic Masking: Empirical near-noise-floor resistance to DCA (Differential Computation Analysis); ρ_max = 0.011 at 10,000 traces, not a security proof
- 25.57 MB (A) / 11.08 MB (B) Core Table Size: the artifact a deployment ships and holds resident — a size, not an adversarial cost (a measured 1,536 bytes of table reads regenerate Construction B's baked set bit-exactly; Construction A needs none)
- ~47× Deployment Overhead (projection): native-C 4.30× protected primitive × ~11× cache, Construction B; the ~17× figure (~1.55× RNG-excluded masking floor × ~11× cache) is an explicitly-labeled lower bound
System Requirements
| Requirement | Minimum | Recommended |
| Operating System | Windows 10 + WSL2, Linux, or macOS | Ubuntu 20.04+ |
| Python | 3.10 | 3.12 |
| RAM | 4 GB | 8 GB |
| Disk | 500 MB | 2 GB |
Software Dependencies
- Python 3.10-3.12 (not the free-threaded 3.13t build)
- NumPy, SciPy, tqdm, cryptography (all installed by
code/requirements.txt)
- SageMath 9.0+ (optional, for NTT verification; a preparsed Python mirror ships too)
- liboqs 0.9+ (optional, only for the baseline benchmark)
- QEMU (optional, only for the ARM64 emulation baseline)
Installation Steps
Step 1: WSL2 Installation (Windows Only)
Open PowerShell as Administrator:
wsl --install -d Ubuntu-20.04
Restart and log into WSL:
Step 2: System Update
sudo apt-get update && sudo apt-get upgrade -y
Step 3: Python Installation
# Python and pip
sudo apt-get install -y python3 python3-pip python3-venv
# Dependencies -- Option A: pip + requirements.txt
pip3 install -r code/requirements.txt
# Dependencies -- Option B: conda (creates the 'pq-wb-kem' env)
conda env create -f code/environment.yml
conda activate pq-wb-kem
# Verification
python3 --version
python3 -c "import numpy; import scipy; import tqdm; print('OK')"
Step 4: SageMath Installation
# SageMath installation (may take 5-10 minutes)
sudo apt-get install -y sagemath
# Verification
sage --version
# Expected: SageMath version 9.x
Step 5: liboqs Installation
# Dependencies
sudo apt-get install -y cmake gcc g++ libssl-dev
# Clone and build liboqs
cd ~
git clone https://github.com/open-quantum-safe/liboqs.git
cd liboqs
mkdir build && cd build
cmake -DBUILD_SHARED_LIBS=ON ..
make -j$(nproc)
sudo make install
sudo ldconfig
# Python wrapper
pip3 install liboqs-python
# Verification
python3 -c "import oqs; print(oqs.get_enabled_kem_mechanisms()[:3])"
Step 6: QEMU Installation (for ARM64 Emulation)
# QEMU and ARM64 cross-compiler
sudo apt-get install -y qemu-user qemu-user-static gcc-aarch64-linux-gnu
# Verification
qemu-aarch64 --version
Running Experiments
Experiment 1: NTT Mathematical Verification
Purpose: Verifies that X^256 + 1 factors into exactly 128 irreducible degree-2 polynomials in Z_3329[X].
Theory:
- ML-KEM uses q = 3329 where 256 | (q-1)
- X^256 + 1 has 256 roots in Z_3329
- These roots pair to give 128 degree-2 irreducible factors
Run:
cd /mnt/c/Users/YOUR_USERNAME/Desktop/Makale/research-whitebox-mlkem_supplementary/code/sage
sage ntt_verification.sage
Expected Output:
============================================================
NTT MATHEMATICAL VERIFICATION
White-Box ML-KEM Implementation
============================================================
[1] PARAMETER VERIFICATION
--------------------------------------------------
q = 3329 (ML-KEM modulus)
n = 256 (polynomial degree)
ζ = 17 (primitive 256th root of unity)
Verification: ζ^256 ≡ 1 (mod q): True
Verification: ζ^128 ≢ 1 (mod q): True
[2] FACTORIZATION OF X^256 + 1
--------------------------------------------------
Number of irreducible factors: 128
All factors have degree 2: True
Sample factors:
Factor 0: x^2 + 3326*x + 1
Factor 1: x^2 + 3*x + 1
...
[3] NTT DOMAIN STRUCTURE
--------------------------------------------------
Ring: Z_3329[X]/(X^256 + 1)
Decomposes into: 128 copies of Z_3329[X]/(degree-2 irreducible)
Each component is: GF(3329^2)
============================================================
VERIFICATION COMPLETE: ALL CHECKS PASSED
============================================================
Result File: results/ntt_verification.json
Experiment 2: DCA Attack Simulation
Purpose: Demonstrates that 3-share masking provides 2nd-order DCA resistance of share observation.
Theory:
- Standard (unmasked) implementation leaks information through computation traces
- 3-share masking: s = s₁ + s₂ + s₃ (mod q)
- Attacker observing any 2 shares learns nothing about s
- Requires 3rd-order DCA (exponentially harder) to break
Run:
cd /mnt/c/Users/YOUR_USERNAME/Desktop/Makale/research-whitebox-mlkem_supplementary/code/python
python3 dca_simulation.py
Expected Output:
============================================================
DCA ATTACK SIMULATION
White-Box ML-KEM Implementation
============================================================
[1] UNMASKED IMPLEMENTATION
--------------------------------------------------
Simulating 10000 traces...
Correlation attack on coefficient 0:
True value: 1847
Best guess: 1847
Correlation: 0.8534
Attack success: TRUE (correlation > 0.5)
[2] 3-SHARE MASKED IMPLEMENTATION
--------------------------------------------------
Simulating 10000 traces...
Correlation attack on coefficient 0:
True value: 1847
Best guess: 2891 (wrong)
Correlation: 0.0113
Attack success: FALSE (correlation < 0.1)
[3] STATISTICAL ANALYSIS
--------------------------------------------------
Unmasked correlations: mean=0.8534, std=0.0089
Masked correlations: mean=0.0113, std=0.0127
t-test p-value: 1.23e-198
Effect size (Cohen's d): 89.4
============================================================
SUMMARY
============================================================
Unmasked: VULNERABLE (correlation attack succeeds)
3-share masked: SECURE (correlation ≈ 0)
Theorem Verified: 3-share masking provides 2nd-order DCA resistance of share observation
============================================================
Result File: results/dca_simulation.json
Experiment 3: liboqs Baseline Benchmark
Purpose: Measures standard ML-KEM-768 performance for overhead calculation.
Run:
cd /mnt/c/Users/YOUR_USERNAME/Desktop/Makale/research-whitebox-mlkem_supplementary/code/python
python3 baseline_benchmark.py
Expected Output:
============================================================
ML-KEM-768 BASELINE BENCHMARK
Using liboqs (Open Quantum Safe)
============================================================
Algorithm: ML-KEM-768
NIST Level: 3
Public Key: 1184 bytes
Secret Key: 2400 bytes
Ciphertext: 1088 bytes
Shared Secret: 32 bytes
Running 10000 iterations...
--------------------------------------------------
RESULTS
--------------------------------------------------
KeyGen: 0.137 ms (σ=0.006)
Encaps: 0.161 ms (σ=0.033)
Decaps: 0.194 ms (σ=0.012)
============================================================
Result File: results/baseline_benchmark.json
Experiment 4: Overhead Calculation
Purpose: Computes the overhead bookkeeping for Construction B: the ~47× deployment projection (native-C 4.30× × ~11× cache) and its ~17× RNG-excluded lower bound.
Run:
cd /mnt/c/Users/YOUR_USERNAME/Desktop/Makale/research-whitebox-mlkem_supplementary/code/python
python3 overhead_calculation.py
Expected Output:
============================================================
PQ-WB-KEM OVERHEAD ANALYSIS
Paper 1: White-Box ML-KEM Implementation
============================================================
[1] BASELINE BENCHMARK (liboqs ML-KEM-768 x86_64)
--------------------------------------------------
KeyGen: 0.1374 ms
Encaps: 0.1614 ms
Decaps: 0.1943 ms
[2] ARM64 BENCHMARK (qemu-aarch64 user-mode emulation on the x86-64 host)
--------------------------------------------------
KeyGen: 0.215 ms
Encaps: 0.254 ms
Decaps: 0.310 ms
(instruction-level behaviour of the emulated ISA; the host CPU does the
work, so these are not any ARM device's wall-clock)
[3] WHITE-BOX DECAPSULATION PROJECTION (construction B)
--------------------------------------------------
Native primitive:4.296x (protected/direct, RNG included; primitive_bench_x86.json)
Masking floor: 1.5453x (N=20 wall-clock mean, mask-generation RNG excluded)
Cache bracket: 1.895x .. 63.281x (measured)
Cache factor: 10.95x (geometric mean of the bracket)
Deployment: 47x = round(4.296 x 10.95) (headline)
Floor: 17x = round(1.5453 x 10.95) (RNG-excluded lower bound)
WB Decaps: 9.13 ms (x86-64 baseline x deployment factor)
[4] MANUSCRIPT CROSS-CHECK (x86-64 host anchored; no ARM-device wall-clock)
--------------------------------------------------
Host (x86-64) baseline decaps: 0.213 ms (N=20 portable mean)
Derived at 47x: 10.011 ms
Manuscript reports: ~10 ms (7--14 ms with the +-35% band)
============================================================
SUMMARY
============================================================
Deployment overhead: 47x (construction B, decapsulation only)
Model: 4.30x native protected primitive x 11.0x cache
Floor: 17x (1.55x RNG-excluded masking x 11.0x cache);
the cache term is a mid-estimate of a measured bracket that spans
1.9x to 63.3x. The product is an analytical projection,
not an end-to-end white-box measurement.
Result File: results/overhead_calculation.json
Experiment 5: ML-KEM Scaling Analysis
Purpose: Verifies scaling projections for ML-KEM-512/768/1024 parameter sets.
Run:
cd /mnt/c/Users/YOUR_USERNAME/Desktop/Makale/research-whitebox-mlkem_supplementary/code/python
python3 scaling_analysis.py
Expected Output:
======================================================================
ML-KEM WHITE-BOX SCALING ANALYSIS
======================================================================
1. ML-KEM PARAMETER SCALING
------------------------------------------------------------
Module rank k 2 3 4
NIST Level 1 3 5
------------------------------------------------------------
NTT tables 128 128 128
Table size 9--26 MB 11--26 MB 14--26 MB
Overhead 30x 47x 64x
Decaps time 4--9 ms 7--14 ms 9--18 ms
2. HIGHER-ORDER MASKING ANALYSIS
------------------------------------------------------------
3-share -> 5-share upgrade:
Memory overhead: 2.78x (11.1 MB -> 30.8 MB, construction B)
Performance overhead: 4.03x
Security: 2^12.9 -> 2^24 (+12 bits)
3. PAPER VALUES VERIFICATION
------------------------------------------------------------
ML-KEM-768 NTT tables 128 128 MATCH
5-share memory factor 2.8x 2.78x CLOSE
5-share perf factor 4x 4.03x CLOSE
======================================================================
SCALING ANALYSIS COMPLETE
======================================================================
Result File: results/scaling_analysis.json
Experiment 6: Concrete Security Bounds
Purpose: Calculates engineering estimates (DCA noise-floor lower bound, core table footprint); the manuscript reports the footprint as a deployment size and does not convert DCA/timing into bit-security.
Run:
cd /mnt/c/Users/YOUR_USERNAME/Desktop/Makale/research-whitebox-mlkem_supplementary/code/python
python3 concrete_security_bounds.py
Expected Output:
======================================================================
CONCRETE SECURITY BOUNDS CALCULATOR
PQ-WB-KEM: White-Box ML-KEM-768
Paper: MDPI Mathematics
======================================================================
1. DCA (Differential Computation Analysis) RESISTANCE
----------------------------------------------------------------------
Masking shares: 3
Measured correlation (rho): 0.011255
Sampling-noise floor (1/sqrt N): 0.01000 (rho below floor: False)
Traces for first-order (1/rho^2): 7894
First-order estimate: ~2^12.9 traces (rho at face value)
Non-detection lower bound: >= 2^13.3 traces
>> REPORTED (first-order estimate, not a proof): ~2^12
2. CORE TABLE FOOTPRINT (engineering size, not a security bound)
----------------------------------------------------------------------
Construction A (shared) : 25,573,378 B = 25.57 MB -> ~2^24.6 byte-reads to copy
Construction B (baked) : 11,078,912 B = 11.08 MB -> ~2^23.4 byte-reads to copy
A size, not a security bound: the core is regenerable from |s_hat| (entry-determinacy degree 1).
3. TIMING IMMUNITY (Side-Channel Resistance)
----------------------------------------------------------------------
Timing immunity is structural: constant-time table lookups with no secret-
dependent branch or variable-latency arithmetic. No coefficient-of-variation
or bit-security figure is measured or claimed for ML-KEM in this work.
======================================================================
SUMMARY: ENGINEERING SECURITY ESTIMATES (not proven bit-security)
======================================================================
| Property | Measured Value | Estimate |
|----------------------|-----------------------|--------------|
| DCA resistance | rho = 0.0113 | ~2^12 est. |
| Core footprint (A/B) | 25.6/11.1 MB tables | ~2^24.6/2^23.4 size |
| Timing (const-time) | no secret branches | structural |
======================================================================
The section-2 heading is the historical label of that print block; the figures under it are sizes, and the script's own JSON records them as core_footprint_* with is_security_bound: false.
Result File: results/concrete_security_bounds.json
Run All Experiments
cd /mnt/c/Users/YOUR_USERNAME/Desktop/Makale/research-whitebox-mlkem_supplementary/code/python
python3 run_all.py
This runs all 14 Python producers and generates a summary in results/experiment_summary.json.
Interpreting Results
Reproducible Results Summary
All values in the paper are computed by the scripts in this repository:
Key Security Properties
The construction achieves two security properties, each scoped to a strictly weaker adversary than the full white-box attacker of the paper's Definition 5: against that attacker the clear product coordinates p₀, p₁ are observable intermediates that yield linear equations for ŝ, so no key confidentiality is claimed.
- DCA Resistance (of share observation): 3-share masking ensures:
- I(s₁, s₂; s) = 0 (mutual information is zero); first-order leakage is exactly 0
- measured ρ_max = 0.011 at the 10,000-trace noise floor vs ρ ≈ 0.86 unmasked
- third- and higher-order DCA may succeed (3 shares protect only ≤ 2-order attacks)
- Division-Timing Freedom (in the protected base multiply): all arithmetic replaced with table lookups
- no secret-dependent branches, no data-dependent division or modular reduction
- KyberSlash's own divisions lie in the unprotected decode/compression path, outside this boundary; cache-line constant-time is not claimed
The core table footprint is not a third property. The 25.57 MB (A) / 11.08 MB (B) core is the artifact a deployment ships and holds resident, and it exceeds second-level cache — which is what makes an embedded deployment DRAM-bound and drives the ~11× cache factor — but it is not a cost any adversary is obliged to pay. Construction A's shared table M[x][y] = x·y mod q is a public function of q alone, regenerable in one line of code with no table read whatever, and its secret operand ŝ is a plain program array rather than table content. Construction B's caveat rests on a different premise: its baked tables are a deterministic function of ŝ, so an adversary who recovers ŝ regenerates all 7,670,016 bytes of them bit-exactly — unlike A, this needs the key first, making it a post-recovery collapse rather than a public-regenerability observation. Recovering that key from the tables costs a measured 1,536 bytes of table reads (768 entries), since each baked h(x) = ŝ·x is Z_q-linear in its public index and one read at any nonzero index returns ŝ by a modular inverse; the budget is the number of independent secret scalars times the bytes per entry, an expression with no table-size term, so enlarging the tables cannot repair it (results/table_extraction_witness.json, results/entry_determinacy.json).
The secret-bearing material is the output encoding together with the ~KB secret key, and there too the storage figure is not key material: of the 512 stored encoding tables only 256 are independent (each inverse is reconstructible from its forward map), so the sublayer carries 1.09 MB = 2^20.06 bytes of entropy while occupying 3.41 MB, overstating the secret-bearing material by a measured factor of 3.12 (results/encoding_layer_entropy.json).
Troubleshooting
Error: "No module named 'oqs'"
pip3 install liboqs-python
# If that fails, install from source:
cd ~/liboqs/build
cmake -DBUILD_SHARED_LIBS=ON -DOQS_BUILD_ONLY_LIB=ON ..
make -j$(nproc)
sudo make install
pip3 install liboqs-python
Error: "sage: command not found"
sudo apt-get install -y sagemath
# Alternative: use Conda
conda install -c conda-forge sage
Error: "libssl.so.1.1: cannot open"
sudo apt-get install -y libssl-dev
sudo ldconfig
QEMU is slow
Expected: qemu-aarch64 runs in user-mode emulation, translating every AArch64 instruction and executing it on the host CPU, so the benchmark takes far longer to complete than a native run. The ARM64 figures in results/arm64_benchmark.json are the emulated ISA's instruction-level behaviour, measured while the host CPU does the work — they are not any ARM device's wall-clock, and this repository derives no physical-device timing from them. A wall-clock figure for a given ARM board can only come from running the benchmark on that board; no such run is claimed here.
Theoretical Foundation
NTT Structure
Z_3329[X]/(X^256 + 1) ≅ ∏_{i=0}^{127} Z_3329[X]/(φᵢ(X))
where each φᵢ(X) is a degree-2 irreducible polynomial.
Masking Security Model
Secret s ∈ Z_q
↓
Split: s = s₁ + s₂ + s₃ (mod q)
↓
Property: I(s₁, s₂; s) = 0
↓
Result: 2nd-order DCA resistance
Citation
@article{coruh2026pqwbkem,
author = {Coruh, Ugur},
title = {PQ-WB-KEM: Toward a White-Box Construction of ML-KEM-768 with Arithmetic Masking for M2M Communications},
journal = {Mathematics (MDPI), under review},
year = {2026}
}
License
This research code is provided for academic purposes.