1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! # Solana Stealth SDK
//!
//! A library for private payments on Solana using Stealth Addresses.
//!
//! ## Overview
//!
//! Stealth addresses allow a sender to pay a recipient without revealing the
//! connection between them. Each payment generates a unique one-time address
//! that only the recipient can detect and spend from.
//!
//! ## Quick Start
//!
//! ### Receiving Payments
//!
//! ```rust,ignore
//! use solana_stealth::{StealthMetaAddress, Scanner};
//!
//! // Generate a meta-address (do this once)
//! let meta = StealthMetaAddress::generate();
//! println!("Share this publicly: {}", meta.to_public_string());
//!
//! // Save your keys securely
//! meta.save_to_file("~/.stealth/keys.json").unwrap();
//!
//! // Scan for incoming payments
//! let scanner = Scanner::new(&meta);
//! let payments = scanner.scan("https://api.devnet.solana.com").await.unwrap();
//!
//! for payment in payments {
//! println!("Received {} lamports at {}", payment.amount.unwrap_or(0), payment.stealth_address);
//!
//! // Derive the keypair to spend these funds
//! let keypair = scanner.derive_spend_keypair(&payment).unwrap();
//! let solana_keypair = keypair.to_solana_keypair().unwrap();
//! }
//! ```
//!
//! ### Sending Payments
//!
//! ```rust,ignore
//! use solana_stealth::{PublicMetaAddress, StealthPayment};
//!
//! // Parse recipient's meta-address
//! let recipient = PublicMetaAddress::from_string("stealth1abc...").unwrap();
//!
//! // Create a stealth payment
//! let payment = StealthPayment::create(&recipient, 1_000_000_000).unwrap(); // 1 SOL
//!
//! // The payment contains:
//! // - stealth_address: where to send the funds
//! // - ephemeral_pubkey: publish this on-chain so recipient can detect the payment
//! ```
//!
//! ## How It Works
//!
//! 1. **Recipient** generates a stealth meta-address (spending + viewing keypairs)
//! 2. **Recipient** publishes their meta-address publicly
//! 3. **Sender** generates a unique stealth address using ECDH with the meta-address
//! 4. **Sender** sends funds to the stealth address and publishes an announcement
//! 5. **Recipient** scans announcements and detects payments addressed to them
//! 6. **Recipient** derives the private key to spend the received funds
//!
//! ## Privacy Properties
//!
//! - Each payment uses a unique one-time address
//! - Only the recipient can detect which payments are theirs
//! - The sender cannot be linked to the recipient on-chain
//! - Amounts are visible on-chain (v1 limitation)
// Re-export main types
pub use ;
pub use ;
pub use ;
pub use ;
pub use StealthKeypair;
/// Version of the protocol
pub const PROTOCOL_VERSION: &str = "v1";
/// Prefix for encoded meta-addresses
pub const META_ADDRESS_PREFIX: &str = "stealth1";