libchat/conversations/src/identity.rs
Jazz Turner-Baggs fe23c39321
PrivateV1 Convo Initialization via Inbox (#13)
* Load orginal protofiles

* Change package name

* Add prost generation

* Remove placeholders

* Add generated files + imports

* replace with chat-proto

* Add XK0

* auto formatting

* Initial implementation of PrivateV1 initialization

* Add ConvoFactory trait

* Hook up indentity placeholder

* Remove RemoteInbox until it’s needed

* Simplify Identity ownership

* Clean up x3handshake

* Move inbox encryption

* Simplify inbox encryption

* Cleanup warnings

* Add todos

* Update chat-proto crate

* Publickey Handling

* Reorg Inbox handshake

* Update Inbox convoId

* Remove file structure headers

* Update ConvoID

* Add Domain Separator trait

* Remove Convo trait functions

* Rename Context

* Add SecretKey

* Add workspace dependency

* update KE name

* Update comments for clarity

* Remove Xk0 references

* Bump chat_proto version and relock
2026-01-21 15:39:09 -08:00

44 lines
910 B
Rust

use blake2::{Blake2b512, Digest};
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 address(&self) -> String {
hex::encode(Blake2b512::digest(self.public_key()))
}
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()
}
}