Skip to main content

Unitary Fund YouTube PyPI Coverage Apache-2.0 License DOI

qrand

A multiprotocol and multiplatform quantum random number generation framework

Random numbers are everywhere.

Computer algorithms, data encryption, physical simulations, and even the arts use them all the time. There is one problem though: it turns out that they are actually very difficult to produce in large amounts. Classical computers can only implement mathematical tricks to emulate randomness, while measuring it out of physical processes turns out to be too slow. Luckily, the probabilistic nature of quantum computers makes these devices particularly useful for the task.

QRAND is a free and open-source framework for quantum random number generation. Thanks to its loosely coupled design, it offers seamlessly compatibility between different quantum computing platforms and QRNG protocols. Not only that, but it also enables the creation of custom cross-compatible protocols, and a wide range of output formats (e.g. bitstring, int, float, complex, hex, base64).

To boost its efficiency, QRAND makes use of a concurrent cache to reduce the number of internet connections needed for random number generation; and for quality checks, it incorporates a suite of classical entropy validation tests which can be easily plugged into any base protocol.

Additionally, QRAND introduces an interface layer for NumPy that enables the efficient production of quantum random numbers (QRN) adhering to a wide variety of probability distributions. This is ultimately accomplished by transforming uniform probability distributions produced in cloud-based real quantum hardware, through NumPy's random module.

from qrand import QuantumBitGenerator
from qrand.platforms import QiskitPlatform
from qrand.protocols import HadamardProtocol
from numpy.random import Generator
from qiskit import IBMQ

provider = IBMQ.load_account()
platform = QiskitPlatform(provider)
protocol = HadamardProtocol()
bitgen = QuantumBitGenerator(platform, protocol)
gen = Generator(bitgen)

print(f"Random Raw: {bitgen.random_raw()}")
print(f"Random Bitstring: {bitgen.random_bitstring()}")
print(f"Random Unsigned Int: {bitgen.random_uint()}")
print(f"Random Double: {bitgen.random_double()}")

print(f"Random Binomial: {gen.binomial(4, 1/4)}")
print(f"Random Exponential: {gen.exponential()}")
print(f"Random Logistic: {gen.logistic()}")
print(f"Random Poisson: {gen.poisson()}")
print(f"Random Std. Normal: {gen.standard_normal()}")
print(f"Random Triangular: {gen.triangular(-1, 0, 1)}")
# ...

Supported quantum platforms

As of May 2021, only Qiskit is supported. However, support for Cirq and Q# is under active development.

Implemented QRNG protocols

As of May 2021, only the basic HadamardProtocol is available. We are also working on implementing this EntaglementProtocol, as well as a version of Google's Sycamore routine (patent permitting).

Authors and citation

QRAND is the work of many people who contribute to the project at different levels. If you use QRAND, please cite as per the included BibTeX file.

Contribution guidelines

If you'd like to contribute to QRAND, please take a look at the contribution guidelines. This project adheres to the following code of conduct. By participating, you are expected to uphold this code.

We use GitHub issues for tracking requests and bugs. Please use Unitary Fund's Discord for discussion and simple questions.

Acknowledgements

Parts of this software's source code have been borrowed from the qRNG project, which is licensed under the GNU GPLv3 license. Copyright notice and specific changes can be found as a docstring wherever this applies.

License

Apache License 2.0


(c) Copyright 2021 Pedro Rivero

Metadata

Release files for qrand 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qrand 0.4.0
File Size Uploaded Provenance
qrand-0.4.0.tar.gz 35.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for qrand 0.4.0
File Interpreter ABI Platform
qrand-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 105.3 kB

Release files / qrand-0.4.0.tar.gz

Download URL qrand-0.4.0.tar.gz
Size 35.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5684b7953701208e7ddffed60f8d44f82739da3381efbbe2c030417de3a5660f
BLAKE2b-256 checksum
How to use checksums
84ad8d2615260640389a6ccdcc709faba43dbfa64ea72740da60b6613c3c3c07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.0 Darwin/20.1.0

Release files / qrand-0.4.0-py3-none-any.whl

Download URL qrand-0.4.0-py3-none-any.whl
Size 69.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
87923b0a494fcf61d85d804bce03c4bb6039c6de88dcb7248301b109a2063b12
BLAKE2b-256 checksum
How to use checksums
7f11324119e2ab32d1f6ca37a1d5b99e8194773cf13b5894b9310bac7a828b68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.6 CPython/3.9.0 Darwin/20.1.0

Security for qrand 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page