An easy-to-host PDS on the ATProtocol, MacOS. Grandma-approved.

style: format code per rustfmt conventions

authored by malpercio.dev and committed by

Tangled 23b82c80 f23db27d

+16 -10
+16 -10
crates/crypto/src/plc.rs
··· 24 24 25 25 use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine as _}; 26 26 use ciborium::ser::into_writer; 27 + use multibase; 27 28 use p256::{ 28 29 ecdsa::{signature::Signer, signature::Verifier, Signature, SigningKey, VerifyingKey}, 29 30 FieldBytes, 30 31 }; 31 32 use serde::{Deserialize, Serialize}; 32 33 use sha2::{Digest, Sha256}; 33 - use multibase; 34 34 35 35 use crate::{CryptoError, DidKeyUri}; 36 36 ··· 278 278 .map_err(|e| CryptoError::PlcOperation(format!("cbor encode unsigned op: {e}")))?; 279 279 280 280 // Step 6: Parse rotation key URI → P-256 VerifyingKey. 281 - let key_str = rotation_key 282 - .0 283 - .strip_prefix("did:key:") 284 - .ok_or_else(|| { 285 - CryptoError::PlcOperation("rotation key missing did:key: prefix".to_string()) 286 - })?; 281 + let key_str = rotation_key.0.strip_prefix("did:key:").ok_or_else(|| { 282 + CryptoError::PlcOperation("rotation key missing did:key: prefix".to_string()) 283 + })?; 287 284 let (_, multikey_bytes) = multibase::decode(key_str) 288 285 .map_err(|e| CryptoError::PlcOperation(format!("decode rotation key multibase: {e}")))?; 289 286 if multikey_bytes.get(..2) != Some(P256_MULTICODEC_PREFIX) { ··· 548 545 assert!(result.is_ok(), "verify should succeed"); 549 546 let verified = result.unwrap(); 550 547 551 - assert!(verified.did.starts_with("did:plc:"), "DID should start with 'did:plc:'"); 552 - assert_eq!(verified.did.len(), 32, "DID should be 32 chars total (did:plc: + 24 suffix)"); 553 548 assert!( 554 - verified.also_known_as.contains(&"at://alice.example.com".to_string()), 549 + verified.did.starts_with("did:plc:"), 550 + "DID should start with 'did:plc:'" 551 + ); 552 + assert_eq!( 553 + verified.did.len(), 554 + 32, 555 + "DID should be 32 chars total (did:plc: + 24 suffix)" 556 + ); 557 + assert!( 558 + verified 559 + .also_known_as 560 + .contains(&"at://alice.example.com".to_string()), 555 561 "also_known_as should contain 'at://alice.example.com'" 556 562 ); 557 563 assert!(