|
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)
|
Functions | |
| _bitrev7 (k) | |
| Bit-reversal of a 7-bit index (FIPS-203 NTT twiddle order). | |
| _negacyclic (f, g) | |
| Schoolbook multiply in Z_q[X]/(X^256+1); independent correctness oracle. | |
| _poly_mod_x2 (f, gamma) | |
| Reduce a length-256 polynomial modulo (X^2 - gamma) over Z_q. | |
| _zeta_powers () | |
| Powers of zeta mod q for the NTT. | |
| base_mul_baked (tabs, uh, i) | |
| Construction B base multiply via baked per-component lookups. | |
| base_mul_direct (sh, uh, i) | |
| Reference base multiply for degree-2 factor i (direct arithmetic). | |
| base_mul_shared (M, sh, uh, i) | |
| Construction A base multiply via shared-table lookups (full-range secret). | |
| build_baked_tables (sh) | |
| Construction B tables for one secret polynomial: per-component q-entry tables with the fixed secret baked in. | |
| build_shared_table () | |
| Construction A table: one shared full multiply table M[x][y]=x*y mod q. | |
| cbd_range_occupancy (shat_polys) | |
| Count NTT-domain secret coordinates landing in the coefficient-domain CBD range {-2..2} mod q. | |
| main () | |
| Build both constructions on the real NTT-domain secret, check correctness, measure sizes and masking overhead, write JSON. | |
| measure_cbd_range_occupancy (n_seeds=200) | |
| Occupancy rate over many independent secrets, so the reference-sample count is not mistaken for the underlying rate. | |
| measure_overhead (iters=100000, seed=SEED) | |
| Construction-B protected-primitive overhead (baked table lookup plus 3-share masking versus direct arithmetic) on the real full-range NTT-domain secret, for wall-clock CI aggregation (wallclock_ci.py). | |
| ntt_forward (poly) | |
| Forward NTT: coefficient domain to NTT domain. | |
| sample_cbd (rng, size, eta=ETA) | |
| Draw from the centered binomial distribution CBD_eta of FIPS 203. | |
| three_share (v, rng) | |
| Split a value into three arithmetic shares mod q. | |
Variables | |
| dict | CBD_RANGE = {(-2) % Q, (-1) % Q, 0, 1, 2} |
| int | ETA = 2 |
| GAMMAS | |
| int | K = 3 |
| int | N = 256 |
| int | NUM_COMPONENTS = N // 2 |
| int | Q = 3329 |
| int | SEED = 42 |
| int | ZETA = 17 |
| ZETA_POWERS = _zeta_powers() | |
|
protected |
Bit-reversal of a 7-bit index (FIPS-203 NTT twiddle order).
| k | Index in [0, 128). |
Definition at line 70 of file whitebox_reference.py.
Referenced by ntt_forward().
Here is the caller graph for this function:
|
protected |
Schoolbook multiply in Z_q[X]/(X^256+1); independent correctness oracle.
| f | First length-256 coefficient vector. |
| g | Second length-256 coefficient vector. |
Definition at line 167 of file whitebox_reference.py.
Referenced by main().
Here is the caller graph for this function:
|
protected |
Reduce a length-256 polynomial modulo (X^2 - gamma) over Z_q.
| f | Coefficient vector. |
| gamma | Component twiddle constant. |
Definition at line 188 of file whitebox_reference.py.
Referenced by main().
Here is the caller graph for this function:
|
protected |
Powers of zeta mod q for the NTT.
Definition at line 55 of file whitebox_reference.py.
| whitebox_reference.base_mul_baked | ( | tabs, | |
| uh, | |||
| i | |||
| ) |
Construction B base multiply via baked per-component lookups.
| tabs | Baked tables for the secret polynomial; |
| uh | Ciphertext; |
| i | Component. |
Definition at line 245 of file whitebox_reference.py.
| whitebox_reference.base_mul_direct | ( | sh, | |
| uh, | |||
| i | |||
| ) |
Reference base multiply for degree-2 factor i (direct arithmetic).
| sh | NTT-domain secret polynomial (length 256, full-range). |
| uh | NTT-domain ciphertext polynomial (length 256). |
| i | Component index in [0, 128). |
Definition at line 153 of file whitebox_reference.py.
| whitebox_reference.base_mul_shared | ( | M, | |
| sh, | |||
| uh, | |||
| i | |||
| ) |
Construction A base multiply via shared-table lookups (full-range secret).
| M | Shared multiply table. |
| sh | NTT-domain secret; |
| uh | NTT-domain ciphertext; |
| i | Component. |
Definition at line 213 of file whitebox_reference.py.
| whitebox_reference.build_baked_tables | ( | sh | ) |
Construction B tables for one secret polynomial: per-component q-entry tables with the fixed secret baked in.
| sh | NTT-domain secret polynomial (full-range). |
Definition at line 227 of file whitebox_reference.py.
| whitebox_reference.build_shared_table | ( | ) |
Construction A table: one shared full multiply table M[x][y]=x*y mod q.
Definition at line 204 of file whitebox_reference.py.
Referenced by main().
Here is the caller graph for this function:| whitebox_reference.cbd_range_occupancy | ( | shat_polys | ) |
Count NTT-domain secret coordinates landing in the coefficient-domain CBD range {-2..2} mod q.
| shat_polys | List of NTT-domain secret polynomials. |
Definition at line 125 of file whitebox_reference.py.
Referenced by main(), and measure_cbd_range_occupancy().
Here is the caller graph for this function:| whitebox_reference.main | ( | void | ) |
Build both constructions on the real NTT-domain secret, check correctness, measure sizes and masking overhead, write JSON.
Definition at line 300 of file whitebox_reference.py.
References _negacyclic(), _poly_mod_x2(), build_shared_table(), cbd_range_occupancy(), main(), measure_cbd_range_occupancy(), sample_cbd(), and three_share().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| whitebox_reference.measure_cbd_range_occupancy | ( | n_seeds = 200 | ) |
Occupancy rate over many independent secrets, so the reference-sample count is not mistaken for the underlying rate.
| n_seeds | Number of independent secrets sampled. |
Definition at line 136 of file whitebox_reference.py.
References cbd_range_occupancy(), and sample_cbd().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| whitebox_reference.measure_overhead | ( | iters = 100000, |
|
seed = SEED |
|||
| ) |
Construction-B protected-primitive overhead (baked table lookup plus 3-share masking versus direct arithmetic) on the real full-range NTT-domain secret, for wall-clock CI aggregation (wallclock_ci.py).
| iters | Number of base multiplications timed per variant. |
| seed | Deterministic seed. |
Definition at line 269 of file whitebox_reference.py.
References sample_cbd().
Here is the call graph for this function:| whitebox_reference.ntt_forward | ( | poly | ) |
Forward NTT: coefficient domain to NTT domain.
| poly | Length-256 coefficient vector. |
Definition at line 79 of file whitebox_reference.py.
References _bitrev7().
Here is the call graph for this function:| whitebox_reference.sample_cbd | ( | rng, | |
| size, | |||
eta = ETA |
|||
| ) |
Draw from the centered binomial distribution CBD_eta of FIPS 203.
| rng | Seeded numpy Generator. |
| size | Number of coefficients. |
| eta | Distribution parameter; 2 for the ML-KEM-768 secret. |
Definition at line 109 of file whitebox_reference.py.
Referenced by main(), measure_cbd_range_occupancy(), and measure_overhead().
Here is the caller graph for this function:| whitebox_reference.three_share | ( | v, | |
| rng | |||
| ) |
Split a value into three arithmetic shares mod q.
| v | Value; |
| rng | NumPy Generator. |
Definition at line 258 of file whitebox_reference.py.
Referenced by main().
Here is the caller graph for this function:Definition at line 104 of file whitebox_reference.py.
| int whitebox_reference.ETA = 2 |
Definition at line 106 of file whitebox_reference.py.
| whitebox_reference.GAMMAS |
Definition at line 99 of file whitebox_reference.py.
| int whitebox_reference.K = 3 |
Definition at line 49 of file whitebox_reference.py.
| int whitebox_reference.N = 256 |
Definition at line 48 of file whitebox_reference.py.
| int whitebox_reference.NUM_COMPONENTS = N // 2 |
Definition at line 50 of file whitebox_reference.py.
| int whitebox_reference.Q = 3329 |
Definition at line 47 of file whitebox_reference.py.
| int whitebox_reference.SEED = 42 |
Definition at line 52 of file whitebox_reference.py.
| int whitebox_reference.ZETA = 17 |
Definition at line 51 of file whitebox_reference.py.
| whitebox_reference.ZETA_POWERS = _zeta_powers() |
Definition at line 67 of file whitebox_reference.py.