refactor(core/org): drop unreachable unwrap in unwrap_org_key; assert hex in OrgId test

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TJo44YM3UbBjro2fG6NrKy
This commit is contained in:
adlee-was-taken
2026-06-19 23:14:27 -04:00
parent ca4936cf95
commit 631608e6e5

View File

@@ -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())); return Err(RelicarioError::Format("wrapped key blob too short".into()));
} }
let ephemeral_pk = x25519_dalek::PublicKey::from( let mut eph_bytes = [0u8; 32];
<[u8; 32]>::try_from(&wrapped[..32]).unwrap() eph_bytes.copy_from_slice(&wrapped[..32]);
); let ephemeral_pk = x25519_dalek::PublicKey::from(eph_bytes);
let encrypted = &wrapped[32..]; let encrypted = &wrapped[32..];
let recipient_sk = ed25519_seed_to_x25519_secret(ed25519_seed); let recipient_sk = ed25519_seed_to_x25519_secret(ed25519_seed);
@@ -359,6 +359,7 @@ mod tests {
fn org_id_is_16_hex_chars() { fn org_id_is_16_hex_chars() {
let id = OrgId::new(); let id = OrgId::new();
assert_eq!(id.0.len(), 16); assert_eq!(id.0.len(), 16);
assert!(id.0.chars().all(|c| c.is_ascii_hexdigit()));
} }
#[test] #[test]