cryptonight

package module
v0.0.0-...-828e5b0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: MIT Imports: 20 Imported by: 0

README

CrptoNight-go

A new variant of the origin cryptonight algorithm

Goal?

Fully written on Golang. Can be easily compiled to every platform.

For faster hashrate. The hash faster, the synchronization faster.

For ASIC-resistance. ASIC-resistance is required to keep network safe.

What's changed?

We studied other CryptoNight variants like lite, turtle upx and so on.

At first, changing the Iteration from 524,288 to 65,536, it will lead to much less iterating simple calculations. The hashrate will get quite a increases.

Then is turn to change the Scratchpad. As everyone known, the key to ASIC-resistant in CryotoNote series coins is that Scratchpad make the CryptoNight algorithm memory-hard. We’re dropping the scratch pad size in fourth, from From 2MB to 512KB. And the hashrate gets around 8 times.

After boosting the speed of hashing, we changed the finalHash period to ensure the ASIC-resistance.

We added 8 more algorithm, and let them randomly occur according by the number, which equals the first byte of the last sum result mods 12. It's similar to X16r, but not same.

As for why the memory-hard in CryptoNight and randomness in X16r lead to ASIC-resistance, there are more authoritative papers on internet or bitcointalk. So we will not talk this on such a little repo README.

Ref

most codes forked from github.com/Equim-chan/cryptonight.

Modified by ngin-network Team.

Documentation

Overview

Package cryptonight implements CryptoNight hash function and some of its variant. Original CryptoNight algorithm is defined in CNS008 at https://cryptonote.org/cns/cns008.txt

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHash

func CheckHash(hash []byte, diff uint64) bool

CheckHash checks hash's difficulty against diff. It returns true if hash's difficulty is equal to or greater than diff.

if len(hash) != 32, the return value is always false.

CheckHash should be prefered over Difficulty if you only want to check if some hash passes a specific difficulty, as CheckHash is very fast and requires no heap allocation. It actually checks (hashDiff * diff) < 2^256 instead of calculating the exact value of hashDiff.

This function is a port of monero: src/cryptonote_basic/difficulty.cpp:check_hash

This isn't a part of CryptoNight, but since such demand of checking difficulty is too common, it is thus included in this package.

func Difficulty

func Difficulty(hash []byte) uint64

Difficulty returns hash's difficulty.

If len(hash) != 32, the return value is always 0.

Difficulty is slower than CheckHash, so it should only be used when necessary, for example when you want to tell the exact difficulty value of a hash.

This isn't a part of CryptoNight, but since such demand of checking difficulty is too common, it is thus included in this package.

func Sum

func Sum(data []byte, variant int) []byte

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

Types

This section is empty.

Directories

Path Synopsis
cmd
Package groestl implements Grøstl-256 algorithm.
Package groestl implements Grøstl-256 algorithm.
internal
aes
Package aes implements AES utilities for CryptoNight usage.
Package aes implements AES utilities for CryptoNight usage.
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.
Package jh implements JH-256 algorithm.
Package jh implements JH-256 algorithm.

Jump to

Keyboard shortcuts

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