pot_o_extensions/
security.rs1use pot_o_core::TribeResult;
4use pot_o_mining::Challenge;
5
6use crate::peer_network::PeerInfo;
7
8pub trait ProofAuthority: Send + Sync {
14 fn verify_miner_identity(&self, pubkey: &str, signature: &[u8]) -> TribeResult<bool>;
15 fn sign_challenge(&self, challenge: &Challenge) -> TribeResult<Vec<u8>>;
16 fn validate_node_connection(&self, peer: &PeerInfo) -> TribeResult<bool>;
17}
18
19pub struct Ed25519Authority;
24
25impl ProofAuthority for Ed25519Authority {
26 fn verify_miner_identity(&self, _pubkey: &str, _signature: &[u8]) -> TribeResult<bool> {
27 Ok(true)
30 }
31
32 fn sign_challenge(&self, _challenge: &Challenge) -> TribeResult<Vec<u8>> {
33 Ok(vec![0u8; 64])
36 }
37
38 fn validate_node_connection(&self, _peer: &PeerInfo) -> TribeResult<bool> {
39 Ok(true)
41 }
42}
43
44#[derive(Debug, Clone)]
49pub struct MtlsConfig {
50 pub ca_cert_path: String,
51 pub node_cert_path: String,
52 pub node_key_path: String,
53}
54
55pub struct MtlsAuthority {
56 pub config: MtlsConfig,
57}
58
59impl ProofAuthority for MtlsAuthority {
60 fn verify_miner_identity(&self, _pubkey: &str, _signature: &[u8]) -> TribeResult<bool> {
61 todo!("mTLS miner identity verification not yet implemented")
62 }
63 fn sign_challenge(&self, _challenge: &Challenge) -> TribeResult<Vec<u8>> {
64 todo!("mTLS challenge signing not yet implemented")
65 }
66 fn validate_node_connection(&self, _peer: &PeerInfo) -> TribeResult<bool> {
67 todo!("mTLS node connection validation not yet implemented")
68 }
69}
70
71pub struct HmacDeviceAuth {
76 pub shared_secret: Vec<u8>,
77}
78
79impl ProofAuthority for HmacDeviceAuth {
80 fn verify_miner_identity(&self, _pubkey: &str, _signature: &[u8]) -> TribeResult<bool> {
81 todo!("HMAC device identity verification not yet implemented")
82 }
83 fn sign_challenge(&self, _challenge: &Challenge) -> TribeResult<Vec<u8>> {
84 todo!("HMAC challenge signing not yet implemented")
85 }
86 fn validate_node_connection(&self, _peer: &PeerInfo) -> TribeResult<bool> {
87 todo!("HMAC node connection validation not yet implemented")
88 }
89}