Expand description
§UniversalHash Core Algorithm
A democratic proof-of-work algorithm designed for fair mining where smartphones can meaningfully compete with servers.
v0.2.0 - Full spec compliance with UniversalHash v4 specification.
§Features
- Spec-Compliant: Implements UniversalHash v4 specification exactly
- Democratic Mining: Phone-to-desktop ratio of 1:3-5
- ASIC Resistance: Multi-primitive design (AES + SHA-256 + BLAKE3)
- Memory-Hard: 2MB scratchpad prevents GPU parallelism
§Algorithm Parameters (v4)
- 4 parallel computation chains
- 512KB scratchpad per chain (2MB total)
- 12,288 rounds per chain
- Triple primitive rotation: AES, SHA-256, BLAKE3
§Input Format
The algorithm extracts the nonce from the last 8 bytes of input:
input = header || nonce
^^^^^^ ^^^^^
any len 8 bytes (little-endian u64)Typical mining format: epoch_seed (32B) || miner_address (20B) || timestamp (8B) || nonce (8B)
§Example
use uhash_core::{UniversalHash, hash, meets_difficulty};
// Single-shot hashing
let result = hash(b"input data");
// Check difficulty (leading zero bits)
if meets_difficulty(&result, 16) {
println!("Found hash with 16+ leading zero bits!");
}
// Reusable hasher (avoids re-allocation)
let mut hasher = UniversalHash::new();
let hash1 = hasher.hash(b"first");
let hash2 = hasher.hash(b"second");§no_std Support
This crate supports no_std environments with the alloc crate:
[dependencies]
uhash-core = { version = "0.2", default-features = false }Structs§
- Universal
Hash - UniversalHash v4 hasher
Constants§
- AES_
BLOCK_ SIZE - AES block size
- BLAK
E3_ SIZE - BLAKE3 output size
- BLOCKS_
PER_ SCRATCHPAD - Number of blocks per scratchpad
- BLOCK_
SIZE - Block size in bytes for memory operations
- CHAINS
- Number of parallel computation chains
- ROUNDS
- Number of rounds per chain (spec: 12,288)
- SCRATCHPAD_
SIZE - Scratchpad size per chain in bytes (512 KB)
- SHA256_
SIZE - SHA-256 output size
- TOTAL_
MEMORY - Total memory footprint (2 MB)
- VERSION
- Algorithm version
Functions§
- hash
- Convenience function for single-shot hashing
- meets_
difficulty - Check if a hash meets the required difficulty