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

Classes

class  _CountingArray
 Array proxy that charges every indexed entry to a read budget. More...
 
class  ReadCountingTables
 Baked-table view that counts every entry fetched by the extractor. More...
 

Functions

 _bit_exact (a, b)
 Bit-exact comparison of two baked table sets.
 
 _build_encoding_sublayer (seed)
 Output-encoding sublayer: per factor two random Z_q bijections plus their two derived inverses.
 
 _invertibility_sweep (tabs, sh)
 Check that every nonzero index recovers the baked scalar: s0 = h0[x]*x^-1.
 
 _measure_determinacy_degree_baked (seed_a, seed_b)
 Measure Construction B's entry-determinacy degree d instead of asserting it.
 
 _secret_polys (seed)
 ML-KEM-768 secret: K polys, coefficients uniform over {-2..2} (the CBD support; the extraction budget is distribution-independent), in the NTT domain.
 
 _stored_bytes (tabs)
 Serialized footprint of one polynomial's baked table set.
 
 extract_and_regenerate (view, gammas)
 Read the determining entries of each baked table and rebuild the full set.
 
 main ()
 Run the entry-determinacy witness on both constructions and write JSON.
 

Variables

int ENC_INDEPENDENT_PER_FACTOR = 2
 
int ENC_TABLES_PER_FACTOR = 4
 
 m
 
 reads
 
int SEED = 42
 
tuple SEEDS = (42, 1337, 20250714, 7, 99)
 
int Z_TRIALS = 1000
 

Function Documentation

◆ _bit_exact()

table_extraction_witness._bit_exact (   a,
  b 
)
protected

Bit-exact comparison of two baked table sets.

Parameters
aFirst table set;
bSecond table set.
Returns
(all_equal, pairs_compared, pairs_exact).

Definition at line 236 of file table_extraction_witness.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ _build_encoding_sublayer()

table_extraction_witness._build_encoding_sublayer (   seed)
protected

Output-encoding sublayer: per factor two random Z_q bijections plus their two derived inverses.

Parameters
seedDeterministic seed.
Returns
(tables, independent_bijections) with tables a list of uint16 arrays.

Definition at line 138 of file table_extraction_witness.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ _invertibility_sweep()

table_extraction_witness._invertibility_sweep (   tabs,
  sh 
)
protected

Check that every nonzero index recovers the baked scalar: s0 = h0[x]*x^-1.

Parameters
tabsBaked tables for one polynomial;
shThe polynomial's secret.
Returns
(indices_tested_per_table, indices_inverted_per_table_min, total_inverted).

Definition at line 250 of file table_extraction_witness.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ _measure_determinacy_degree_baked()

table_extraction_witness._measure_determinacy_degree_baked (   seed_a,
  seed_b 
)
protected

Measure Construction B's entry-determinacy degree d instead of asserting it.

Sufficiency: one charged read per baked table regenerates it bit-exactly. Minimality: two distinct secrets yield different tables, so zero entries cannot determine the family and d > 0. The two results pin d exactly.

Parameters
seed_aFirst secret seed;
seed_bIndependent secret seed.
Returns
(d, reads_per_table, one_read_sufficient, zero_reads_insufficient).

Definition at line 194 of file table_extraction_witness.py.

References _secret_polys().

Referenced by main().

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

◆ _secret_polys()

table_extraction_witness._secret_polys (   seed)
protected

ML-KEM-768 secret: K polys, coefficients uniform over {-2..2} (the CBD support; the extraction budget is distribution-independent), in the NTT domain.

Parameters
seedDeterministic seed.
Returns
List of K full-range NTT-domain secret polynomials.

Definition at line 71 of file table_extraction_witness.py.

Referenced by _measure_determinacy_degree_baked(), and main().

+ Here is the caller graph for this function:

◆ _stored_bytes()

table_extraction_witness._stored_bytes (   tabs)
protected

Serialized footprint of one polynomial's baked table set.

Parameters
tabsList of (h0, h1, h2) uint16 triples.
Returns
Total bytes from the built arrays' .nbytes.

Definition at line 129 of file table_extraction_witness.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ extract_and_regenerate()

table_extraction_witness.extract_and_regenerate (   view,
  gammas 
)

Read the determining entries of each baked table and rebuild the full set.

h(x) = shat*x is Z_q-linear, so the entry at the unit index is the baked scalar; h2 needs no extra read because gamma_i is public.

Parameters
viewReadCountingTables over the target table set.
gammasPublic component twiddles.
Returns
List of regenerated (h0, h1, h2) uint16 triples.

Definition at line 169 of file table_extraction_witness.py.

Referenced by main().

+ Here is the caller graph for this function:

◆ main()

table_extraction_witness.main ( void  )

Run the entry-determinacy witness on both constructions and write JSON.

Definition at line 270 of file table_extraction_witness.py.

References _bit_exact(), _build_encoding_sublayer(), _invertibility_sweep(), _measure_determinacy_degree_baked(), _secret_polys(), _stored_bytes(), and extract_and_regenerate().

+ Here is the call graph for this function:

Variable Documentation

◆ ENC_INDEPENDENT_PER_FACTOR

int table_extraction_witness.ENC_INDEPENDENT_PER_FACTOR = 2

Definition at line 68 of file table_extraction_witness.py.

◆ ENC_TABLES_PER_FACTOR

int table_extraction_witness.ENC_TABLES_PER_FACTOR = 4

Definition at line 67 of file table_extraction_witness.py.

◆ m

table_extraction_witness.m

Definition at line 405 of file table_extraction_witness.py.

◆ reads

table_extraction_witness.reads

Definition at line 406 of file table_extraction_witness.py.

◆ SEED

int table_extraction_witness.SEED = 42

Definition at line 64 of file table_extraction_witness.py.

◆ SEEDS

tuple table_extraction_witness.SEEDS = (42, 1337, 20250714, 7, 99)

Definition at line 65 of file table_extraction_witness.py.

◆ Z_TRIALS

int table_extraction_witness.Z_TRIALS = 1000

Definition at line 66 of file table_extraction_witness.py.