| Crates.io | chrono-merkle |
| lib.rs | chrono-merkle |
| version | 1.2.0 |
| created_at | 2026-01-12 22:35:38.366236+00 |
| updated_at | 2026-01-19 03:40:20.613363+00 |
| description | Time-aware Merkle tree with delta-based updates and programmable nodes |
| homepage | |
| repository | https://github.com/clockinchain/chrono-merkle |
| max_upload_size | |
| id | 2038983 |
| size | 281,902 |
Time-aware Merkle trees for blockchain, audit trails, and secure data verification
ChronoMerkle provides a production-ready, cryptographically secure implementation of time-aware Merkle trees with delta-based updates, programmable validation nodes, and sparse timestamp indexing. Perfect for blockchain applications, compliance logging, audit trails, and time-series data integrity verification.
Add this to your Cargo.toml:
[dependencies]
chrono-merkle = "1.1"
ChronoMerkle uses feature flags to keep your binary size small. The default feature set includes essential functionality:
| Feature | Description | Default |
|---|---|---|
serde |
Serialization/deserialization support | โ |
std |
Standard library support | โ |
blake3-hash |
Blake3 cryptographic hasher | โ |
sha2-hash |
SHA-256 cryptographic hasher | โ |
clockhash |
ClockHash trace compression integration | โ |
parallel |
Parallel tree operations with Rayon | โ |
storage |
Storage backend support | โ |
memory-storage |
In-memory storage backend | โ |
file-storage |
File-based persistent storage | โ |
postgres-storage |
PostgreSQL database backend | โ |
redis-storage |
Redis cache backend | โ |
no-std |
Embedded/no_std compatibility | โ |
wasm |
WebAssembly support | โ |
visualization |
ASCII/DOT/JSON tree visualization | โ |
security-logging |
Enhanced security event logging | โ |
default: serde, std, blake3-hashserde: Serialization support with serdestd: Standard library support (enabled by default)blake3-hash: Blake3 hasher (enabled by default)sha2-hash: SHA-256 hasherclockhash: ClockHash integration for trace compressionparallel: Parallel tree operations with Rayonstorage: Storage backend supportfile-storage: File-based storagememory-storage: In-memory storage (enabled with storage)postgres-storage: PostgreSQL storage backendredis-storage: Redis storage backendno-std: Embedded/no-std supportwasm: WebAssembly supportvisualization: ASCII/DOT/JSON visualizationuse chrono_merkle::{ChronoMerkleTree, Blake3Hasher};
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new ChronoMerkle tree with Blake3 hashing
let mut tree = ChronoMerkleTree::new(Blake3Hasher::default());
// Insert data with timestamps (Unix timestamps)
tree.insert(b"Hello World", 1000)?;
tree.insert(b"ChronoMerkle", 1001)?;
tree.insert(b"Time-aware", 1002)?;
// Generate cryptographic proof for data inclusion
let proof = tree.generate_proof(0)?;
let is_valid = tree.verify_proof(&proof)?;
assert!(is_valid);
println!("โ
Proof verified successfully!");
// Time-based range queries
let results = tree.find_range(1000, 1002);
println!("Found {} entries in time range", results.len());
// Rollback to previous state
tree.rollback_to_timestamp(1001)?;
println!("Rolled back to timestamp 1001, tree now has {} leaves", tree.leaf_count());
Ok(())
}
Traditional Merkle trees provide data integrity but lack temporal awareness. ChronoMerkle bridges this gap by combining:
# Basic tree operations and proof generation
cargo run --example basic_usage
# Blockchain-style operations with transaction validation
cargo run --example blockchain_example
# Custom validation rules and programmable nodes
cargo run --example programmable_nodes
# ClockHash integration for trace compression (requires clockhash feature)
cargo run --example clockhash_integration --features clockhash
# Test all examples
cargo run --example basic_usage
cargo run --example blockchain_example
cargo run --example programmable_nodes
cargo run --example clockhash_integration --features clockhash
ChronoMerkle is built around a modular, cryptographically secure architecture designed for high-performance temporal data integrity.
| Component | Purpose |
|---|---|
ChronoMerkleTree |
Main tree structure with time-aware operations and delta updates |
SparseIndex |
Efficient timestamp-based indexing for O(log n) temporal queries |
ChronoProof |
Cryptographic inclusion proofs with delta chain verification |
| Node Types | Leaf (data), Internal (hashes), Delta (changes), Programmable (validation) |
| Storage Backends | Pluggable persistence: Memory, File, PostgreSQL, Redis |
| Security Logger | Audit trail and security event logging |
Traditional Merkle trees rebuild entire branches on updates. ChronoMerkle uses delta nodes to track changes incrementally:
// Instead of rebuilding the entire tree...
tree.insert(data, timestamp)?;
// ...only affected branches are updated with delta tracking
let delta = tree.compute_delta(old_root, new_root)?;
tree.apply_delta(delta)?;
Benefits: 10-100x faster updates for large trees, minimal memory overhead.
Time-based queries are optimized through configurable sparse indexing:
// Configurable sparsity (e.g., every 10th timestamp)
let config = TreeConfig {
sparse_index_sparsity: 10,
..Default::default()
};
// Enables O(log n) range queries
let results = tree.find_range(start_timestamp, end_timestamp)?;
Embed business logic directly into tree structure:
// Custom validation at tree nodes
let validator = |node: &Node, proof: &ChronoProof| -> Result<bool> {
// Your business rules here
match node.node_type() {
NodeType::Programmable => validate_business_rules(node, proof),
_ => Ok(true)
}
};
tree.add_programmable_node(validator)?;
ChronoMerkle implements multiple layers of cryptographic security:
use chrono_merkle::{ChronoMerkleTree, HashFunction};
// Implement your own hasher
#[derive(Clone, Default)]
struct MyHasher;
impl HashFunction for MyHasher {
type Output = [u8; 32];
fn hash(&self, data: &[u8]) -> Self::Output {
// Your hashing logic here
[0; 32] // Placeholder
}
fn hash_pair(&self, left: &Self::Output, right: &Self::Output) -> Self::Output {
// Hash combination logic
[0; 32] // Placeholder
}
}
let tree = ChronoMerkleTree::new(MyHasher::default());
use chrono_merkle::{ChronoMerkleTree, Blake3Hasher};
let mut tree = ChronoMerkleTree::new(Blake3Hasher::default());
// Add data that should pass your validation rules
tree.insert(b"valid_data", 1000)?;
// Tree maintains validation state
assert!(tree.is_valid());
use chrono_merkle::{ChronoMerkleTree, Blake3Hasher, MemoryStorage};
#[cfg(feature = "storage")]
{
let mut tree = ChronoMerkleTree::new(Blake3Hasher::default());
tree.insert(b"persistent_data", 1000)?;
// Save to storage
let storage = MemoryStorage::new();
tree.save_state(&storage, "my_tree")?;
// Load from storage
let loaded_tree = ChronoMerkleTree::load_state(&storage, "my_tree", Blake3Hasher::default())?;
}
ChronoMerkle is optimized for high-throughput, time-sensitive applications with enterprise-scale datasets.
| Operation | Complexity | Typical Performance | Notes |
|---|---|---|---|
| Tree Construction | O(1) | ~5ns empty tree | Minimal overhead |
| Data Insertion | O(log n) | ~50ฮผs for 1000 entries | Delta-based updates |
| Proof Generation | O(log n) | ~25ฮผs for 1000 entries | Cryptographic security |
| Proof Verification | O(log n) | ~15ฮผs for 1000 entries | Constant-time |
| Time Range Queries | O(log n) | ~10ฮผs for 10K entries | Sparse index optimized |
| Rollback Operations | O(log n) | ~30ฮผs for 1000 entries | Delta chain replay |
# Run comprehensive benchmarks
cargo bench
# Key benchmark results (typical performance on modern hardware):
tree_construction/create_empty_tree time: ~5.5 ns
tree_construction/insert_1000_leaves time: ~45 ฮผs
proof_operations/generate_proof time: ~25 ฮผs
proof_operations/verify_proof time: ~15 ฮผs
query_operations/range_query_10000 time: ~10 ฮผs
Send + Sync guaranteesWe welcome contributions from developers, security researchers, and the broader Rust community!
| Type | Impact | Getting Started |
|---|---|---|
| ๐ Bug Reports | High | Check existing issues, provide reproduction steps |
| ๐ Security Issues | Critical | Email security@clockin.network privately |
| โจ Features | High | Open RFC in Discussions, implement if approved |
| ๐ Documentation | Medium | Improve README, add examples, fix typos |
| ๐งช Testing | Medium | Add property-based tests, improve coverage |
| ๐ง Code | High | Fix bugs, optimize performance, add features |
Fork & Clone
git clone https://github.com/your-username/chrono-merkle.git
cd chrono-merkle
Setup Development Environment
# Install Rust 1.85+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Run full test suite
cargo test
cargo test --release
cargo bench
# Check code quality
cargo fmt --check
cargo clippy -- -D warnings
Make Changes
# Create feature branch
git checkout -b feature/your-feature-name
# Follow conventional commits
# feat: add new feature
# fix: resolve bug
# docs: update documentation
# test: add tests
Submit Pull Request
For detailed contribution guidelines, see CONTRIBUTING.md.
Licensed under either of:
at your option.
security@clockin.network for private disclosurecontact@clockin.network for business inquiriesChronoMerkle - Time-aware cryptographic data structures for the next generation of blockchain and distributed systems.
Built with โค๏ธ by ClockinChain โข Licensed under MIT OR Apache-2.0