Efficient Implementation of CRYSTALS-KYBER Key Encapsulation Mechanism on ESP32
Fabian Segatz, Muhammad Ihsan Al Hafiz · 2025
Read Efficient Implementation of CRYSTALS-KYBER Key Encapsulation Mechanism on ESP32 by Fabian Segatz, Muhammad Ihsan Al Hafiz (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2503-10207.txt.
Introduction
Fabian Segatz and Muhammad Ihsan Al Hafiz report in 2025 on running a post-quantum encryption scheme on a cheap, popular microcontroller. The scheme, Kyber, won the first United States standardization contest for cryptography that can survive quantum computers, and it must work on the tiny chips inside everyday connected devices.
The ESP32 chip they target has two processor cores. By hand-splitting the Kyber steps across both cores, they sped up key generation, encapsulation, and decapsulation by roughly twenty percent each. They also probed the chip's built-in hashing and encryption hardware for further gains. Small devices need quantum-safe locks too.
Catalog record
| CREATOR | Fabian Segatz, Muhammad Ihsan Al Hafiz |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 28 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2503-10207
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Efficient Implementation of CRYSTALS-KYBER Key Encapsulation Mechanism on ESP32 Fabian Segatz, Muhammad Ihsan Al Hafiz Abstract Kyber, an IND-CCA2-secure lattice-based post-quantum key-encapsulation mechanism, is the winner of the first post-quantum cryptography standardization process of the US National Institute of Standards and Technology. In this work, we provide an efficient implementation of Kyber on ESP32, a very popular microcontroller for Internet of Things applications. We hand-partition the Kyber algorithm to enable utilization of the ESP32 dual-core architecture, which allows us to speed up its execution by 1.21x (keygen), 1.22x (encaps) and 1.20x (decaps). We also explore the possibility of gaining further improvement by utilizing the ESP32’s SHA and AES coprocessor and achieve a culminated speed-up of 1.72x (keygen), 1.84x (encaps) and 1.69x (decaps) Keywords: Post-quantum cryptography, Efficient implementation, Kyber, ESP32 List of Acronyms and Abbreviations Acronyms AES Advanced Encryption Standard API Application Programming Interfaces CCA Chosen-Ciphertext Attack CPU Central Processing Unit CRYSTALS Cryptographic Suite for Algebraic Lattices ESP-IDF Espressif IoT Development Framework IND-CCA2 Indistinguishability under adaptive chosen ciphertext attack IND-CPA Indistinguishability under Chosen-Plaintext Attack IoT Internet of Things KDF Key Derivation Function KEM Key Encapsulation Mechanism MLWE problem Learning With Errors problem in module lattices NIST National Institute of Standards and Technology NTT Number Theoretic Transform PKE Public-Key Encryption PQC Post-Quantum Cryptography PRF Pseudo-Random Function RNG Random Number Generator RSA Rivest-Shamir-Adleman RTOS Real-Time Operating System SHA Secure Hash Algorithm XOF Extendable Output Function 1 Introduction Due to the rapidly growing market for Internet of Things (IoT) applications, the ESP platform series from Espressif System increased its market share in the past years. In December 2017, Espressif System shipped 100-Million devices of the ESP series across the world [ 1 ] . To secure the communication channel in IoT applications, Anand et al. [ 2 ] implemented Rivest-Shamir-Adleman (RSA) encryption with a public key concept in ESP32, one of the microcontrollers from the ESP series. RSA encryption was widely used in previous IoT applications [ 3 ] . Unfortunately, several studies [ 4 , 5 , 6 ] stated that Shor’s polynomial-time algorithm [ 7 ] will be able to break established cryptography security, including RSA encryption, once quantum computers are available. In 2016, the National Institute of Standards and Technology (NIST) released a formal global call for standardizing new Public-Key Encryption (PKE) methods and Key Encapsulation Mechanisms (KEMs) suitable for Post-Quantum Cryptography (PQC) [ 5 , 8 ] . In July 2022, Kyber was announced as the first post-quantum KEM algorithm standard [ 9 ] after a six-year selection process. There are open-source Kyber implementations existing for the ARM Cortex M4 [ 10 , 11 ] and the Haswell processor architecture [ 12 ] . This work aims to find an efficient implementation of Cryptographic Suite for Algebraic Lattices (CRYSTALS) -Kyber on ESP32 that shows the advantage of utilizing the ESP32’s dual-core architecture, as well as Advanced Encryption Standard (AES) and Secure Hash Algorithm (SHA) . We plan to give an answer on how much the execution time of Kyber’s keypair-generation, encapsulation and decapsulation algorithm can be reduced by utilizing the ESP32’s hardware features. The purpose of an efficient implementation of Kyber on ESP32 is to enable the usage of PQC in many IoT applications and to encourage handling the future world’s security requirements ahead of time. It is expected that utilizing both cores of the ESP32 by paralleling parts of the Kyber algorithm and utilizing other available hardware accelerators will result in a more time-efficient execution compared to using a simple single-core implementation. To the best of our knowledge, this is the first published optimized implementation of Kyber KEM on ESP32. Contribution 1. The ESP32 processor consists of two Harvard Architecture Xtensa LX6 CPUs. When utilizing the Espressif IoT Development Framework (ESP-IDF) framework and its built-in version of FreeRTOS, it is possible to run threads on the respective cores. However, to speed up the execution time of a program, it must be partitioned into tasks and rearranged in a way that they can be executed in parallel in individual threads. This work presents an effective scheme of parallelizing the Kyber’s Indistinguishability under Chosen-Plaintext Attack (IND-CPA) functionalities. 2. This paper presents results on how much speed-up is achievable by utilizing the ESP32’s hardware accelerators for SHA and AES when executing the 90s variant of Kyber. Organization In Section 2 , we aim to briefly describe Kyber KEM , the target platform and the tools that we used. In Section 3 , we describe the methods for measuring the performance of our implementations. Further, we elaborate on how to utilize the hardware accelerators and explain task parallelism as a basic principle for our dual-core implementation. In Section 4 , the implementations will be presented. This is followed by the results in Section 5 and the discussion in Section 6 . Finally, we want to conclude our work in Section 7 and elaborate on future research. 2 Background This section gives a brief overview of the Kyber algorithm, the used hardware platform ESP32, and the tools we used in this research. 2.1 CRYSTALS-Kyber Kyber is a lattice-based KEM that was selected as the PQC standard in July 2022 [ 9 ] . Its security is based on the Learning With Errors problem in module lattices (MLWE problem) [ 13 ] . Kyber consists of an IND-CPA -secure PKE that is used for the Indistinguishability under adaptive chosen ciphertext attack (IND-CCA2) -secure KEM . The complete algorithm is specified by Avanzi et al. [ 14 ] . Kyber PKE PKE was first introduced by Diffie and Hellman in 1976 [ 15 ] . It allows asymmetric cryptography utilizing a pair of keys. When one of those keys gets used for encryption, the other one is needed for decryption. This allows one of the keys to be published (public key) so that anyone can use it, while the other remains private (secret key). Every PKE scheme relies on some computationally hard mathematical problem. Kyber is a lattice-based cryptography algorithm and relies on the MLWE problem . In this work, we want to give a high-level understanding of the data flow because this is what is relevant for the later implementation. Avanzi et al. published a written specification of Kyber [ 14 ] that defines all the primitives of the following visualization. Figure 1: Visualization of the IND-CPA -secure encryption algorithm indcpa_enc() Figure 2: Visualization of the IND-CPA -secure keypair generation algorithm indcpa_keygen() Figure 3: Visualization of the IND-CPA -secure decryption algorithm indcpa_dec() Figure 3 shows the data flow of the keypair generation. The entry point, marked in green, shows that some random bytes must first be created. From those, we obtain a public- and a noise seed. The publicseed is used to create a matrix A , while the noiseseed is used to sample the vectors e and s . All of those variables need to be in the Number Theoretic Transform (NTT) -space, a special version of a discrete Fourier transform. Because of the way that Kyber is designed, the required matrix multiplication ( A\cdot s ) consists of additions, if it is executed in the NTT -space [ 14 ] . Ultimately, the value t and the publicseed get concatenated and encoded into