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
//! # Auth Module
//!
//! Peer-to-peer authentication using BRC-31 (Authrite) protocol.
//!
//! ## Overview
//!
//! This module provides mutual authentication between peers using
//! cryptographic handshakes and optional certificate exchange.
//!
//! ## Components
//!
//! - [`Peer`] - Main authentication handler
//! - [`SessionManager`] - Concurrent session management
//! - [`certificates`] - BRC-52/53 certificate handling
//! - [`transports`] - Transport layer implementations
//!
//! ## Authentication Flow
//!
//! 1. **Initial Handshake**: Peers exchange nonces and establish session
//! 2. **Certificate Exchange** (optional): Peers exchange identity certificates
//! 3. **General Messages**: Authenticated message exchange
//!
//! ## Example
//!
//! ```rust,ignore
//! use bsv_rs::auth::{Peer, PeerOptions, SimplifiedFetchTransport};
//! use bsv_rs::wallet::ProtoWallet;
//! use bsv_rs::primitives::PrivateKey;
//!
//! // Create wallet and transport
//! let wallet = ProtoWallet::new(Some(PrivateKey::random()));
//! let transport = SimplifiedFetchTransport::new("https://example.com");
//!
//! // Create peer
//! let peer = Peer::new(PeerOptions {
//! wallet,
//! transport,
//! certificates_to_request: None,
//! session_manager: None,
//! auto_persist_last_session: false,
//! originator: Some("myapp.com".into()),
//! });
//!
//! // Send authenticated message
//! peer.to_peer(b"Hello!", Some(&recipient_key), None).await?;
//!
//! // Listen for incoming messages
//! let callback_id = peer.listen_for_general_messages(|sender, payload| {
//! Box::pin(async move {
//! println!("Received from {}: {:?}", sender.to_hex(), payload);
//! Ok(())
//! })
//! }).await;
//! ```
//!
//! ## BRC Standards
//!
//! This module implements:
//! - **BRC-31**: Authrite peer-to-peer authentication
//! - **BRC-52**: Certificate issuance and structure
//! - **BRC-53**: Certificate verification with selective disclosure
//! - **BRC-104**: HTTP headers for authenticated requests
// Re-exports
pub use ;
pub use ;
pub use SessionManager;
pub use ;
pub use ;
pub use ;
pub use ;