randomy

package module
v0.0.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2023 License: BSD-3-Clause Imports: 9 Imported by: 2

README

Go-randomy

This is a binding for Random-Y based algorithms.

Do NOT use go mod import this.

For better go.mod experience, like directly import go-randomy dep through go get or go build, check the https://github.com/core-coin/RandomY and https://github.com/core-coin/go-randomy and their GitHub actions.

Algorithms

  • random-y
  • random-x
  • random-xl
  • random-wow
  • random-arq
  • random-yada

Build

Windows
  1. Download and install the msys2, then open and install the following components:

Take msys2's pacman for example

pacman -Syu
pacman -S git mingw64/mingw-w64-x86_64-go mingw64/mingw-w64-x86_64-gcc mingw64/mingw-w64-x86_64-cmake mingw64/mingw-w64-x86_64-make
  1. Clone this repo to your project folder
cd MyProject
git clone https://github.com/core-coin/go-randomy
  1. Run ./build.sh to auto compile official random-y code
# clone and compile RandomY source code into librandomy
./build random-y # random-y can be replaced with random-xl random-arq random-wow
  1. You can use the package as your internal one.

Directly using it with import "github.com/MyProject/go-randomy" and then randomy.AllocCache() etc.

Linux
  1. Download the latest go from web and then install it following this instructions.
sudo apt update && sudo apt upgrade
sudo apt install git cmake make gcc build-essential
  1. Clone this repo to your project folder.
cd MyProject
git clone https://github.com/core-coin/go-randomy
  1. Run go generate to auto compile official random-y code.
# clone and compile RandomY source code into librandomy
./build random-y # random-y can be replaced with random-xl random-arq random-wow
  1. You can using the package as your internal one.

Directly using it with import "github.com/myname/my-project/go-randomy" and then start the functions like randomy.AllocCache() etc.

License

The 3-Clause BSD License

Documentation

Index

Constants

View Source
const (
	FlagDefault     C.randomx_flags = 8 + 4 // for all default
	FlagLargePages  C.randomx_flags = 1     // for dataset & rxCache & vm
	FlagHardAES     C.randomx_flags = 2     // for vm
	FlagFullMEM     C.randomx_flags = 4     // for vm
	FlagJIT         C.randomx_flags = 8     // for vm & cache
	FlagSecure      C.randomx_flags = 16
	FlagArgon2SSSE3 C.randomx_flags = 32 // for cache
	FlagArgon2AVX2  C.randomx_flags = 64 // for cache
	FlagArgon2      C.randomx_flags = 96 // = avx2 + sse3
)

All flags

View Source
const RxHashSize = C.RANDOMX_HASH_SIZE

Variables

This section is empty.

Functions

func CalculateHash

func CalculateHash(vm VM, in []byte) []byte

func CalculateHashFirst

func CalculateHashFirst(vm VM, in []byte)

func CalculateHashNext

func CalculateHashNext(vm VM, in []byte) []byte

func DatasetItemCount

func DatasetItemCount() uint32

func DestroyVM

func DestroyVM(vm VM)

func GetDatasetMemory

func GetDatasetMemory(dataset Dataset) unsafe.Pointer

func GetFlags

func GetFlags() C.randomx_flags

func InitCache

func InitCache(cache Cache, seed []byte)

func InitDataset

func InitDataset(dataset Dataset, cache Cache, startItem uint32, itemCount uint32)

func RandomY added in v0.0.9

func RandomY(vm *RandyVm, mutex *sync.Mutex, hash []byte, nonce uint64) ([]byte, error)

func ReleaseCache

func ReleaseCache(cache Cache)

func ReleaseDataset

func ReleaseDataset(dataset Dataset)

func SHA3_512

func SHA3_512(data ...[]byte) []byte

NIPS implementation of SHA3-512

func SetVMCache

func SetVMCache(vm VM, cache Cache)

func SetVMDataset

func SetVMDataset(vm VM, dataset Dataset)

Types

type Cache

type Cache *C.randomx_cache

func AllocCache

func AllocCache(flags ...C.randomx_flags) (Cache, error)

type Dataset

type Dataset *C.randomx_dataset

func AllocDataset

func AllocDataset(flags ...C.randomx_flags) (Dataset, error)

type RandyVm added in v0.0.9

type RandyVm struct {
	// contains filtered or unexported fields
}

func NewRandomYVMWithKeyAndMutex added in v0.0.9

func NewRandomYVMWithKeyAndMutex() (*RandyVm, *sync.Mutex)

func NewRandyVm added in v0.0.9

func NewRandyVm(key []byte) (ret *RandyVm, err error)

func (*RandyVm) Close added in v0.0.9

func (this *RandyVm) Close()

func (*RandyVm) Hash added in v0.0.9

func (this *RandyVm) Hash(buf []byte) (ret []byte)

type VM

type VM *C.randomx_vm

func CreateVM

func CreateVM(cache Cache, dataset Dataset, flags ...C.randomx_flags) (VM, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL