Crate blake3_pow

Source
Expand description

§Proof of Work

The classic proof of work system based on a cryptogarphic hash function, in this case Blake3. To be explicit, a proof of work for some bytes : &[u8] and cost : u32 is a nonce : [u8; NONCE_SIZE] such that the Blake3 hash of nonce appended to bytes has at least cost leading zeros.

This crate provides functionality for searching and verifying this sort of proof of work.

§Example

let cost = 20;
let bytes = b"Hello, world!";
// client side
let nonce = blake3_pow::search(bytes, cost).expect("Search fails");
// server side
if blake3_pow::verify(bytes, nonce, cost) {
    println!("This PoW is valid!");    
}

Enums§

Error
Errors which can occur in searching for a proof of work.

Constants§

NONCE_SIZE
Predefine nonce size

Functions§

leading_zeros
Computes the number of leading zeros in the given byte array.
search
Proof-of-Work Search
verify
Proof of Work Verification