Expand description
§silent-payments
High-level BIP 352 Silent Payments library for Rust wallets.
This is a facade crate that re-exports all sub-crate public APIs.
Like tokio’s facade pattern, users depend on silent-payments and
get access to all functionality through a single dependency.
§Crate graph
silent-payments (facade)
+-- silent-payments-core (address, keys, inputs, crypto)
+-- silent-payments-send (sender builder, output scripts)
+-- silent-payments-receive (scanner, labels, detected outputs)
+-- silent-payments-psbt (BIP 375 fields, roles, DLEQ proofs)
+-- silent-payments-scan (ScanBackend trait, electrum, index-server)
+-- silent-payments-descriptor (BIP 392 sp() descriptors)§Quick start
use silent_payments::prelude::*;The prelude provides:
- Address types:
SpAddresswith bech32m parsing and encoding - Key newtypes:
ScanPublicKey,SpendPublicKey,ScanSecretKey,SpendSecretKey - Input classification:
classify_input,collect_eligible_inputs,ClassifiedInput,SpInputType - Crypto wrappers:
compute_shared_secret,compute_output_pubkey,compute_input_hash,get_label_tweak - Error types:
AddressError,InputError,CryptoError - PSBT types:
SpPsbtConstructor,SpPsbtUpdater,SpPsbtSigner,SpPsbtExtractor,DleqProof - Scan types:
ScanBackend,ScanError,OnMatch,OnProgress
§Feature Flags
bip392– EnablesSpDescriptorfor BIP 392 descriptor parsing and generationelectrum– EnablesElectrumBackendfor Electrum server scanningindex-server– EnablesIndexServerBackendfor BIP0352 index server scanningexperimental-dleq– Enables DLEQ proof generation in PSBT signing
§Complete Send + Receive Roundtrip
use std::str::FromStr;
use silent_payments::prelude::*;
let secp = Secp256k1::new();
// Receiver: create keys + address
let scan_sk = ScanSecretKey::from_slice(&[0xea; 32])?;
let spend_sk = SpendSecretKey::from_slice(&[0x93; 32])?;
let (scan_pk, spend_pk) = (scan_sk.public_key(&secp), spend_sk.public_key(&secp));
let sp_addr = SpAddress::new(scan_pk.clone(), spend_pk.clone(), Network::Bitcoin);
// Sender: build inputs, create outputs
let sender = SilentPaymentSender::new(&[(txin.clone(), prev.clone(), input_sk)], EcdsaSighashType::All)?;
let outputs = sender.create_output_scripts(&sp_addr, &secp)?;
// Receiver: scan transaction, derive spend key
let scanner = BlockScanner::new(scan_sk, spend_pk, LabelManager::new());
let detected = scanner.scan_transaction(&tx, &[prev], &secp)?;
for d in &detected { let _key = d.derive_spend_key(&spend_sk, &secp)?; }Re-exports§
pub use silent_payments_core;pub use silent_payments_send;pub use silent_payments_receive;pub use silent_payments_psbt;pub use silent_payments_scan;pub use silent_payments_descriptor;
Modules§
- address
- BIP 352 Silent Payment address parsing, encoding, and construction.
- crypto
- Cryptographic safety wrappers for BIP 352 Silent Payments.
- error
- Per-domain error enums for Silent Payments operations.
- input
- Transaction input classification and public key extraction for BIP 352.
- keys
- Newtype wrappers for Silent Payments key types.
- prelude
- Common types and traits for convenient glob imports.
Structs§
- Block
Scanner - Scans transactions for Silent Payment outputs addressed to the receiver.
- Classified
Input - A classified transaction input with its extracted public key.
- Detected
Output - A Silent Payment output detected during transaction scanning.
- Dleq
Proof - Opaque DLEQ proof wrapping 64 bytes (32-byte challenge
e|| 32-byte responses). - Electrum
Backend - Scanning backend that connects to an Electrum server.
- Extracted
SpOutput - A Silent Payment output extracted from a PSBT after ECDH share aggregation.
- Index
Server Backend - Scanning backend for BIP0352 index servers.
- Label
Manager - Manages labeled Silent Payment addresses with O(1) per-output lookup.
- Scan
Public Key - The receiver’s scan public key (B_scan in BIP 352).
- Scan
Secret Key - The receiver’s scan secret key (b_scan in BIP 352).
- Silent
Payment Output - A derived Silent Payment output ready for inclusion in a transaction.
- Silent
Payment Sender - A validated Silent Payment sender ready to produce output scripts.
- SpAddress
- A BIP 352 Silent Payment address.
- SpDescriptor
- A BIP 392 Silent Payments descriptor.
- SpPsbt
Constructor - BIP 375 Constructor role: adds SP output info and labels to the PSBT.
- SpPsbt
Extractor - BIP 375 Extractor role: aggregates ECDH shares and computes SP output scripts.
- SpPsbt
Signer - BIP 375 Signer role: adds ECDH shares with mandatory DLEQ proof validation.
- SpPsbt
Updater - BIP 375 Updater role: allows wallet-specific BIP32 operations on the PSBT.
- Spend
Public Key - The receiver’s spend public key (B_spend in BIP 352).
- Spend
Secret Key - The receiver’s spend secret key (b_spend in BIP 352).
Enums§
- Address
Error - Errors from parsing or encoding BIP 352 Silent Payment addresses.
- Crypto
Error - Errors from cryptographic operations (EC math, key validation, ECDH).
- Descriptor
Error - Errors from parsing or generating BIP 392
sp()descriptors. - Dleq
Error - Errors from BIP 374 DLEQ proof operations.
- Input
Error - Errors from classifying transaction inputs and extracting public keys.
- Psbt
Error - Errors from BIP 375 PSBT operations (field access, role transitions, validation).
- Receive
Error - Errors from receiving/scanning Silent Payment transactions.
- Scan
Error - Errors from scanning backends.
- Send
Error - Errors from constructing or executing a Silent Payment send operation.
- SpInput
Type - The type of a transaction input eligible for Silent Payments.
Traits§
- Scan
Backend - Pluggable scanning backend for Silent Payments.
Functions§
- classify_
input - Classify a single transaction input and extract its public key.
- collect_
eligible_ inputs - Classify all inputs in a transaction, reporting both eligible and skipped inputs.
- compute_
input_ hash - Compute the BIP 352 input hash (tagged hash:
BIP0352/Inputs). - compute_
output_ pubkey - Compute the BIP 352 output public key:
B_spend + hash(shared_secret || k) * G. - compute_
shared_ secret - Compute the ECDH shared secret between a scan public key and the sender’s partial secret (input_secret * input_hash).
- get_
label_ tweak - Compute a label tweak from a scan secret key and label index.
Type Aliases§
- OnMatch
- Callback invoked for each detected Silent Payment output during range scanning.
- OnProgress
- Callback invoked for progress reporting (current block height).