Skip to main content

sapling_crypto/
lib.rs

1//! # sapling
2//!
3//! ## Nomenclature
4//!
5//! All types in the `sapling-crypto` crate, unless otherwise specified, are
6//! Sapling-specific types. For example, [`PaymentAddress`] is documented as being a
7//! shielded payment address; we implicitly mean it is an Sapling payment address (as
8//! opposed to e.g. an Orchard payment address, which is also shielded).
9//!
10//! ## Feature flags
11//!
12//! - `pinned-vk-only`: embeds the canonical Sapling verifying keys
13//!   without proving parameters, and enables `circuit`. It adds no Wagyu
14//!   dependency; separately enabled proving dependencies are unaffected.
15//! ### Wallet derivation
16//!
17//! The default-enabled `wallet` feature exposes wallet derivation and PCZT APIs.
18//! Node clients may omit it while retaining verification and coinbase construction.
19//! `zip32-addresses` implies `wallet`.
20//!
21//! ### ZIP 32 addresses
22//!
23//! The default-enabled `zip32-addresses` feature provides indexed address
24//! generation and diversifier-index recovery using FF1. Consumers that disable
25//! default features must enable it explicitly to use these wallet APIs. Direct
26//! address construction from diversifiers and note decryption
27//! remain available without it.
28//!
29
30#![no_std]
31#![cfg_attr(docsrs, feature(doc_cfg))]
32// Catch documentation errors caused by code changes.
33#![deny(rustdoc::broken_intra_doc_links)]
34#![deny(unsafe_code)]
35
36#[macro_use]
37extern crate alloc;
38
39#[cfg(feature = "std")]
40extern crate std;
41
42mod address;
43pub mod builder;
44pub mod bundle;
45mod once;
46
47#[cfg(feature = "circuit")]
48pub mod circuit;
49pub mod constants;
50pub mod group_hash;
51pub mod keys;
52pub mod note;
53pub mod note_encryption;
54#[cfg(feature = "wallet")]
55pub mod pczt;
56pub mod pedersen_hash;
57#[cfg(feature = "circuit")]
58pub mod prover;
59#[cfg(test)]
60mod rng_compat;
61mod spec;
62mod tree;
63pub mod util;
64pub mod value;
65#[cfg(feature = "circuit")]
66mod verifier;
67#[cfg(feature = "wallet")]
68pub mod zip32;
69
70pub use address::PaymentAddress;
71pub use bundle::Bundle;
72pub use keys::{Diversifier, NullifierDerivingKey, ProofGenerationKey, SaplingIvk, ViewingKey};
73pub use note::{Note, Rseed, nullifier::Nullifier};
74pub use tree::{
75    Anchor, CommitmentTree, IncrementalWitness, MerklePath, NOTE_COMMITMENT_TREE_DEPTH, Node,
76    merkle_hash,
77};
78
79#[cfg(feature = "circuit")]
80pub use verifier::{BatchValidator, PreparedBatchVerifyingKeys, SaplingVerificationContext};
81
82#[cfg(any(test, feature = "test-dependencies"))]
83#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]
84pub mod testing {
85    pub use super::{
86        address::testing::arb_payment_address, keys::testing::arb_incoming_viewing_key,
87        note::testing::arb_note, tree::testing::arb_node,
88    };
89}
90
91#[cfg(test)]
92mod test_vectors;