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
encoding_layer_entropy.py File Reference

Stored-bytes vs. More...

Go to the source code of this file.

Namespaces

namespace  encoding_layer_entropy
 

Functions

 encoding_layer_entropy.assert_bijection (perm, label)
 Verify a table is a permutation of Z_q.
 
 encoding_layer_entropy.log2_factorial (n)
 log2(n!) via lgamma, which stays finite where n! overflows.
 
 encoding_layer_entropy.main ()
 Measure the encoding layer as built by whitebox_encoded.build_encodings(), split measured from analytic, and write results/encoding_layer_entropy.json.
 
 encoding_layer_entropy.measure_determinacy_degree (E, rng)
 Entry-determinacy degree of a Z_q bijection, measured by reconstruction.
 
 encoding_layer_entropy.measure_omitted_entry_predictability (E, rng)
 Predictability of an omitted entry when q//2 entries of a bijection are retained, i.e.
 
 encoding_layer_entropy.verify_inverses_derivable (E, Einv)
 Reconstruct every inverse from its forward permutation and compare.
 

Variables

float encoding_layer_entropy.EXPECTED_ENTROPY_LOG2_BYTES = 20.06
 
int encoding_layer_entropy.EXPECTED_INDEPENDENT = 256
 
float encoding_layer_entropy.EXPECTED_OVERSTATEMENT = 3.12
 
int encoding_layer_entropy.EXPECTED_STORED_BYTES = 3_408_896
 
int encoding_layer_entropy.PRED_GUESSES_PER_TABLE = 1000
 
int encoding_layer_entropy.SEED = 42
 

Detailed Description

Stored-bytes vs.

key-entropy accounting for the output-encoding sublayer, and its entry-determinacy degree as the positive side of the dichotomy.

The encoding sublayer is built by whitebox_encoded.build_encodings(), so the layer is measured exactly as this repository constructs it rather than as a reimplementation. Four Z_q-permutation tables are stored per NTT factor (two forward encodings and their two inverses), but each inverse is a deterministic function of its forward permutation, so only half the stored tables carry key material. The script (1) measures the stored footprint from the built arrays' .nbytes, (2) reconstructs every inverse from its forward permutation and asserts equality, establishing the independent-bijection count as half the stored table count, (3) computes the key entropy H = (independent count) * log2(q!) by lgamma, (4) reports the overstatement factor stored/entropy, and (5) measures the omitted-entry predictability of the built bijections against the 1/q floor.

Result carried by this script: the sublayer is entry-unpredictable. Retaining q//2 entries of a bijection leaves every omitted entry uniform over the 1665 unused residues, i.e. a predictability of ~2/q, only a factor two above the unconditional 1/q floor; the entry-determinacy degree is d = q-1, since a bijection is pinned only once a single residue remains. This is the POSITIVE side of the entry-determinacy dichotomy, opposite the algebraically-determined baked tables whose d = 1.

Note
The stored footprint is NOT secret-bearing material. Storage exceeds key entropy by the measured overstatement factor because the inverses are derived and because a Z_q permutation stores q uint16 entries while carrying only log2(q!) bits. Reporting the stored megabytes as entropy overstates the key material.
MEASURED: footprint, inverse derivability, independent count, omitted-entry predictability. ANALYTIC: log2(q!) key entropy and the floors it is compared to. The two are emitted under separate top-level keys and never mixed.
Deterministic (seed 42); writes results/encoding_layer_entropy.json.

Output Files

Usage

Author
Ugur Coruh

Definition in file encoding_layer_entropy.py.