[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/git/https%3A%2F%2Fsrc.koda.cnrs.fr%2Flabhc%2Fcode4publications%2F2024-tches-lcpj-measurement-method/HEAD) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Python](https://img.shields.io/static/v1?message=Python&color=3776AB&logo=Python&logoColor=FFFFFF&label=)](https://www.python.org/) [![Jupyter](https://img.shields.io/badge/Jupyter-orange?logo=jupyter&logoColor=%23F37626&color=%23A9A9A9)](https://www.jupyter.org/) # Low Cost and Precise Jitter Measurement Method for TRNG Entropy Assessment ## Background This repository contains data and source codes (in the form of Python notebooks) as complementary material to the article of the same name published in [TCHES 2024](https://ches.iacr.org/2024/)-1. We advise the user to read the original paper [here](https://ujm.hal.science/ujm-04220101v2/document). The original article presents a new jitter measurement method aimed at the evaluation of oscillator-based TRNGs. The aim of this repository is to help the user understand the new jitter measurement method.
Paper abstract Random number generators, and specifically true random number generators (TRNGs), are essential in cryptography. TRNGs implemented in logic devices usually exploit the time instability of clock signals generated in freely running oscillators as source of randomness. To assess the performance and quality of oscillator-based TRNGs, accurate measurement of clock jitter originating from thermal noise is of paramount importance. We propose a novel jitter measurement method, in which the required jitter accumulation time can be reduced to around 100 reference clock periods. Reduction of the jitter accumulation time reduces the impact of the flicker noise on the measured jitter and increases the precision of the estimated contribution of thermal noise. In addition, the method can be easily embedded in logic devices. The fact that the jitter measurement can be placed in the same device as the TRNG is important since it can be used as a basis for efficient embedded statistical tests. In contrast to other methods, we propose a thorough theoretical analysis of the measurement error. This makes it possible to tune the parameters of the method to guarantee a relative error smaller than 12% even in the worst cases.
## Content The repository contains two main folders. ### The `/src` folder In the [`/src`](https://src.koda.cnrs.fr/labhc/code4publications/2024-tches-lcpj-measurement-method/-/tree/master/src?ref_type=heads) folder, we offer the user three Python notebooks. Please note that although the results obtained in these notebooks will not exactly match the results in our article (because of the random nature of this project), the results obtained here will be very similar to those in our article. We recommend that you use them in the following order: 1. [`Error_analysis`](src/Error_analysis.ipynb): This notebook can be used to analyze the error of the method due to its approximation of the area under the Gaussian curve of jitter (see Section 3.2.1 of the original [paper](https://ujm.hal.science/ujm-04220101v2/document)). 2. [`Simulation`](src/Simulation.ipynb): This notebook can be used to simulate the new jitter measurement method in Python 3. 3. [`FPGA_measurements`](src/FPGA_measurements.ipynb): This notebook can be used to measure the jitter using the new method. As an example, we measure the jitter in three different FGPAs using data stored in the `/data` folder. ### The `/data` folder This folder can be found inside the [`data.zip`](https://src.koda.cnrs.fr/labhc/code4publications/2024-tches-lcpj-measurement-method/-/blob/master/data.zip?ref_type=heads) file. It contains experimental data acquired from three different FPGA families. Each of the following subfolders contains twenty binary files: 1. `/CV` : data acquired with an Intel® Cyclone® V FPGA. 2. `/S6` : data acquired with a Xilinx Spartan™ 6 FPGA. 3. `/SF2` : data acquired with a Microchip SmartFusion® 2 FPGA. #### The binary files To implement the new jitter measurement method, the following circuit has to be implemented in hardware:
Fig. 1 from our [article](https://ujm.hal.science/ujm-04220101v2/document). Circuitry of the ERO-TRNG with an additional counter aimed at the jitter measurement.
For more information on how to implement the jitter measurement circuitry in hardware, refer to Section 4 of the original [article](https://ujm.hal.science/ujm-04220101v2/document)). Note that only a set of 16-bit counter values needs to be acquired from that circuit. Next, we set the parameters of the measurement method (see Algorithm 1 in the original [paper](https://ujm.hal.science/ujm-04220101v2/document)) as follows: $N=4\ 096$ $L=65\ 535$ $k \in \[1;255\]$ Each file contains a total of $N \left( k_{max}-k_{min}+1 \right) + 1 = 4\ 096(255 - 1 + 1) + 1 = 1\,044\,481$ counter values. Let $c_{i,j}$ be the $j$-th acquired counter value from the circuit in Fig. 1 when $k=i$. A binary file contains the counter values, ordered as follows: ```math [c_{1,1},\ c_{1,2},\ c_{1,3},\ ...\ c_{1,4\ 096},\ c_{2,1},\ c_{2,2},\ c_{2,3},\ ...\ ...\ c_{255,4\ 096},\ c_{65\ 535,1}] ``` The last counter value $c_{65\ 535,1}$ is used to approximate the ratio $T_0/T_1$. Please note that only one file is sufficient to perform several jitter measurements. However, to demonstrate the reproducibility of the new jitter measurement method, we offer the user twenty binary files acquired one after the other in 3-minute intervals for each FGPA device. In order to stabilize the temperature of the board and hence the frequency of the oscillators, the files were acquired after the ring oscillators in the FPGA had been running for 10 minutes.
Repository structure ``` ├───📁 src/ │ ├───📄 Error_analysis.ipynb │ ├───📄 FPGA_measurements.ipynb │ └───📄 Simulation.ipynb │ └───📦 data.zip │ 📁 data/ ├───📁 CV/ │ └───📄acq_TIMESTAMP_CV.bin... ├───📁 S6/ │ └───📄acq_TIMESTAMP_S6.bin... └───📁 SF2/ └───📄acq_TIMESTAMP_SF2.bin... ```
## Executing the codes ### By a single click using Binder 1. Click [this link](https://mybinder.org/v2/git/https%3A%2F%2Fsrc.koda.cnrs.fr%2Flabhc%2Fcode4publications%2F2024-tches-lcpj-measurement-method/HEAD) or on the Binder snippet available on top of this README. 2. A new tab with the loading Binder icon will appear; wait for a few minutes. Binder can take a long time to load, but this doesn’t mean that Binder will fail to launch. You can always refresh the window if you see the "... is taking longer to load; hang tight!” message. 3. You will see a JupyterLab interface. 4. On the menu on the left side, go to the `/src` folder. Click on one of the three notebooks you wish to use.
Fig. 2 Jupyter interface using Binder.
5. Follow the instructions in the notebook. ### By downloading them and running the project locally 1. Download our project on a PC with Python. For more information on how to install Python, click [here](https://wiki.python.org/moin/BeginnersGuide/Download). 2. Make sure that the following Python modules are installed. If they are not, install them using `pip`. For more information on how to install modules with 'pip', click [here](https://packaging.python.org/en/latest/tutorials/installing-packages/). [`numpy`](https://pypi.org/project/numpy/) [`matplotlib`](https://pypi.org/project/matplotlib/) [`scipy`](https://pypi.org/project/scipy/) [`progressbar2`](https://pypi.org/project/progressbar2/) [`plotly`](https://pypi.org/project/plotly/) [`jupyter`](https://pypi.org/project/jupyter/) 3. Unzip the content of the [`data.zip`](https://src.koda.cnrs.fr/labhc/code4publications/2024-tches-lcpj-measurement-method/-/blob/master/data.zip?ref_type=heads) file in its location. 3. In a command line, go to the downloaded folder of this project on your PC. 4. Start the JupyterLab server from the command line by running: ``` python -m notebook ``` 5. You should see a JupyterLab interface open in a tab in your web browser. 6. Go to the `/src` folder. Click on the notebook you wish to use.
Fig. 3 Local JupyterLab interface.
7. Follow the instructions in the notebook. ## Authors **Arturo Garay1,2, Florent Bernard1, Patrick Haddad2, Natahlie Bochard1, Viktor Fischer1,3**
Affiliations 1Hubert Curien Laboratory, Université Jean Monnet, Member of the Université de Lyon, 42000, Saint-Etienne, France 2STMicroelectronics, Advanced System Technology, 13790 Rousset, France 3Faculty of Information Technologies, Czech Technical University in Prague, 160 41, Prague, Czech Republic
### Acknowledgements We gratefully acknowledge the help of Dr. Ugo Mureddu in preparation of this article. ## Support Send an email to one of the authors if you have any problems or questions.
Email addresses - [arturo.garay@univ-st-etienne.fr](arturo.garay@univ-st-etienne.fr) - [florent.bernard@univ-st-etienne.fr](florent.bernard@univ-st-etienne.fr) - [patrick.haddad@st.com](patrick.haddad@st.com) - [nathalie.bochard@univ-st-etienne.fr](nathalie.bochard@univ-st-etienne.fr) - [fischer@univ-st-etienne.fr](fischer@univ-st-etienne.fr)
## Links of interest
For information regarding other jitter measurement methods - _Viktor Fischer and David Lubicz. Embedded evaluation of randomness in oscillator based elementary TRNG. In Lejla Batina and Matthew Robshaw, editors, CHES 2014, volume 8731 of LNCS, pages 527–543. Springer, Heidelberg, September 2014_, [link](https://ujm.hal.science/ujm-01010404/document). - _Bohan Yang, Vladimir Rozic, Milos Grujic, Nele Mentens, and Ingrid Verbauwhede. On-chip jitter measurement for true random number generators. In 2017 Asian Hardware Oriented Security and Trust Symposium, AsianHOST 2017, Beijing, China, October 19-20, 2017, pages 91–96. IEEE Computer Society, 2017_, [link](https://lirias.kuleuven.be/bitstream/123456789/630261/2/OCJMFTRNG.pdf). - _Boyan Valtchanov, Viktor Fischer, and Alain Aubert. A coherent sampling based method for estimating the jitter used as entropy source for True Random Number Generators. In International Conference on Sampling Theory and Applications - SAMPTA 2009, 2009_, [link](https://hal.science/hal-00451849/document).
For the stochastic model of the jitter-based eRO-TRNG - _Mathieu Baudet, David Lubicz, Julien Micolod, and André Tassiaux. On the security of oscillator-based random number generators. Journal of Cryptology, 24(2):398–425, April 2011_, [link](https://eprint.iacr.org/2009/299.pdf).
For standards requiring the evaluation of TRNGs using their stochastic model - _Information technology – Security techniques – Test and analysis methods for random bit generators within ISO/IEC 19790 and ISO/IEC 15408. Technical report, International Organization for Standardization, October 2019_, [link](https://www.iso.org/standard/68296.html). - _Wolfgang Killmann and Werner Schindler. A proposal for: Functionality classes for random number generators, AIS20/31. Technical report, Bundesamt für Sicherheit in der Informationstechnik (BSI), Bonn, 2011_, [link](https://cosec.bit.uni-bonn.de/fileadmin/user_upload/teaching/15ss/15ss-taoc/01_AIS31_Functionality_classes_for_random_number_generators.pdf).
## License Low Cost and Precise Jitter Measurement Method for TRNG Entropy Assessment Artifact Copyright © 2023 Arturo Garay This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You can find a copy of the GNU General Public License [here](https://src.koda.cnrs.fr/labhc/code4publications/2024-tches-lcpj-measurement-method/-/blob/master/LICENSE.txt?ref_type=heads). You can also see [https://www.gnu.org/licenses/](https://www.gnu.org/licenses/).