Skip to main content

uhash_core/
lib.rs

1//! # uhash-core
2//!
3//! UniversalHash v4 — democratic proof-of-work hash engine.
4//!
5//! ## Primary API
6//!
7//! - [`hash`] — one-shot hash function
8//! - [`UniversalHash`] — reusable hasher (avoids re-allocation)
9//! - [`meets_difficulty`] / [`verify`] — proof verification
10//! - [`build_input`] / [`challenge_input`] — challenge utilities
11//!
12//! ## Lithium v1 Protocol
13//!
14//! The Lithium v1 adapter provides the canonical on-chain PoW surface:
15//!
16//! - [`lithium_header`]
17//! - [`lithium_preimage`]
18//! - [`lithium_hash`]
19//!
20//! ## no_std Support
21//!
22//! This crate supports `no_std` environments with the `alloc` crate:
23//!
24//! ```toml
25//! [dependencies]
26//! uhash-core = { version = "0.3", default-features = false }
27//! ```
28
29#![cfg_attr(not(feature = "std"), no_std)]
30
31#[cfg(not(feature = "std"))]
32extern crate alloc;
33
34mod challenge;
35mod hash;
36mod lithium;
37mod params;
38mod primitives;
39mod verify;
40
41#[cfg(feature = "std")]
42mod ffi;
43
44// Primary public API — hash engine
45pub use hash::{hash, UniversalHash};
46
47// Verification
48pub use verify::{meets_difficulty, verify};
49
50// Challenge utilities
51pub use challenge::{build_input, challenge_input, encode_difficulty};
52
53// Algorithm parameters
54pub use params::*;
55
56// Lithium v1 protocol adapter
57pub use lithium::{
58    lithium_hash, lithium_header, lithium_preimage, LithiumCanonicalVector, LITHIUM_BLOCK_HASH_LEN,
59    LITHIUM_CANONICAL_VECTORS, LITHIUM_CYBERLINKS_MERKLE_LEN,
60};
61
62#[cfg(test)]
63mod tests;