From 631608e6e5f9adc95971a0cc27004cd8379de315 Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Fri, 19 Jun 2026 23:14:27 -0400 Subject: [PATCH] refactor(core/org): drop unreachable unwrap in unwrap_org_key; assert hex in OrgId test Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01TJo44YM3UbBjro2fG6NrKy --- crates/relicario-core/src/org.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/crates/relicario-core/src/org.rs b/crates/relicario-core/src/org.rs index 5b02caa..caceaf2 100644 --- a/crates/relicario-core/src/org.rs +++ b/crates/relicario-core/src/org.rs @@ -304,9 +304,9 @@ pub fn unwrap_org_key(wrapped: &[u8], ed25519_seed: &Zeroizing<[u8; 32]>) -> Res return Err(RelicarioError::Format("wrapped key blob too short".into())); } - let ephemeral_pk = x25519_dalek::PublicKey::from( - <[u8; 32]>::try_from(&wrapped[..32]).unwrap() - ); + let mut eph_bytes = [0u8; 32]; + eph_bytes.copy_from_slice(&wrapped[..32]); + let ephemeral_pk = x25519_dalek::PublicKey::from(eph_bytes); let encrypted = &wrapped[32..]; let recipient_sk = ed25519_seed_to_x25519_secret(ed25519_seed); @@ -359,6 +359,7 @@ mod tests { fn org_id_is_16_hex_chars() { let id = OrgId::new(); assert_eq!(id.0.len(), 16); + assert!(id.0.chars().all(|c| c.is_ascii_hexdigit())); } #[test]