Crates.io | blake3-pow |
lib.rs | blake3-pow |
version | |
source | src |
created_at | 2025-02-10 12:37:50.275919+00 |
updated_at | 2025-03-20 18:59:22.822362+00 |
description | A Proof of Work scheme using the blake3 hash function |
homepage | |
repository | https://gitlab.com/mateolafalce/blake3-pow |
max_upload_size | |
id | 1549989 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Fork from Samuel Schlesinger repository for the kkv project.
A proof of work algorithm using the Blake3 cryptographic hash function.
let cost = 20;
let bytes = b"Hello, world!";
// client side
let nonce = blake3_pow::search(bytes, cost)?;
// server side
assert!(blake3_pow::verify(bytes, nonce, cost));
The main point is: we present some bytes
and we say that a "proof of work"
for some cost
is a nonce : [u8; NONCE_SIZE]
such that the hash of nonce
concatenated to bytes
has cost
leading zeros.
To verify
such a proof, we compute the hash and check if it has cost
leading
zeros. To search
for such a proof, we continually generate random nonce
s until
we guess one which constitutes a proof of work. That is to say, we randomly
guess until we get it right.
When you want to expose functionality to the outside world without allowing bots to take advantage of it at any frequency, you must meter usage somehow. By requesting that API calls come affixed with a proof of costly work associated with the particular request, you can acheive this in a stateless way.
git clone https://gitlab.com/mateolafalce/blake3-pow.git
cd blake3-pow
cargo run --example http_pow