blvm_protocol/utxo_commitments/mod.rs
1//! UTXO Commitments Module
2//!
3//! Implements cryptographic commitments to the UTXO set using Merkle trees.
4//! This module enables efficient UTXO set synchronization and verification
5//! without requiring full blockchain download.
6//!
7//! ## Architecture
8//!
9//! - **Data Structures**: UTXO, UTXO Set, UTXO Commitment
10//! - **Merkle Tree**: Sparse Merkle Tree for incremental updates
11//! - **Peer Consensus**: N of M peer verification model
12//! - **Verification**: PoW-based commitment verification
13//!
14//! ## Usage
15//!
16//! ```rust
17//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
18//! use blvm_protocol::utxo_commitments::{UtxoMerkleTree, UtxoCommitment};
19//! use blvm_consensus::types::{OutPoint, UTXO, Hash};
20//!
21//! // Create UTXO Merkle tree
22//! let mut utxo_tree = UtxoMerkleTree::new()?;
23//!
24//! // Add UTXO
25//! let outpoint = OutPoint { hash: [1; 32].into(), index: 0 };
26//! let utxo = UTXO { value: 1000, script_pubkey: vec![].into(), height: 0, is_coinbase: false };
27//! utxo_tree.insert(outpoint, utxo)?;
28//!
29//! // Generate commitment
30//! # let block_hash: Hash = [0; 32].into();
31//! # let height = 0;
32//! let root = utxo_tree.root();
33//! let commitment = UtxoCommitment::new(root, 1000, 1, height, block_hash);
34//! # Ok(())
35//! # }
36//! ```
37
38#[cfg(feature = "utxo-commitments")]
39pub mod config;
40#[cfg(feature = "utxo-commitments")]
41pub mod data_structures;
42#[cfg(feature = "utxo-commitments")]
43pub mod initial_sync;
44#[cfg(feature = "utxo-commitments")]
45pub mod merkle_tree;
46#[cfg(feature = "utxo-commitments")]
47pub mod network_integration;
48#[cfg(feature = "utxo-commitments")]
49pub mod peer_consensus;
50#[cfg(feature = "utxo-commitments")]
51pub mod verification;
52
53// Re-export main types
54#[cfg(feature = "utxo-commitments")]
55pub use config::*;
56#[cfg(feature = "utxo-commitments")]
57pub use data_structures::*;
58#[cfg(feature = "utxo-commitments")]
59pub use initial_sync::{update_commitments_after_block, InitialSync};
60#[cfg(feature = "utxo-commitments")]
61pub use merkle_tree::UtxoMerkleTree;
62#[cfg(feature = "utxo-commitments")]
63pub use network_integration::*;
64#[cfg(feature = "utxo-commitments")]
65pub use peer_consensus::*;
66#[cfg(feature = "utxo-commitments")]
67pub use verification::*;