quantum-random 1.1.0

A Package to Access Quantum Random Numbers


To use this package, put the following dependency into your project's dependencies section:

dub.json
dub.sdl

QuantumRandom

This package helps to access quantum random numbers of a quantum random number generator of the Humboldt University of Berlin (HU Berlin), Faculty of Mathematics and Natural Sciences I, Department of Physics. Their website: https://qrng.physik.hu-berlin.de Also, this package provides a ready-to-use D interface for libQRNG.

Current State

Right now, this package can read the downloaded random numbers of the TU Berlin in order to set up e.g. scientific experiments. Re-use the same files to gain deterministic results. If all downloaded files i.e. numbers are used, starts over with the same data.

The QRNG live API can be used to receive endless random numbers over the Internet.

Building

This package builds on top of libQRNG and thus requires the binaries from http://qrng.physik.hu-berlin.de/download to build properly. The required files for a specific target are specified in dub.json.

After downloading the necessary binary, copy it to the location which matches your platform, e.g.:

  • Linux: /usr/local/lib/libQRNG.so
  • macOS: /usr/local/lib/libQRNG.dylib
  • Windows: Project folder. Requires both libQRNG.lib and libQRNG.dll.

Windows

The DMD linker expects Win32 libraries to be in OMF, not it COFF. It is necessary to convert them.

MacOS

In case of macOS, the following error message could occur after compiling the application:

dyld: Library not loaded: /usr/local/lib/libLibQRNG.dylib
  Referenced from: PATH TO YOUR APPLICATION WHICH USES THIS LIB
  Reason: image not found

If so, please add the following command to the end of your dub.json file: "postGenerateCommands-osx": ["install_name_tool -change /usr/local/lib/libLibQRNG.dylib /usr/local/lib/libQRNG.dylib $PACKAGE_DIR/bin/$$DUB_TARGET_NAME || :"]

Usage

QRNG can be used as simple wrapper for libQRNG:

auto ret = qrng_connect("QRNG_USERNAME", "QRNG_PASSWORD");
if (ret != 0)
	throw new Exception(qrng_error_strings[ret]);
	
int[] ints = new int[5];
int received;
qrng_get_int_array(&(ints[0]), 5, &received);

writeln("Random integers: ", ints);

QRNG can be used as random number cache:

// Create an instance of a random double cache which uses the live API as seed source
auto qrng = new DoubleQRNG(new StreamQuantumSeedSource!1024("QRNG_USERNAME", "QRNG_PASSWORD"), 1);
scope (exit) //Defer closing to stop generator thread
	qrng.stop();

auto q1 = qrng.createChunkProvider();

writeln("Random double: ", q1.next());

To do

  • [ ] Implement a deterministic mode for the live API.
  • [x] Test building with different compilers/linkers.
  • [x] Windows, DMD
  • [x] macOS, DMD
  • [x] Ubuntu, DMD
Authors:
Thorsten Sommer, Robin Kupper
Dependencies:
none
Versions:
1.3.0 2017-Oct-11
1.2.1 2017-Oct-11
1.2.0 2017-Jul-01
1.1.0 2017-Jun-05
1.0.13 2017-Apr-17
Show all 19 versions
Download Stats:
  • 6 downloads today

  • 8 downloads this week

  • 42 downloads this month

  • 999 downloads total