Skip to main content

Crate uhash_core

Crate uhash_core 

Source
Expand description

§uhash-core

UniversalHash v4 — democratic proof-of-work hash engine.

§Primary API

§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§

LithiumCanonicalVector
Canonical lithium-v1 vector tuple shared across crates/tests.
UniversalHash
UniversalHash v4 hasher

Constants§

AES_BLOCK_SIZE
AES block size
BLAKE3_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.