Skip to main content

nectar_postage_issuer/
lib.rs

1//! Postage stamp issuing and signing for Ethereum Swarm.
2//!
3//! This crate provides the issuing and signing functionality for postage stamps,
4//! designed for use by CLI tools (like `dipper`) that create and sign stamps.
5//!
6//! For verification-only use cases (like `vertex` nodes), use
7//! [`nectar-postage`](nectar_postage) directly.
8//!
9//! # Features
10//!
11//! - `std` (default) - Enables standard library support
12//! - `serde` - Enables serialization/deserialization
13//! - `local-signer` - Enables local key signing with `alloy-signer-local`
14//! - `parallel` - Enables parallel signing with rayon
15//!
16//! # Example
17//!
18//! ```ignore
19//! use nectar_postage_issuer::{BatchStamper, MemoryIssuer, Stamper};
20//! use nectar_primitives::SwarmAddress;
21//! use alloy_primitives::B256;
22//! use alloy_signer_local::PrivateKeySigner;
23//!
24//! // Create an issuer for a batch
25//! let issuer = MemoryIssuer::new(B256::ZERO, 20, 16);
26//!
27//! // Combine with any SignerSync implementation to create a stamper
28//! let signer = PrivateKeySigner::random();
29//! let mut stamper = BatchStamper::new(issuer, signer);
30//!
31//! // Stamp chunks
32//! let stamp = stamper.stamp(&chunk_address)?;
33//! ```
34
35#![cfg_attr(not(feature = "std"), no_std)]
36
37mod error;
38mod factory;
39mod issuer;
40mod sharded;
41mod stamper;
42
43// Re-export core types from nectar-postage (includes BatchEvent, BatchEventHandler)
44pub use nectar_postage::*;
45
46// Errors (override nectar_postage::StampError with our own that includes signing)
47pub use error::SigningError;
48
49// Issuing
50pub use issuer::{MemoryIssuer, StampIssuer};
51pub use sharded::ShardedIssuer;
52pub use stamper::{BatchStamper, Stamper};
53
54// Factory (std only)
55#[cfg(feature = "std")]
56pub use factory::{BatchFactory, CreateResult, MemoryBatchError, MemoryBatchFactory};
57
58// Parallel signing (requires parallel feature)
59#[cfg(feature = "parallel")]
60pub use sharded::{StampResult, sign_stamps_parallel};