Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Lightweight Crypto on Risc-V

This repository contains auxiliary material for the paper "Assembly or Optimized C for Lightweight Cryptography on RISC-V?" which was accepted to CANS 2020.


  • Fabio Campos <>
  • Lars Jellema <>
  • Mauk Lemmen <>
  • Lars Müller <>
  • Daan Sprenkels <>
  • Benoit Viguier <>

The paper is available at

Installation of the dependencies.

Have a look at

We install compilers and libraries in /opt/riscv and in /opt/verilator

⚠️ Execute the line by line instead of one go (which would likely fail).

Compiling a scheme

First edit and to reflect the correct path of the compilers

1. For Sifive

  1. Open 2 terminals.
  2. Execute ./ [SCHEME Folder] [compiler] sifive to generate the correct Makefile and dependencies.
  3. Compile with make
  4. Plug your SiFive board, you should see a /dev/ttyUSB0 and /dev/ttyUSB1 appear.
  5. In the second terminal, execute ./
    This will start a screen on ttyUSB1 and log the output into main.log
  6. In the first terminal, execute make upload (may need sudo).
    This will upload main.elf to the board, you should see output on the second terminal.
  7. To compile for another scheme, execute make clean, this will remove any generated file (including the Makefile)

⚠️ it is possible for your board to not display results, this is a bug due to the latest compilers. We included the binary main-valid.elf to "reset" the board in a working state. To flash it on the board, simply do make reset.

2. For pqriscv-vexriscv (aka. murax)

  1. Open 3 terminals.
  2. Execute ./ [SCHEME Folder] gcc murax to generate the correct Makefile and dependencies.
  3. In terminal 1, Compile with make
  4. In terminal 2, run make startsim to boot the simulator
  5. In terminal 3, once the you read WAITING FOR TCP JTAG CONNECTION in terminal 2, run make openocd to start openocd.
  6. In terminal 1, once you read Info : Listening on port 4444 for telnet connections, run make flash. This will upload the binary to the simulator.
  7. In terminal 2, you should see the result of the execution.

This simulator requires compilation with GCC and with -O2 instead of -O3

3. For riscvOVPsim

  1. Execute ./ [SCHEME Folder] [compiler] riscvOVPsim
  2. Execute make startsim

Compiling and simulating using the bit manipulation extension (B)

  1. Clone the "RISC-V Bitmanip (Bit Manipulation) Extension" git clone
  2. Build and install the tools following the instructions from
  3. Execute ./ [SCHEME Folder] gcc_b spike to generate the correct Makefile and dependencies.
  4. Compile with make RISCV_ARCH=rv64gcb in order to build a version using the B extension or make RISCV_ARCH=rv64gc to build a version without the B extension.
  5. Execute make startsim RISCV_ARCH=rv64gcb in order to simulate using the the B extension or make startsim RISCV_ARCH=rv64gc to simulate w/o B extension. The corresponding binary (see step 4) should be available.


No description, website, or topics provided.







No releases published


No packages published