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
cache_effect.c File Reference

Measures the cache-miss penalty of the PQ-WB-KEM white-box table lookups. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
+ Include dependency graph for cache_effect.c:

Go to the source code of this file.

Classes

struct  node_t
 

Macros

#define NUM_COMPONENTS   128
 
#define Q   3329
 
#define ZETA   17
 

Functions

static void bench_primitive (FILE *js)
 
static void bench_working_set (FILE *js)
 
static double chase_latency_ns (size_t bytes, long steps)
 
static uint32_t lcg_next (void)
 
int main (void)
 
static double now_sec (void)
 
static int pow_mod (int base, int exp, int mod)
 

Variables

static uint64_t lcg_state = 42
 

Detailed Description

Measures the cache-miss penalty of the PQ-WB-KEM white-box table lookups.

Cache-penalty factor of the deployment-overhead projection (measured masking x cache penalty), measured on real hardware two ways rather than assumed.

Note
BENCH A builds the real construction-B per-component baked tables (7.67 MB, k=3; full-range NTT-domain secret, layout as whitebox_reference.py) and times table-lookup vs direct-arithmetic base multiplication. Host 36 MB L3 holds the whole table, so its ratio is a LOWER BOUND for embedded targets lacking an L3.
BENCH B pointer-chases a Sattolo random cycle of 64-byte nodes over 16 KB..64 MB working sets for true random-access latency; the DRAM/L1 ratio is the penalty an L1/L2-only embedded target sees once the tables exceed cache.
Deterministic (LCG seed 42). Writes results/cache_effect.json. Build: gcc -O2 -o cache_effect cache_effect.c.

Definition in file cache_effect.c.


Class Documentation

◆ node_t

struct node_t

Definition at line 200 of file cache_effect.c.

+ Collaboration diagram for node_t:
Class Members
uint32_t next
char pad[60]

Macro Definition Documentation

◆ NUM_COMPONENTS

#define NUM_COMPONENTS   128

Definition at line 32 of file cache_effect.c.

◆ Q

#define Q   3329

Definition at line 31 of file cache_effect.c.

◆ ZETA

#define ZETA   17

Definition at line 33 of file cache_effect.c.

Function Documentation

◆ bench_primitive()

static void bench_primitive ( FILE *  js)
static

Definition at line 53 of file cache_effect.c.

References lcg_next(), now_sec(), NUM_COMPONENTS, pow_mod(), Q, and ZETA.

Referenced by main().

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

◆ bench_working_set()

static void bench_working_set ( FILE *  js)
static

Definition at line 229 of file cache_effect.c.

References chase_latency_ns().

Referenced by main().

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

◆ chase_latency_ns()

static double chase_latency_ns ( size_t  bytes,
long  steps 
)
static

Definition at line 202 of file cache_effect.c.

References lcg_next(), node_t::next, and now_sec().

Referenced by bench_working_set().

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

◆ lcg_next()

static uint32_t lcg_next ( void  )
static

Definition at line 37 of file cache_effect.c.

References lcg_state.

Referenced by bench_primitive(), and chase_latency_ns().

+ Here is the caller graph for this function:

◆ main()

int main ( void  )

Definition at line 270 of file cache_effect.c.

References bench_primitive(), and bench_working_set().

Referenced by wallclock_ci::main().

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

◆ now_sec()

static double now_sec ( void  )
static

Definition at line 24 of file cache_effect.c.

Referenced by bench_primitive(), and chase_latency_ns().

+ Here is the caller graph for this function:

◆ pow_mod()

static int pow_mod ( int  base,
int  exp,
int  mod 
)
static

Definition at line 42 of file cache_effect.c.

Referenced by bench_primitive().

+ Here is the caller graph for this function:

Variable Documentation

◆ lcg_state

uint64_t lcg_state = 42
static

Definition at line 36 of file cache_effect.c.

Referenced by lcg_next().