PQ-WB-KEM: White-Box ML-KEM-768 1.0
PQ-WB-KEM: Toward a White-Box Construction of ML-KEM-768 with Arithmetic Masking for M2M Communications - Mathematics (MDPI)
Loading...
Searching...
No Matches
algebraic_attack_analysis.py File Reference

Algebraic attack resistance analysis for white-box ML-KEM. More...

Go to the source code of this file.

Classes

class  algebraic_attack_analysis.AlgebraicAttackResult
 Result of an algebraic attack attempt. More...
 

Namespaces

namespace  algebraic_attack_analysis
 

Functions

 algebraic_attack_analysis._bitrev7 (k)
 Bit-reversal of a 7-bit index (FIPS-203 NTT twiddle order).
 
AlgebraicAttackResult algebraic_attack_analysis.algebraic_attack_basic (np.ndarray secret_ntt, int num_queries=256)
 Basic algebraic attack exploiting NTT linearity.
 
AlgebraicAttackResult algebraic_attack_analysis.algebraic_attack_protected (np.ndarray secret_ntt, np.ndarray mixing_key, np.ndarray permutation, np.ndarray inverse_permutation, int num_queries=1000)
 Attempt the algebraic attack against the protected implementation.
 
Dict algebraic_attack_analysis.analyze_attack_complexity (int num_trials=10)
 Analyze attack complexity across unprotected/protected scenarios.
 
np.ndarray algebraic_attack_analysis.apply_nonlinear_mixing (np.ndarray ntt_poly, np.ndarray mixing_key)
 Apply nonlinear mixing (cubic map) to break linearity.
 
np.ndarray algebraic_attack_analysis.apply_random_shuffling (np.ndarray ntt_poly, np.ndarray permutation)
 Apply coefficient shuffling by a permutation.
 
Dict algebraic_attack_analysis.benchmark_countermeasure_overhead ()
 Benchmark runtime overhead of the countermeasures vs baseline.
 
np.ndarray algebraic_attack_analysis.compute_zeta_powers ()
 Compute powers of zeta for the NTT.
 
Tuple[np.ndarray, np.ndarray] algebraic_attack_analysis.extract_linear_equations (List[Tuple[np.ndarray, np.ndarray]] input_output_pairs, int target_coefficients=256)
 Extract linear equations from input-output pairs.
 
Dict algebraic_attack_analysis.full_module_recovery (int num_queries=3, int seed=42)
 Full ML-KEM-768 secret recovery on the unprotected white-box base multiply.
 
np.ndarray algebraic_attack_analysis.generate_secret_key ()
 Generate a secret key with CBD(eta=2) distribution.
 
 algebraic_attack_analysis.main ()
 Run the full analysis and write results JSON.
 
int algebraic_attack_analysis.mod_inverse (int a, int m)
 Modular inverse of a mod m (prime m, via Fermat).
 
np.ndarray algebraic_attack_analysis.ntt_forward (np.ndarray poly)
 Forward NTT: standard domain to NTT domain.
 
np.ndarray algebraic_attack_analysis.ntt_inverse (np.ndarray ntt_poly)
 Inverse NTT: NTT domain to standard domain.
 
np.ndarray algebraic_attack_analysis.ntt_multiply (np.ndarray a_ntt, np.ndarray b_ntt)
 Multiply two polynomials in the NTT domain.
 
np.ndarray algebraic_attack_analysis.simulate_protected_whitebox (np.ndarray secret_ntt, np.ndarray ciphertext_ntt, np.ndarray mixing_key, np.ndarray permutation, np.ndarray inverse_permutation)
 Simulate a protected white-box: mix and shuffle the tabulated secret, multiply.
 
np.ndarray algebraic_attack_analysis.simulate_whitebox_table_lookup (np.ndarray secret_ntt, np.ndarray ciphertext_ntt)
 Simulate a white-box table lookup returning s * c in the NTT domain.
 
Tuple[Optional[np.ndarray], bool] algebraic_attack_analysis.solve_linear_system_mod_q (np.ndarray A, np.ndarray b, int q=Q)
 Solve Ax = b mod q by Gaussian elimination.
 
 algebraic_attack_analysis.solve_mod_q (np.ndarray A, np.ndarray b, int q)
 Solve A x = b over Z_q by Gauss-Jordan elimination.
 

Variables

int algebraic_attack_analysis.ETA = 2
 
int algebraic_attack_analysis.K = 3
 
int algebraic_attack_analysis.N = 256
 
int algebraic_attack_analysis.Q = 3329
 
int algebraic_attack_analysis.ZETA = 17
 
np.ndarray algebraic_attack_analysis.ZETA_POWERS = compute_zeta_powers()
 

Detailed Description

Algebraic attack resistance analysis for white-box ML-KEM.

Exploits NTT linearity (BGE-style, Billet-Gilbert-Ech-Chatbi, SAC 2004) to recover the secret key, then evaluates nonlinear-mixing and shuffling countermeasures.

Note
Shuffling alone is a linear permutation and does not break the algebraic attack.
Wall-clock timing is build/platform-dependent; for robust reporting use wallclock_ci.py, which aggregates N=20 runs (mean +/- 95% CI) per environment (absolute liboqs times are build- and platform-specific; the dimensionless overhead ratios are the comparable metric).

Output Files

Usage

Author
Ugur Coruh

Definition in file algebraic_attack_analysis.py.