This commit is contained in:
Jazz Turner-Baggs 2026-06-21 22:06:48 -07:00
parent 82e181e78c
commit edddf56873
No known key found for this signature in database
2 changed files with 13 additions and 1 deletions

View File

@ -13,6 +13,8 @@ use crate::conversation::ConversationId;
#[derive(Debug, Clone)]
pub struct Content {
pub bytes: Vec<u8>,
/// Hex-encoded [`DelegateCredential`] of the sender, if present in the message.
/// Empty when the sender did not attach a credential.
pub encoded_credential: Vec<u8>,
}

View File

@ -5,6 +5,10 @@ use crate::ClientError;
type AccountAddr = String;
/// A local signing identity that holds an Ed25519 keypair.
///
/// Can be standalone (unassociated) or authorized to act on behalf of an account
/// via [`DelegateSigner::associate`].
pub struct DelegateSigner {
signing_key: Ed25519SigningKey,
verifying_key: Ed25519VerifyingKey,
@ -13,6 +17,7 @@ pub struct DelegateSigner {
}
impl DelegateSigner {
/// Create a new signer with a randomly generated keypair.
pub fn random() -> Self {
let signing_key = Ed25519SigningKey::generate();
let verifying_key = signing_key.verifying_key();
@ -25,6 +30,7 @@ impl DelegateSigner {
}
}
/// Associate a DelegateSigner with an Account.
pub fn associate(&mut self, account_addr: AccountAddr) {
self.identifier =
DelegateCredential::associated(&self.verifying_key, account_addr.as_str()).into();
@ -54,7 +60,11 @@ impl IdentityProvider for DelegateSigner {
}
}
/// Represents the senders information for received frames.
/// A credential issued to a delegate key, optionally bound to an account address.
///
/// Serialized as a TLV byte sequence prefixed with magic bytes `0x23 0x23`.
/// A credential without an `account_addr` is *unassociated* — it identifies the
/// delegate key but has not yet been linked to an account.
#[derive(Debug)]
pub struct DelegateCredential {
delegate_id: Ed25519VerifyingKey,