Crate rspow

Crate rspow 

Source
Expand description

RSPOW: simple multi-algorithm proof-of-work utilities.

Supported algorithms:

  • SHA-256, SHA-512, RIPEMD-320
  • Scrypt, Argon2id (with custom Params)

Difficulty modes:

  • AsciiZeroPrefix (default): hash must start with difficulty bytes of ASCII ‘0’ (0x30).
  • LeadingZeroBits: hash must have at least difficulty leading zero bits (big-endian within bytes).

Quick examples:

use rspow::{PoW, PoWAlgorithm};

let data = "hello";
let algorithm = PoWAlgorithm::Sha2_256;
let pow = PoW::new(data, 2, algorithm).unwrap();
let target = pow.calculate_target();
let (_hash, _nonce) = pow.calculate_pow(&target);
use rspow::{PoW, PoWAlgorithm, DifficultyMode};

let data = "hello";
let pow = PoW::with_mode(data, 10, PoWAlgorithm::Sha2_256, DifficultyMode::LeadingZeroBits).unwrap();
let (_hash, _nonce) = pow.calculate_pow(&[]); // target ignored in bits mode

Modules§

bench
kpow
KPoW: k puzzles with an alpha-sized worker pool and a central scheduler.

Structs§

Argon2Params
Argon2 password hash parameters.
PoW
Struct representing Proof of Work (PoW) with data, difficulty, and algorithm.
ScryptParams
The Scrypt parameter values.

Enums§

DifficultyMode
Difficulty modes supported by PoW.
PoWAlgorithm
Enum defining different Proof of Work (PoW) algorithms.

Functions§

meets_leading_zero_bits
Utility: check whether hash has at least bits leading zero bits.