cryptonight

package
v0.0.0-...-e95cdce Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Generate code with minimal theoretical latency = 45 cycles, which is equivalent to 15 multiplications
	TOTAL_LATENCY = 15 * 3

	// Always generate at least 60 instructions
	NUM_INSTRUCTIONS_MIN = 60

	// Never generate more than 70 instructions (final RET instruction doesn't count here)
	NUM_INSTRUCTIONS_MAX = 70

	// Available ALUs for MUL
	// Modern CPUs typically have only 1 ALU which can do multiplications
	ALU_COUNT_MUL = 1

	// Total available ALUs
	// Modern CPUs have 4 ALUs, but we use only 3 because random math executes together with other main loop code
	ALU_COUNT = 3
)
View Source
const (
	MUL                  = iota // a*b
	ADD                         // a+b + C, C is an unsigned 32-bit constant
	SUB                         // a-b
	ROR                         // rotate right "a" by "b & 31" bits
	ROL                         // rotate left "a" by "b & 31" bits
	XOR                         // a^b
	RET                         // finish execution
	V4_INSTRUCTION_COUNT = RET
)
View Source
const (
	V4_OPCODE_BITS    = 3
	V4_DST_INDEX_BITS = 2
	V4_SRC_INDEX_BITS = 3
)
View Source
const REG_BITS = 32

Variables

This section is empty.

Functions

func Algo

func Algo() []string

func TestSum

func TestSum(variant string) bool

Types

type CryptoNight

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

func NewCryptoNight

func NewCryptoNight() *CryptoNight

func (*CryptoNight) Sum

func (cn *CryptoNight) Sum(data []byte, variant string, height uint64) []byte

Sum calculate a CryptoNight hash digest. The return value is exactly 32 bytes long.

When variant is 1, data is required to have at least 43 bytes. This is assumed and not checked by Sum. If this condition doesn't meet, Sum will panic straightforward.

type V4_Instruction

type V4_Instruction struct {
	C uint32
	// contains filtered or unexported fields
}

Directories

Path Synopsis
inter
aes
Package aes implements AES utilities for CryptoNight usage.
Package aes implements AES utilities for CryptoNight usage.
blake256
Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).
Package blake256 implements BLAKE-256 and BLAKE-224 hash functions (SHA-3 candidate).
groestl
Package groestl implements Grøstl-256 algorithm.
Package groestl implements Grøstl-256 algorithm.
jh
Package jh implements JH-256 algorithm.
Package jh implements JH-256 algorithm.
ripemd160
Package ripemd160 implements the RIPEMD-160 hash algorithm.
Package ripemd160 implements the RIPEMD-160 hash algorithm.
sha3
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
Package sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE variable-output-length hash functions defined by FIPS-202.
skein
Package skein implements the Skein512 hash function based on the Threefish tweakable block cipher.
Package skein implements the Skein512 hash function based on the Threefish tweakable block cipher.
skein/skein1024
Package skein1024 implements the Skein1024 hash function based on the Threefish1024 tweakable block cipher.
Package skein1024 implements the Skein1024 hash function based on the Threefish1024 tweakable block cipher.
skein/skein256
Package skein256 implements the Skein256 hash function based on the Threefish256 tweakable block cipher.
Package skein256 implements the Skein256 hash function based on the Threefish256 tweakable block cipher.
skein/threefish
Package threefish implements the Threefish tweakable block cipher.
Package threefish implements the Threefish tweakable block cipher.

Jump to

Keyboard shortcuts

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