zebra_consensus/lib.rs
1//! Implementation of Zcash consensus checks.
2//!
3//! More specifically, this crate implements *semantic* validity checks,
4//! as defined below.
5//!
6//! ## Verification levels.
7//!
8//! Zebra's implementation of the Zcash consensus rules is oriented
9//! around three telescoping notions of validity:
10//!
11//! 1. *Structural Validity*, or whether the format and structure of the
12//! object are valid. For instance, Sprout-on-BCTV14 proofs are not
13//! allowed in version 4 transactions, and a transaction with a spend
14//! or output description must include a binding signature.
15//!
16//! 2. *Semantic Validity*, or whether the object could potentially be
17//! valid, depending on the chain state. For instance, a transaction
18//! that spends a UTXO must supply a valid unlock script; a shielded
19//! transaction must have valid proofs, etc.
20//!
21//! 3. *Contextual Validity*, or whether a semantically valid
22//! transaction is actually valid in the context of a particular
23//! chain state. For instance, a transaction that spends a
24//! UTXO is only valid if the UTXO remains unspent; a
25//! shielded transaction spending some note must reveal a nullifier
26//! not already in the nullifier set, etc.
27//!
28//! *Structural validity* is enforced by the definitions of data
29//! structures in `zebra-chain`. *Semantic validity* is enforced by the
30//! code in this crate. *Contextual validity* is enforced in
31//! `zebra-state` when objects are committed to the chain state.
32
33#![doc(html_favicon_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-favicon-128.png")]
34#![doc(html_logo_url = "https://zfnd.org/wp-content/uploads/2022/03/zebra-icon.png")]
35#![doc(html_root_url = "https://docs.rs/zebra_consensus")]
36
37mod block;
38mod checkpoint;
39mod primitives;
40mod script;
41
42pub mod config;
43pub mod error;
44pub mod router;
45pub mod transaction;
46
47#[cfg(any(test, feature = "proptest-impl"))]
48pub use block::check::difficulty_is_valid;
49
50pub use block::{
51 subsidy::funding_streams::{funding_stream_address, new_coinbase_script},
52 Request, VerifyBlockError, MAX_BLOCK_SIGOPS,
53};
54pub use checkpoint::{
55 list::ParameterCheckpoint, CheckpointList, VerifyCheckpointError, MAX_CHECKPOINT_BYTE_COUNT,
56 MAX_CHECKPOINT_HEIGHT_GAP,
57};
58pub use config::Config;
59pub use error::BlockError;
60pub use primitives::{ed25519, groth16, halo2, redjubjub, redpallas};
61pub use router::RouterError;
62
63/// A boxed [`std::error::Error`].
64pub type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;