Skip to main content

Crate silent_payments

Crate silent_payments 

Source
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:

§Feature Flags

  • bip392 – Enables SpDescriptor for BIP 392 descriptor parsing and generation
  • electrum – Enables ElectrumBackend for Electrum server scanning
  • index-server – Enables IndexServerBackend for BIP0352 index server scanning
  • experimental-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§

BlockScanner
Scans transactions for Silent Payment outputs addressed to the receiver.
ClassifiedInput
A classified transaction input with its extracted public key.
DetectedOutput
A Silent Payment output detected during transaction scanning.
DleqProof
Opaque DLEQ proof wrapping 64 bytes (32-byte challenge e || 32-byte response s).
ElectrumBackend
Scanning backend that connects to an Electrum server.
ExtractedSpOutput
A Silent Payment output extracted from a PSBT after ECDH share aggregation.
IndexServerBackend
Scanning backend for BIP0352 index servers.
LabelManager
Manages labeled Silent Payment addresses with O(1) per-output lookup.
ScanPublicKey
The receiver’s scan public key (B_scan in BIP 352).
ScanSecretKey
The receiver’s scan secret key (b_scan in BIP 352).
SilentPaymentOutput
A derived Silent Payment output ready for inclusion in a transaction.
SilentPaymentSender
A validated Silent Payment sender ready to produce output scripts.
SpAddress
A BIP 352 Silent Payment address.
SpDescriptor
A BIP 392 Silent Payments descriptor.
SpPsbtConstructor
BIP 375 Constructor role: adds SP output info and labels to the PSBT.
SpPsbtExtractor
BIP 375 Extractor role: aggregates ECDH shares and computes SP output scripts.
SpPsbtSigner
BIP 375 Signer role: adds ECDH shares with mandatory DLEQ proof validation.
SpPsbtUpdater
BIP 375 Updater role: allows wallet-specific BIP32 operations on the PSBT.
SpendPublicKey
The receiver’s spend public key (B_spend in BIP 352).
SpendSecretKey
The receiver’s spend secret key (b_spend in BIP 352).

Enums§

AddressError
Errors from parsing or encoding BIP 352 Silent Payment addresses.
CryptoError
Errors from cryptographic operations (EC math, key validation, ECDH).
DescriptorError
Errors from parsing or generating BIP 392 sp() descriptors.
DleqError
Errors from BIP 374 DLEQ proof operations.
InputError
Errors from classifying transaction inputs and extracting public keys.
PsbtError
Errors from BIP 375 PSBT operations (field access, role transitions, validation).
ReceiveError
Errors from receiving/scanning Silent Payment transactions.
ScanError
Errors from scanning backends.
SendError
Errors from constructing or executing a Silent Payment send operation.
SpInputType
The type of a transaction input eligible for Silent Payments.

Traits§

ScanBackend
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).