xelishash

package module
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 6 Imported by: 0

README

Go XELIS Hash

A pure-Go XELIS Proof of Work hash CPU implementation. It's about half as fast than the reference Rust implementation.

Documentation

Index

Constants

View Source
const BUFFER_SIZE = 42
View Source
const BUFFER_SIZE_V2 = MEMORY_SIZE_V2 / 2

Buffer size for stage 3 (inner loop iterations)

View Source
const BYTES_ARRAY_INPUT = KECCAK_WORDS * 8
View Source
const CHUNK_SIZE_V2 = 32

Stage 1 config

View Source
const HASH_SIZE = 32
View Source
const ITERS = 1
View Source
const KECCAK_WORDS = 25

Untweakable parameters

View Source
const KEY = "xelishash-pow-v2"

Stage 3 AES key

View Source
const MEMORY_SIZE = 32768
View Source
const MEMORY_SIZE_V2 = 429 * 128

These are tweakable parameters Memory size is the size of the scratch pad in u64s In bytes, this is equal to ~ 440KB

View Source
const NONCE_SIZE_V2 = 12
View Source
const OUTPUT_SIZE_V2 = MEMORY_SIZE_V2 * 8
View Source
const SCRATCHPAD_ITERS = 5000
View Source
const SCRATCHPAD_ITERS_V2 = 3

ScratchPadV2 iterations in stage 3

View Source
const SLOT_LENGTH = 256
View Source
const STAGE_1_MAX = MEMORY_SIZE / KECCAK_WORDS

Variables

This section is empty.

Functions

func XelisHash

func XelisHash(input []byte, scratch_pad *ScratchPad) [32]byte

func XelisHashV2 added in v1.6.0

func XelisHashV2(input []byte, scratch_pad *ScratchPadV2) [32]byte

This function is used to hash the input using the generated scratch pad NOTE: The ScratchPadV2 is completely overwritten in stage 1 and can be reused without any issues

Types

type Hash

type Hash [HASH_SIZE]byte

type ScratchPad

type ScratchPad [MEMORY_SIZE]uint64

type ScratchPadV2 added in v1.6.0

type ScratchPadV2 [MEMORY_SIZE_V2]uint64

ScratchPadV2 used to store intermediate values It has a fixed size of `MEMORY_SIZE_V2` u64s It can be easily reused for multiple hashing operations safely

type ThreadPool added in v1.5.0

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

func NewThreadPool added in v1.5.0

func NewThreadPool(threads int) *ThreadPool

func (*ThreadPool) Hash added in v1.6.0

func (t *ThreadPool) Hash(algo string, input []byte) [32]byte

Hash accepts algorithm name as string (example: xel/0, xel/1)

func (*ThreadPool) XelisHash added in v1.5.0

func (t *ThreadPool) XelisHash(input []byte) [32]byte

func (*ThreadPool) XelisHashV2 added in v1.6.0

func (t *ThreadPool) XelisHashV2(input []byte) [32]byte

Jump to

Keyboard shortcuts

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