International Association for Cryptologic Research

International Association
for Cryptologic Research

Transactions on Cryptographic Hardware and Embedded Systems 2026

A Framework for designing High-Order Side-Channel Protected Hardware Implementations of ML-KEM


README

HOPE-MLKEM Framework

Welcome to the HOPE-MLKEM framework. This repository accompanies the CHES article:
“A Framework for Designing High-Order Side-Channel Protected Hardware Implementations of ML-KEM.”


1. Prerequisites

The following tools are required to use the framework:

  1. Verilator (v5.035): Verilog/SystemVerilog simulator.
  2. GTKWave (v3.3.116): Waveform visualization tool.
  3. Yosys (v0.51): RTL synthesis framework.
  4. Nextpnr (v0.6): Vendor-neutral FPGA place-and-route tool.
  5. OpenSTA (v2.7.0): A gate-level static timing analysis tool used for the ASIC flow.
  6. Icarus Verilog (v13.0): A Verilog simulation and synthesis tool, used for gate-level power analysis.

Note: On Ubuntu 24.04 LTS, installing 'bc' was not required in our setup. If you encounter related errors, you can install it with: sudo apt-get install bc


2. Repository Structure

The main directories and their purposes are summarized below:

.       
├── pnr                            # Place-and-Route outputs
├── power                          # Power analysis files
│   ├── out                        # Power reports and logs
│   └── scripts                    # OpenSTA Tcl scripts for power analysis
│       ├── run_power_static.tcl
│       └── run_power_vcd.tcl
├── prog                           # FPGA programming files
├── rtl                            # RTL (Verilog/SystemVerilog) sources and constraint files.
├── sim                            # Simulation setup
│   ├── src   
│   │   ├── testbench.cpp          # Demo C++ testbench (to be updated/modified for your design)
│   │   ├── sim_utils.cpp          # Auxiliary simulation functions.
│   │   └── sim_utils.h            # Declarations for simulation utilities.
│   └── waveform.gtkw              # Optional GTKWave session file.
├── sta                            # Static Timing Analysis files
│   ├── out                        # STA reports and logs
│   └── scripts   
│       ├── run_sta.tcl            # OpenSTA execution script
│       └── sta_translate_names.py # Script to make reports human-readable
├── synth                          # Synthesis files
│   ├── out                        # Synthesis outputs: netlists, JSON, logs, and stats
│   └── scripts
│       ├── get_kge.py             # kGE area calculation script
│       └── synth_nangate45.tcl    # Yosys script for Nangate45 synthesis
├── tech                           # Technology libraries for ASIC flow
│   ├── nangate45                  # Nangate 45nm
│   └── ihp-sg13g2                 # IHP 130nm
├── traces                         # Side-channel analysis traces and tools
│   ├── fixed                      # Output for fixed-input traces
│   ├── random                     # Output for random-input traces
│   ├── src    
│   │   └── readvcd.c              # Tool to convert VCD to power traces
│   └── tvla                       # TVLA analysis results
│       └── TVLA.ipynb             # Jupyter notebook for TVLA analysis
├── Makefile                       # Main Makefile for all workflows
└── README.md                      # This documentation

3. Overview

The HOPE-MLKEM framework provides a unified environment for simulating, synthesizing, and evaluating hardware implementations of ML-KEM, with support for FPGA and ASIC flows, static timing and power analysis, and side-channel leakage evaluation through TVLA.

Configuration is performed directly in the main Makefile. The following parameters must be set prior to execution:


4. Simulation

The framework supports several hardware configurations, corresponding to the implementations reported in the CHES article. These configurations can be defined via parameters in the AXI_IO_MLKEM module (TOP_MODULE=AXI_IO_MLKEM):

Implementation N_BU MASKED SHUFF SHUFF_DELAY KECCAK_PROT
Unprotected (N_BU=1) 1 0 0 0 0
Unprotected (N_BU=2) 2 0 0 0 0
Unprotected (N_BU=4) 4 0 0 0 0
Protected First-Order 2 1 1 539 1
Protected High-Order 4 1 1 539 1

Additional Makefile parameters include:

Simulation is performed using:

make sim

5. TVLA Security Analysis

The framework enables Test Vector Leakage Assessment (TVLA) over simulated traces. Configuration parameters are defined in the Makefile as follows:

Once configured, the traces can be generated by executing:

make traces

Fixed and random traces will be stored in the traces/fixed/ and traces/random/ directories, respectively. Results can be analyzed using the Jupyter notebook located at traces/tvla/TVLA.ipynb.

Please ensure all Python dependencies are installed using the requirements.txt file: pip install -r requirements.txt

All parameters within AXI_IO_MLKEM may be modified to explore different masking, shuffling, or protection strategies.

Note: This process can take anywhere from a few minutes to a few hours, depending on the number of traces and the selected module configuration (K or Masked).


6. Waveform Analysis

Waveform generation follows a similar procedure to TVLA analysis. By adjusting the parameters K_MLKEM_WAVES and MASKED in the Makefile, the user can visualize internal signals and verify design behavior. Execute:

make waves

to perform the simulation and automatically open GTKWave.


7. FPGA Flow

For this section it is important that users configure: TOP_MODULE=TOP_MLKEM for unprotected version or TOP_MODULE=TOP_MLKEM_MASKED for protected one.

7.1 FPGA Synthesis

Use Yosys to synthesize your design. Multiple synthesis flows are available:

Note: This process can take few hours to complete.


8. ASIC Flow

For this section it is important that users configure: TOP_MODULE=TOP_MLKEM for unprotected version or TOP_MODULE=TOP_MLKEM_MASKED for protected one. In the same way, we recomend to consider all BRAMs as blackboxes, just comenting the specific line in rtl/lib_mem_mlkem.v and rtl/mem_zetas.v.

8.1 ASIC Synthesis

In order to perform ASIC synthesis and power analysis it is mandatory to configure the Makefile as follow:

The following parameters are automatically configured based on the selected TECH_NODE. You can extend this logic to support new technology libraries:

Also for Static Timing Analysis:

To synthesize your design for the selected ASIC technology (TECH_NODE), run:

make synth-asic

This target uses a dedicated Yosys script to map the RTL to the Nangate45 standard cells, generating a structural Verilog netlist, an area report, and calculating the total area in kilo-gate equivalents (kGE).

8.2 Perform Static Timing Analysis (ASIC):

After ASIC synthesis, run STA using OpenSTA to verify timing constraints.

make sta-asic

This command analyzes the synthesized netlist against timing constraints. It generates detailed reports on timing paths and slack in the sta/out/$(TECH_NODE) directory. It also automatically translates the reports to a human-readable format and, crucially, generates a Standard Delay Format (SDF) file. This SDF file contains accurate timing information essential for gate-level simulations.

8.3 Perform Power Analysis (ASIC)

Note: These power analysis are under evaluation and they should be taken care carefully
The framework includes a power analysis flow.

make power-asic-static

This command estimates power based on default signal activities and is useful for early-stage analysis.

Recap: How to Configure and Use the Framework

Build/Simulate the Design

Side-Channel Trace Generation

Note: Open and run the traces/tvla/TVLA.ipynb Jupyter Notebook to perform a Test Vector Leakage Assessment (TVLA) on the generated traces.

Synthesize the Design

Static Timing Analysis (ASIC)

Power Analysis (ASIC)

For further details, please refer to:

Contact

Eros Camacho-Ruiz - ([email protected] [email protected])

Hardware Cryptography Researcher

Instituto de Microelectrónica de Sevilla (IMSE-CNM), CSIC, Universidad de Sevilla, Seville, Spain