Dart wrapper for RandomX proof-of-work (PoW) algorithm
dart_randomx
Dart wrapper for RandomX proof-of-work (PoW) algorithm.
Usage
A simple usage example:
import 'dart:typed_data';
import 'package:dart_randomx/dart_randomx.dart';
Future<void> main() async {
await RandomX.loadLib();
var randomX = RandomX();
print(randomX);
var key = Uint8List.fromList([97, 98, 99, 100, 101, 102, 0]);
randomX.init(key);
var data = Uint8List.fromList([65, 66, 67, 68, 69, 0]);
var hash = randomX.hash(data);
print(hash);
randomX.destroy();
}
RandomX Full Memory
The RandomX
algorithm has 2 modes:
slow
: uses less memory but is slower.fast
: faster (about 10x) but uses 2G+ of memory.
To activate the fast mode just initialize it passing fullMemory
as true
:
Future<void> main() async {
await RandomX.loadLib();
var randomX = RandomX();
randomX.init(key, fullMemory: true);
}
Project Build
See the script build-ffi-lib.sh
to build the libraries:
randomx
: the RandomXPoW
algorithm.wrapper_randomx
: dart:ffi wrapper of librandomx
.
The directory wrapper_randomx_library
has the source code for the
dart:ffi wrapper and the build scripts:
-
build-librandomx.sh
:Will clone the
RandomX
project, build it and place the library file
librandomx.a
atwrapper_randomx_library/
to then build the wrapper. -
build-wrapper.sh
:Builds the wrapper, linking with
librandomx.a
.
NOTE: This process was tested on MaxOS
and Ubuntu
.
RandomX Project
The RandomX proof-of-work (PoW) algorithm can be found at:
NOTE: The script build-librandomx.sh
automatically clones and builds it.
RandomX Configuration
The RandomX
project recommends a different configuration for each coin,
defined by the file RandomX/src/configuration.h
. See the configuration documentation:
The default configuration for this project is the same of Monero
:
wrapper_randomx_library/configuration-monero.h
NOTE: RandomX
was originally developed for Monero
.*
Author
Graciliano M. Passos: gmpassos@GitHub.
License
BSD-3-Clause License