
The randextract
library is a Python 3 package implementing randomness extractors that can be used to transform
weak random sources into almost-uniform ones. The library implements quantum-proof strong randomness extractors that can
be used in the Privacy Amplification (PA) step of any Quantum Key Distribution (QKD) or Quantum Random Number Generator
(QRNG) protocol. Since quantum-proof strong randomness extractors are also classical-proof, these extractors are also
well-suited for applications that involve only classical or no side-information at all.
Our goal is to provide an easy-to-read reference library, whose correctness can be easily verified, that can be used to validate high performance implementations (usually hardware based) that are more difficult to audit and test.
src/randextract
: source code of the library.tests
: unit and integration tests.docs/source
: source code of the online documentation.examples
: scripts validating real world privacy amplification implementations.resources
: additional resources such as plots, datasets used in testing and the scripts to generate them, Jupyter notebooks, test vectors, etc.
You can install the latest release of the package using pip
:
pip install randextract
Alternatively, you can install the current dev version cloning this git repo:
git clone https://github.com/cryptohslu/randextract.git
cd randextract
# (Optionally, create a virtual environment)
python -m venv .venv
source .venv/bin/activate
pip install .
The documentation is available at https://randextract.crypto-lab.ch.
You can also build the documentation locally:
cd docs
make html
If randextract
was useful to you in your research, please cite us.
@misc{randextract,
title={randextract: a Reference Library to Test and Validate Privacy Amplification Implementations},
author={Iyán Méndez Veiga and Esther Hänggi},
year={2025},
eprint={2506.00124},
archivePrefix={arXiv},
primaryClass={quant-ph},
url={https://arxiv.org/abs/2506.00124},
}
If you want to collaborate with us at the please send us an email.