HPB hardware random number service
HPB hardware random number service
Random numbers are useful for a variety of purposes, such as generating data encryption keys, simulating and modeling complex phenomena and for selecting samples from larger data sets. They have also been widely used for games and gambling.
With the advent of computers, programmers recognized the need for a means of introducing randomness into a computer program. However, surprising as it may seem, it is difficult to get a computer to do something by chance. A computer follows its instructions blindly and is therefore completely predictable. There are two main approaches to generating random numbers using a computer: Pseudo-Random Number Generators (PRNGs) and True Random Number Generators (TRNGs).
|Characteristics||Pseudo-Random Number Generators||True Random Number Generators|
The efficiency of true random number generator is poor due to the complex physical processing of data.
The true random number generator is non-deterministic so no one knows the result before the random number is generated, while the result of a pseudo-random number generator is predetermined because the seed is generated by math formula.
Also, the pseudo-random number generator is periodic because the math formula is regular. The true random number generator is aperiodic because the physical phenomenon is irregular.
Pseudo random number generators are not suitable for applications like data encryption, games and gambling due to its deterministic nature. Hence there is a need for true random number generators. HPB is able to provide true hardware random number generation, and the functionality is introduced in chapter two.
2. The HPB hardware random number service
HPB random number generation service is a true random number service based on our software and hardware. The random number is generated and transmitted by high performance nodes within the HPB network and finalized by our consensus algorithm.
The random number service has three layers; the seed generator layer, the computation layer and the interface layer.
- The seed layer produces hardware random number, implemented by the Blockchain Offload Engine (BOE) card located in each HPB Node, and is further explained in chapter three.
- The computation layer reads the seed produced in the seed layer and writes the seed into blocks. The seeds of previous blocks are also collected in this layer before the random number is generated by the consensus algorithm.
- The interface layer provides the random number interface for end users.
3. How it works
3.1 The generation of the random number seed
The HPB Blockchain Offload Engine (BOE), which is installed in each of the HPB nodes across the world, consists of multiple FPGA chips that are configured to exercise a certain function through VHDL language. These chips are heterogeneous in functionality and thus work differently than chipsets which are only able to perform one function.
The BOE generates random numbers through FPGA chips and sensory bodies that are configured to register voltage differences. Our chips are able to continuously measure those differences at extremely levels of sensitivity. For instance, our board detects a variance of 0.00001 volt, and based on this seed a new random number.
The seed is generated by the BOE chipset and the process is divided into 2 steps
- The voltage change value is captured from the ADC (Analog-to-Digital Converter) inside the BOE card.
- The least significant bit is recorded, and the shift operation is done periodically until 256 bits are recorded and the seed is generated.
3.2 The submission of the seed
HPB High Performance nodes submit the hardware seed during the process of producing blocks. The seed is finally confirmed by the blockchain after consensus is reached by the different nodes.
3.3 The generation of the random number
The HPB random number system encrypts the seed continuously and 200 blocks are generated in a cycle according to the consensus algorithm.
- For the first block in a cycle, the High Performance node selects a seed randomly from the blocks generated during last cycle and generates the random number of the current block by encrypting the seed.
- For other blocks in a cycle, the High Performance node gets the random number seed of last block and generates the random number of the current block by encrypting the seed.
Fairness is probably the most important aspect when players decide whether they will participate a given online game. However, the result could easily be controlled if the random number is deterministic. It is unfair for players because they can hardly win a game if the result is controlled by a third-party. With HPB hardware random number service, the random number is non-deterministic, and the results can be audited.
Below is a lottery use case.
License Plate Lottery
Lucky draw, e.g. U.S. green card lottery and Beijing license-plate lottery, is a common way for government to allocate public resources. Fairness, especially verifiable fairness, is undoubtedly the most critical requirement the lottery must meet. With HPB hardware random number service, the allocation process is transparent, and the results can be audited. Thus, the fairness can be ensured.
How to group a tournament or assign a position in a sport competition in some ways is the most influential determinant of who wins and loses the game. Traditionally grouping draw methods are constantly challenged by both participants and audiences because they are neither transparent nor auditable. Also, the spirit of the sports will be affected if the match is controlled by an interest group. HPB offers a good solution to the problems above by ensuring auditable true random number generation.
How to use HPB hardware random number service
There are two methods to implement HPB’s random number generation service:
RPC (Remote Procedure Call) interface which users can call to get the random number generated for each block. Every block in HPB network has a random number assigned to them.
Smart contract developers can add a line of code: “Block.Random” to create random numbers for their smart contracts.
For specific implementation details please refer to the interface document: