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//! ### ZIP 32 addresses
16//!
17//! The default-enabled `zip32-addresses` feature provides indexed address
18//! generation and diversifier-index recovery using FF1. Consumers that disable
19//! default features must enable it explicitly to use these wallet APIs. Direct
20//! address construction from diversifiers, key derivation, and note decryption
21//! remain available without it.
22//!
23
24#![no_std]
25#![cfg_attr(docsrs, feature(doc_cfg))]
26// Catch documentation errors caused by code changes.
27#![deny(rustdoc::broken_intra_doc_links)]
28#![deny(unsafe_code)]
29
30#[macro_use]
31extern crate alloc;
32
33#[cfg(feature = "std")]
34extern crate std;
35
36mod address;
37pub mod builder;
38pub mod bundle;
39mod once;
40
41#[cfg(feature = "circuit")]
42pub mod circuit;
43pub mod constants;
44pub mod group_hash;
45pub mod keys;
46pub mod note;
47pub mod note_encryption;
48pub mod pczt;
49pub mod pedersen_hash;
50#[cfg(feature = "circuit")]
51pub mod prover;
52mod rng_compat;
53mod spec;
54mod tree;
55pub mod util;
56pub mod value;
57#[cfg(feature = "circuit")]
58mod verifier;
59pub mod zip32;
60
61pub use address::PaymentAddress;
62pub use bundle::Bundle;
63pub use keys::{Diversifier, NullifierDerivingKey, ProofGenerationKey, SaplingIvk, ViewingKey};
64pub use note::{Note, Rseed, nullifier::Nullifier};
65pub use tree::{
66    Anchor, CommitmentTree, IncrementalWitness, MerklePath, NOTE_COMMITMENT_TREE_DEPTH, Node,
67    merkle_hash,
68};
69
70#[cfg(feature = "circuit")]
71pub use verifier::{BatchValidator, PreparedBatchVerifyingKeys, SaplingVerificationContext};
72
73#[cfg(any(test, feature = "test-dependencies"))]
74#[cfg_attr(docsrs, doc(cfg(feature = "test-dependencies")))]
75pub mod testing {
76    pub use super::{
77        address::testing::arb_payment_address, keys::testing::arb_incoming_viewing_key,
78        note::testing::arb_note, tree::testing::arb_node,
79    };
80}
81
82#[cfg(test)]
83mod test_vectors;