Expand description
§uhash-core
UniversalHash v4 — democratic proof-of-work hash engine.
§Primary API
hash— one-shot hash functionUniversalHash— reusable hasher (avoids re-allocation)meets_difficulty/verify— proof verificationbuild_input/challenge_input— challenge utilities
§Lithium v1 Protocol
The Lithium v1 adapter provides the canonical on-chain PoW surface:
§no_std Support
This crate supports no_std environments with the alloc crate:
[dependencies]
uhash-core = { version = "0.3", default-features = false }Structs§
- Lithium
Canonical Vector - Canonical lithium-v1 vector tuple shared across crates/tests.
- 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
- LITHIUM_
BLOCK_ HASH_ LEN - Fixed block hash length for lithium v1 preimage.
- LITHIUM_
CANONICAL_ VECTORS - Shared canonical vectors used by core/web/consumer parity tests.
- LITHIUM_
CYBERLINKS_ MERKLE_ LEN - Fixed cyberlinks merkle length for lithium v1 preimage.
- 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§
- build_
input - Build PoW input bytes from a challenge header and nonce.
- challenge_
input - Build PoW input from a typed Challenge and nonce.
- encode_
difficulty - Encode a difficulty as leading zero bit count.
- hash
- Convenience function for single-shot hashing
- lithium_
hash - Compute lithium v1 PoW hash using UniversalHash engine:
UniversalHash(SHA256(miner_address || block_hash || cyberlinks_merkle) || nonce_le). - lithium_
header - Build canonical lithium header bytes:
SHA256(miner_address_utf8 || block_hash_32 || cyberlinks_merkle_32). - lithium_
preimage - Build canonical lithium PoW input bytes:
lithium_header || nonce_le_u64. - meets_
difficulty - Check if a hash meets the required difficulty (leading zero bits).
- verify
- Verify a proof: recompute hash and check difficulty.