Skip to main content

Crate traversev

Crate traversev 

Source
Expand description

§TraverseV

Crates.io Version Crates.io License docs.rs

Pure Rust implementation of a memory-hard proof-of-work construction, producing trustless and permissioned proofs.

Documentation

§About

TraverseV builds a memory-hard structure once through a multi-pass fill in which each block is derived from previously computed blocks using data-dependent addressing and a mixing function adapted from Argon2d. Candidate nonce values are then evaluated against that structure through a sequential, read-only traversal derived from scrypt, in which each round’s memory access depends on the result of the previous round.

Whether a TraverseV instance produces trustless or permissioned proofs is fixed at construction.

  • A Trustless instance is built from application context and parameters. Its proofs are based on the BLAKE3 regular hash function, and are verifiable by any instance sharing the same configuration.
  • A Permissioned instance is built from a shared secret, application context, and parameters. Its proofs are based on the BLAKE3 keyed hash function, and are verifiable only by instances sharing the same configuration and shared secret.

Mining searches over nonce values until one meets the target difficulty, while verifying a candidate is cheap and does not require repeating that search.

§Minimum Supported Rust Version

Rust 1.85.1 or higher.

§License

Licensed under the MIT License.

§Example

use traversev::{Params, TraverseV};

fn main() {
    let params = Params::new(12 * 1024, 3, 8, 12).unwrap();
    let context = "65daysofstatic";

    // Build a trustless instance
    let miner = TraverseV::new_trustless(context, params);

    // Mine for a trustless proof over some input
    let input = b"65 Doesn't Understand You";
    let proof: u128 = miner.mine(input, 0u128, 1);

    // Any trustless instance with the same configuration can verify
    let verifier = TraverseV::new_trustless(context, params);
    assert!(verifier.verify(input, proof));

    // Build a permissioned instance with a shared secret
    let secret = b"One Time for All Time";
    let miner = TraverseV::new_permissioned(secret, context, params);

    // A trustless instance cannot verify a permissioned proof
    let proof: u128 = miner.mine(input, 0u128, 1);
    assert!(!verifier.verify(input, proof));
}

§Features

The zeroize feature (disabled by default) implements ZeroizeOnDrop for TraverseV, and zeroises intermediate values on a best-effort basis.

Structs§

Block
One block of memory as 128 little-endian u64 words.
Params
TraverseV proof-of-work parameters.
TraverseV
TraverseV proof-of-work instance.

Enums§

Mode
Indicates whether a TraverseV instance produces trustless or permissioned proofs.
TraverseVErr
Errors returned by TraverseV.