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 withdifficultybytes of ASCII ‘0’ (0x30).LeadingZeroBits: hash must have at leastdifficultyleading 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 modeModules§
Structs§
- Argon2
Params - Argon2 password hash parameters.
- PoW
- Struct representing Proof of Work (PoW) with data, difficulty, and algorithm.
- Scrypt
Params - The Scrypt parameter values.
Enums§
- Difficulty
Mode - Difficulty modes supported by PoW.
- PoWAlgorithm
- Enum defining different Proof of Work (PoW) algorithms.
Functions§
- meets_
leading_ zero_ bits - Utility: check whether
hashhas at leastbitsleading zero bits.