bankai_types/lib.rs
1//! # Bankai Types
2//!
3//! Shared type definitions for the Bankai SDK ecosystem.
4//!
5//! This crate provides common types used across the Bankai SDK, verification library,
6//! and API. It's designed to work in both `std` and `no_std` environments, making it
7//! suitable for use in constrained environments like smart contracts and ZK circuits.
8//!
9//! ## Modules
10//!
11//! - [`proofs`] - Core proof types (MMR proofs, hashing functions) - works in `no_std`
12//! - [`api`] - API request/response types (requires `std` and `api` feature)
13//! - [`utils`] - Utility functions (MMR operations)
14//! - [`block`] - Bankai block representations with beacon and execution client data
15//! - [`fetch`] - Types for proof fetching and wrapping (requires `verifier-types` feature)
16//! - [`verify`] - Types for verification results (requires `verifier-types` feature)
17//!
18//! ## Feature Flags
19//!
20//! - `std` (default) - Enable standard library support
21//! - `api` - Enable API types (requires `std`)
22//! - `verifier-types` - Enable verifier-specific types (fetch/verify modules)
23//! - `serde` - Enable serde serialization support
24//! - `utoipa` - Enable OpenAPI schema generation
25
26#![cfg_attr(not(feature = "std"), no_std)]
27
28extern crate alloc;
29
30/// Core proof types for MMR proofs and hashing functions
31///
32/// These types are available in both `std` and `no_std` environments,
33/// making them suitable for use in ZK circuits and smart contracts.
34pub mod proofs;
35
36/// API request and response types
37///
38/// Types for interacting with the Bankai API, including block queries,
39/// proof requests, and chain statistics.
40///
41/// Requires the `api` feature flag.
42#[cfg(any(feature = "default", feature = "api"))]
43pub mod api;
44
45/// Utility functions for MMR operations
46///
47/// Provides helpers for working with Merkle Mountain Ranges,
48/// including peak calculations and position utilities.
49pub mod utils;
50
51/// Bankai block representations
52///
53/// Defines the structure of Bankai blocks, which contain verified
54/// beacon and execution chain data with their respective MMR roots.
55#[cfg(any(feature = "default", feature = "api", feature = "verifier-types"))]
56pub mod block;
57
58/// Proof fetching types
59///
60/// Types used for fetching and wrapping proofs from the Bankai API,
61/// including EVM-specific proof structures. The main type is [`fetch::ProofWrapper`],
62/// which bundles together all proofs needed for batch verification.
63///
64/// Requires the `verifier-types` feature flag.
65#[cfg(feature = "verifier-types")]
66pub mod fetch;
67
68/// Verification result types
69///
70/// Types representing verified data after successful proof verification,
71/// including batch results and EVM-specific verified data.
72///
73/// Requires the `verifier-types` feature flag.
74#[cfg(feature = "verifier-types")]
75pub mod verify;
76
77// Re-export commonly used types for easier access
78#[cfg(feature = "verifier-types")]
79pub use fetch::ProofWrapper;