From ed4ffa57be99980911dc52a83b106c8ea97cddfa Mon Sep 17 00:00:00 2001 From: Will Dillon Date: Fri, 7 Nov 2025 23:13:50 -0800 Subject: Got P2P decryption working --- src/identity.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/identity.rs b/src/identity.rs index 47ec956..5443b40 100644 --- a/src/identity.rs +++ b/src/identity.rs @@ -78,7 +78,16 @@ pub struct Keystore { } impl Keystore { - pub fn decrypt_and_id_p2p(&self, source: u8, dest: u8, mac: u16, data: &Bytes) -> Option<(Bytes, Identity, Contact)> { + pub fn decrypt_and_id_p2p(&self, source: u8, dest: u8, mac: u16, data: &Bytes) -> Option<(Bytes, Rc, Rc)> { + // Just brute-force all the secrets until one matches... + for identity in self.identities.iter() { + for secret in identity.1.secrets.iter() { + let result = secret.1.mac_then_decrypt(mac, data); + if let Some(result) = result { + return Some((result, identity.0.clone(), secret.0.clone())); + } + } + } None } -- cgit v1.2.3