hashcash

package
v0.0.0-...-a1a29da Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: Unlicense Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxDifficulty = 32 // Can be modified by the compiler

Variables

View Source
var DefaultHashAlgorithm = sha3.New512

Functions

func CountLeadingBits

func CountLeadingBits(s []byte) (n int)

func LogDifficulty

func LogDifficulty(algo hash.Hash, peers int64) (x uint64)

func New

func New(ctx context.Context, h hash.Hash, bits uint64, salt, payload string) (hc string, err error)

Creates a hashcash (hc) hash is reset on every try

func SqrtDifficulty

func SqrtDifficulty(algo hash.Hash, peers int64) (x uint64)

func Verify

func Verify(h hash.Hash, hc string) (err error)

Verifies a hashcash is valid. Returns nil on valid And error if the hash is invalid

func VerifyWithDifficultyAndPayload

func VerifyWithDifficultyAndPayload(h hash.Hash, hc string, difficulty uint64, payload string) (err error)

Same as Verify but checks the if needed bits is greater or equal to the passed difficulty

Types

This section is empty.

Jump to

Keyboard shortcuts

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