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 Namespace Reference

Functions

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

Variables

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

Function Documentation

◆ assert_bijection()

encoding_layer_entropy.assert_bijection (   perm,
  label 
)

Verify a table is a permutation of Z_q.

Parameters
permuint16 table of length q.
labelIdentifier used in the failure message.

Definition at line 94 of file encoding_layer_entropy.py.

Referenced by verify_inverses_derivable().

+ Here is the caller graph for this function:

◆ log2_factorial()

encoding_layer_entropy.log2_factorial (   n)

log2(n!) via lgamma, which stays finite where n! overflows.

Parameters
nNon-negative integer.
Returns
log2(n!) in bits.

Definition at line 80 of file encoding_layer_entropy.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

encoding_layer_entropy.main ( void  )

Measure the encoding layer as built by whitebox_encoded.build_encodings(), split measured from analytic, and write results/encoding_layer_entropy.json.

Definition at line 259 of file encoding_layer_entropy.py.

References whitebox_encoded.build_encodings(), log2_factorial(), main(), measure_determinacy_degree(), measure_omitted_entry_predictability(), and verify_inverses_derivable().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ measure_determinacy_degree()

encoding_layer_entropy.measure_determinacy_degree (   E,
  rng 
)

Entry-determinacy degree of a Z_q bijection, measured by reconstruction.

Parameters
EForward encodings, shape (components, 2, q).
rngSeeded NumPy generator.
Returns
Dict with the measured degree and both reconstruction checks.

Two probes bracket the degree. At q-1 retained entries the omitted one is forced: the residues consumed by the RETAINED entries leave exactly one unused, which must be the omitted image. At q-2 retained entries two residues remain for two omitted indices, so the best predictor is a coin flip. The table is therefore pinned at q-1 and not before: d = q-1. Both probes read only retained entries; the withheld image never enters the reconstruction.

Definition at line 196 of file encoding_layer_entropy.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ measure_omitted_entry_predictability()

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.

the M < S_tbl/2 budget regime.

Parameters
EForward encodings, shape (components, 2, q); only forward tables are probed.
rngSeeded NumPy generator.
Returns
Dict of measured predictability quantities.

The strongest predictor is bijectivity-aware: an omitted entry must lie in the residues not consumed by the retained ones, so it guesses uniformly over that residual candidate set. Both the empirical hit rate and the mean candidate-set size are measured.

Definition at line 141 of file encoding_layer_entropy.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ verify_inverses_derivable()

encoding_layer_entropy.verify_inverses_derivable (   E,
  Einv 
)

Reconstruct every inverse from its forward permutation and compare.

Parameters
EForward encodings, shape (components, 2, q).
EinvStored inverses, shape (components, 2, q).
Returns
Number of stored inverse tables shown to be derived (non-independent).

Derivability is what demotes the stored table count to the independent count: an inverse carries no key material of its own.

Definition at line 114 of file encoding_layer_entropy.py.

References assert_bijection().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ EXPECTED_ENTROPY_LOG2_BYTES

float encoding_layer_entropy.EXPECTED_ENTROPY_LOG2_BYTES = 20.06

Definition at line 76 of file encoding_layer_entropy.py.

◆ EXPECTED_INDEPENDENT

int encoding_layer_entropy.EXPECTED_INDEPENDENT = 256

Definition at line 75 of file encoding_layer_entropy.py.

◆ EXPECTED_OVERSTATEMENT

float encoding_layer_entropy.EXPECTED_OVERSTATEMENT = 3.12

Definition at line 77 of file encoding_layer_entropy.py.

◆ EXPECTED_STORED_BYTES

int encoding_layer_entropy.EXPECTED_STORED_BYTES = 3_408_896

Definition at line 74 of file encoding_layer_entropy.py.

◆ PRED_GUESSES_PER_TABLE

int encoding_layer_entropy.PRED_GUESSES_PER_TABLE = 1000

Definition at line 70 of file encoding_layer_entropy.py.

◆ SEED

int encoding_layer_entropy.SEED = 42

Definition at line 69 of file encoding_layer_entropy.py.