libchat/conversations/src/identity.rs
Jazz Turner-Baggs 71f7b8a485
FFI Integration fixes (#48)
* Make conversation store easier to use

* fix: Bug in Inbox id’s

* Clean up warnings

* Add DH decryption for Inbox
2026-02-09 09:55:58 -08:00

39 lines
772 B
Rust

use std::fmt;
use crate::crypto::{PublicKey, StaticSecret};
pub struct Identity {
secret: StaticSecret,
}
impl fmt::Debug for Identity {
// Manually implement debug to not reveal secret key material
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Identity")
.field("public_key", &self.public_key())
.finish_non_exhaustive()
}
}
impl Identity {
pub fn new() -> Self {
Self {
secret: StaticSecret::random(),
}
}
pub fn public_key(&self) -> PublicKey {
PublicKey::from(&self.secret)
}
pub fn secret(&self) -> &StaticSecret {
&self.secret
}
}
impl Default for Identity {
fn default() -> Self {
Self::new()
}
}