dart_randomx

Creator: coderz1093

Last updated:

0 purchases

dart_randomx Image
dart_randomx Images

Languages

Categories

Add to Cart

Description:

dart randomx

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();
}
copied to clipboard
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);
}
copied to clipboard
Library Binaries #
This package already comes with built-in binaries for the RandomX wrapper library.
They are located at the sub-directory wrapper_randomx_library/:

libwrapper_randomx.dll (Windows x64)
libwrapper_randomx.so (Linux x64)
libwrapper_randomx-x64.dylib (macOS x64)
libwrapper_randomx-arm64.dylib (macOS ARM64)

Project Build #
See the script build-ffi-lib.sh to build the libraries:

randomx: the RandomX PoW algorithm.
wrapper_randomx: dart:ffi wrapper of lib randomx.

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 at wrapper_randomx_library/ to then build the wrapper.


build-wrapper.sh:
Builds the wrapper, linking with librandomx.a.


For Windows support see the file wrapper_randomx_library/build-all-mingw64.sh.
You will need to install MSYS2 and some packages:
pacman -S --needed development
pacman -S --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-gcc
pacman -S --needed ninja
copied to clipboard
NOTE: The build process was tested on macOS 11, Linux (Ubuntu 18) and Windows 10.
RandomX Project #
The RandomX proof-of-work (PoW) algorithm can be found at:

https://github.com/tevador/RandomX

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:

https://github.com/tevador/RandomX/blob/master/doc/configuration.md

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

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.