-
Notifications
You must be signed in to change notification settings - Fork 6
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 |
---|---|---|
Efficiency | Excellent | Poor |
Determinism | Deterministic | Non-deterministic |
Periodicity | Periodic | Aperiodic |
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.
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.
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.
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.
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.
Online gaming
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.
Traditional solution
HPB solution
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.
Sports Competition
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.
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:
https://github.com/hpb-project/wiki/wiki/Interface-of-HPB-hardware-random-number-generator
|中文(简体)版本 | |English Version|
Basics
R&D
- HPB-Consensus-Algorithm-Election-Mechanism
- HPB-BOE-Introduction
- HPB-Consensus-Algorithm--Compare
- HPB-Gas-Mechanism
- HPB-P2P-NetWork
- HPB-JSON-RPC-API-Index
- RLP-Agreement-Extended-Reading
- Interface-of-HPB-hardware-random-number-generator
- HPB-hardware-random-number-service
HPB Dapp Development
- Quick-Start-For-HPB-Developer
- HPB-Dapps-Introductions
- HPB-EVM-Contracts-Introductions
- HPB-Extended-Reading-on-EVM-Development
- An-Introduction-to-EVM-Virtual-Machines
- HPB-Smart-Contracts-Extended-Doc
- Best-Practice-of-Accessing-HPB-Main-Network-in-JS-version
- Best-Practice-of-HPB-Main-Network-Access-Java-Version
- Best-Practice-of-HPB-Smart-Contract
- Case-of-Transmission-from-Ethereum-DAPP-to-HPB-blockchain
- How-to-Write-a-Contract-Extended-Reading
- Development-Tool--Remix-Extended-Reading
- Solidity-Language-Extended-Reading
- Token-issuance-on-HPB-MainNet
- Migrating-a-Ethereum-DApp-to-the-HPB-MainNet
HPB Wallet Development
- An-Introduction-to-HPB-Wallet
- HPB-Wallet-for-Xcode-Integration
- Creating-the-HPB-Wallet
- Generating-Mnemonics-for-HPB Wallet
- HPB-Wallet-and-Middleware-Interface
HPB Mainnet/TestNet Entry
- HPB-Development-Node-Construction-Guild
- Guide-to-Server-Security-Reinforcement
- Build Node With Docker
- HPB-Private-Chain-Building-Guide
Developer Community