mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-03-28 07:03:43 +00:00
* Make conversation store easier to use * fix: Bug in Inbox id’s * Clean up warnings * Add DH decryption for Inbox
39 lines
772 B
Rust
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()
|
|
}
|
|
}
|