Fix typo for M1 Mac build
|2 years ago|
|audits||4 years ago|
|doc||3 years ago|
|src||2 years ago|
|vcxproj||3 years ago|
|.gitattributes||3 years ago|
|.gitignore||4 years ago|
|CMakeLists.txt||2 years ago|
|LICENSE||4 years ago|
|README.md||3 years ago|
|randomx.sln||4 years ago|
RandomX is a proof-of-work (PoW) algorithm that is optimized for general-purpose CPUs. RandomX uses random code execution (hence the name) together with several memory-hard techniques to minimize the efficiency advantage of specialized hardware.
RandomX utilizes a virtual machine that executes programs in a special instruction set that consists of integer math, floating point math and branches. These programs can be translated into the CPU's native machine code on the fly (example: program.asm). At the end, the outputs of the executed programs are consolidated into a 256-bit result using a cryptographic hashing function (Blake2b).
RandomX can operate in two main modes with different memory requirements:
Both modes are interchangeable as they give the same results. The fast mode is suitable for "mining", while the light mode is expected to be used only for proof verification.
Full specification is available in specs.md.
Design description and analysis is available in design.md.
Between May and August 2019, RandomX was audited by 4 independent security research teams:
The first audit was generously funded by Arweave, one of the early adopters of RandomX. The remaining three audits were funded by donations from the Monero community. All four audits were coordinated by OSTIF.
Final reports from all four audits are available in the audits directory. None of the audits found any critical vulnerabilities, but several changes in the algorithm and the code were made as a direct result of the audits. More details can be found in the final report by OSTIF.
RandomX is written in C++11 and builds a static library with a C API provided by header file randomx.h. Minimal API usage example is provided in api-example1.c. The reference code includes a
randomx-tests executables for testing.
cmake (minimum 2.8.7) and
gcc (minimum version 4.8, but version 7+ is recommended).
To build optimized binaries for your machine, run:
git clone https://github.com/tevador/RandomX.git cd RandomX mkdir build && cd build cmake -DARCH=native .. make
To build portable binaries, omit the
ARCH option when executing cmake.
On Windows, it is possible to build using MinGW (same procedure as on Linux) or using Visual Studio (solution file is provided).
randomx-benchmark binaries are available on the Releases page.
RandomX was primarily designed as a PoW algorithm for Monero. The recommended usage is following:
Kis selected to be the hash of a block in the blockchain - this block is called the 'key block'. For optimal mining and verification performance, the key should change every 2048 blocks (~2.8 days) and there should be a delay of 64 blocks (~2 hours) between the key block and the change of the key
K. This can be achieved by changing the key when
blockHeight % 2048 == 64and selecting key block such that
keyBlockHeight % 2048 == 0.
His the standard hashing blob with a selected nonce value.
RandomX was successfully activated on the Monero network on the 30th November 2019.
If you wish to use RandomX as a PoW algorithm for your cryptocurrency, please follow the configuration guidelines.
Note: To achieve ASIC resistance, the key
K must change and must not be miner-selectable. We recommend to use blockchain data as the key in a similar way to the Monero example above. If blockchain data cannot be used for some reason, use a predefined sequence of keys.
The table below lists the performance of selected CPUs using the optimal number of threads (T) and large pages (if possible), in hashes per second (H/s). "CNv4" refers to the CryptoNight variant 4 (CN/R) hashrate measured using XMRig v2.14.1. "Fast mode" and "Light mode" are the two modes of RandomX.
|CPU||RAM||OS||AES||CNv4||Fast mode||Light mode|
|Intel Core i9-9900K||32G DDR4-3200||Windows 10||hw||660 (8T)||5770 (8T)||1160 (16T)|
|AMD Ryzen 7 1700||16G DDR4-2666||Ubuntu 16.04||hw||520 (8T)||4100 (8T)||620 (16T)|
|Intel Core i7-8550U||16G DDR4-2400||Windows 10||hw||200 (4T)||1700 (4T)||350 (8T)|
|Intel Core i3-3220||4G DDR3-1333||Ubuntu 16.04||soft||42 (4T)||510 (4T)||150 (4T)|
|Raspberry Pi 3||1G LPDDR2||Ubuntu 16.04||soft||3.5 (4T)||-||20 (4T)|
Note that RandomX currently includes a JIT compiler for x86-64 and ARM64. Other architectures have to use the portable interpreter, which is much slower.
SChernykh is developing GPU mining code for RandomX. Benchmarks are included in the following repositories:
The code from the above repositories is included in the open source miner XMRig.
Note that GPUs are at a disadvantage when running RandomX since the algorithm was designed to be efficient on CPUs.
Most Intel and AMD CPUs made since 2011 should be fairly efficient at RandomX. More specifically, efficient mining requires:
Due to the way the algorithm works, mining malware is much easier to detect. RandomX Sniffer is a proof of concept tool that can detect illicit mining activity on Windows.
Efficient mining requires more than 2 GiB of memory, which also disqualifies many low-end machines such as IoT devices, which are often parts of large botnets.
RandomX uses only operations that are guaranteed to give correctly rounded results by the IEEE 754 standard: addition, subtraction, multiplication, division and square root. Special care is taken to avoid corner cases such as NaN values or denormals.
The reference implementation has been validated on the following platforms:
RandomX generates multiple unique programs for every hash, so FPGAs cannot dynamically reconfigure their circuitry because typical FPGA takes tens of seconds to load a bitstream. It is also not possible to generate bitstreams for RandomX programs in advance due to the sheer number of combinations (there are 2512 unique programs).
Sufficiently large FPGAs can mine RandomX in a soft microprocessor configuration by emulating a CPU. Under these circumstances, an FPGA will be much less efficient than a CPU or a specialized chip (ASIC).
RandomX uses some source code from the following 3rd party repositories:
The author of RandomX declares no competing financial interest.
If you'd like to use RandomX, please consider donating to help cover the development cost of the algorithm.
Author's XMR address:
Total donations received: ~3.86 XMR (as of 30th August 2019). Thanks to all contributors.