From f8a923fd6d7643d203f12000ceaa42761c3dbc4d Mon Sep 17 00:00:00 2001 From: Nico Burniske Date: Thu, 23 Jul 2026 11:19:44 -0400 Subject: [PATCH] quantum_link: manual debug implementation and remove serialization code --- api/src/api/quantum_link.rs | 46 ++++++++++++------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/api/src/api/quantum_link.rs b/api/src/api/quantum_link.rs index 21b187fe..63839278 100644 --- a/api/src/api/quantum_link.rs +++ b/api/src/api/quantum_link.rs @@ -1,9 +1,8 @@ -use std::time::Duration; +use std::{fmt, time::Duration}; use bc_components::{EncapsulationScheme, PrivateKeys, PublicKeys, SignatureScheme, ARID}; use bc_envelope::{ - prelude::{CBORCase, CBOR}, - Envelope, EventBehavior, Expression, ExpressionBehavior, Function, + prelude::CBOR, Envelope, EventBehavior, Expression, ExpressionBehavior, Function, }; use bc_xid::XIDDocument; use chrono::{DateTime, Utc}; @@ -187,13 +186,25 @@ pub trait QuantumLink: Into + TryFrom { impl QuantumLink for T where T: Into + TryFrom {} -#[derive(Debug, Clone)] +#[derive(Clone)] #[cfg_attr(feature = "envoy", flutter_rust_bridge::frb(opaque))] pub struct QuantumLinkIdentity { pub private_keys: Option, pub xid_document: XIDDocument, } +impl fmt::Debug for QuantumLinkIdentity { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("QuantumLinkIdentity") + .field( + "private_keys", + &self.private_keys.as_ref().map(|_| ""), + ) + .field("xid_document", &self.xid_document) + .finish() + } +} + impl QuantumLinkIdentity { pub fn generate() -> Self { let (signing_private_key, signing_public_key) = SignatureScheme::MLDSA44.keypair(); @@ -210,33 +221,6 @@ impl QuantumLinkIdentity { xid_document, } } - - pub fn to_bytes(&self) -> Vec { - let mut map = bc_envelope::prelude::Map::new(); - map.insert(CBOR::from("xid_document"), self.clone().xid_document); - if self.private_keys.is_some() { - map.insert( - CBOR::from("private_keys"), - self.clone().private_keys.unwrap(), - ); - } - - CBOR::from(map).to_cbor_data() - } - - pub fn from_bytes(bytes: &[u8]) -> dcbor::Result { - let cbor = CBOR::try_from_data(bytes)?; - let case = cbor.into_case(); - - let CBORCase::Map(map) = case else { - return Err(dcbor::Error::WrongType); - }; - - Ok(QuantumLinkIdentity { - xid_document: map.get("xid_document").ok_or(dcbor::Error::MissingMapKey)?, - private_keys: map.get("private_keys"), - }) - } } fn expiration_duration() -> chrono::Duration {