{"record":{"id":"6298355194628f65","repo":"n0-computer/iroh","slug":"already-verified","errorCode":null,"errorMessage":"already verified","messagePattern":"already verified","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"info","filePath":"iroh-base/src/key.rs","lineNumber":153,"sourceCode":"        self.as_verifying_key()\n            .verify_strict(message, &signature.0)\n            .map_err(|_| SignatureError::new())\n    }\n\n    /// Convert to a hex string limited to the first 5 bytes for a friendly string\n    /// representation of the key.\n    pub fn fmt_short(&self) -> impl Display + Copy + 'static {\n        PublicKeyShort(\n            self.0.as_bytes()[0..5]\n                .try_into()\n                .expect(\"slice with incorrect length\"),\n        )\n    }\n\n    /// Needed for internal conversions, not part of the stable API.\n    #[doc(hidden)]\n    pub fn as_verifying_key(&self) -> VerifyingKey {\n        VerifyingKey::from_bytes(self.0.as_bytes()).expect(\"already verified\")\n    }\n\n    /// Needed for internal conversions, not part of the stable API.\n    #[doc(hidden)]\n    pub fn from_verifying_key(key: VerifyingKey) -> Self {\n        Self(CompressedEdwardsY(key.to_bytes()))\n    }\n\n    /// Encodes this key in [z-base-32](https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt),\n    /// the encoding used by [pkarr](https://pkarr.org) domain names.\n    pub fn to_z32(&self) -> String {\n        Z_BASE_32.encode(self.as_bytes())\n    }\n\n    /// Parses a key from its [z-base-32](https://philzimmermann.com/docs/human-oriented-base-32-encoding.txt) encoding.\n    pub fn from_z32(s: &str) -> Result<Self, KeyParsingError> {\n        let bytes = Z_BASE_32\n            .decode(s.as_bytes())","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/n0-computer/iroh/blob/2b4de030ce5e0133f272871a76f0c685c63f552a/iroh-base/src/key.rs#L135-L171","documentation":"PublicKey::as_verifying_key converts the stored compressed Edwards-Y point into an ed25519-dalek VerifyingKey with VerifyingKey::from_bytes(...).expect(\"already verified\"). from_bytes only fails for malformed points; since every PublicKey is constructed from bytes already validated as a canonical Ed25519 point, the conversion cannot fail. The expect asserts that invariant.","triggerScenarios":"Not reachable via the public API: PublicKey values come from verified 32-byte Ed25519 keys (from bytes or verifying keys), so from_bytes cannot reject them. Would only fire if a PublicKey were built from unvalidated raw bytes.","commonSituations":"Appears during code review or when constructing PublicKey directly from raw bytes in a fork/patch; a panic here means a PublicKey was created from non-canonical or truncated key material somewhere upstream.","solutions":["No runtime action needed for normal library use — keys are validated at construction.","If you build PublicKey from raw bytes outside the constructors, validate them first via VerifyingKey::from_bytes before wrapping.","When refactoring key construction paths, route all input through the existing validated constructors (from_bytes / from_verifying_key)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// If constructing key material yourself, validate before wrapping into PublicKey\nfn valid_pubkey(bytes: &[u8]) -> bool {\n    use ed25519_dalek::VerifyingKey;\n    <&[u8; 32]>::try_from(bytes).map(|b| VerifyingKey::from_bytes(b).is_ok()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only create PublicKey through its validated constructors (from bytes that parsed as a verifying key, or from_verifying_key).","Never deserialize raw 32 bytes into PublicKey without ed25519 validation in forks/patches.","If a panic with 'already verified' appears, audit the code path that produced the key bytes for truncation or corruption."],"tags":["internal-invariant","crypto","panic-guard"],"backgroundTag":"internal-invariant-violation","analyzedSha":"2b4de030ce5e0133f272871a76f0c685c63f552a","analyzedAt":"2026-09-08T04:26:47.755Z","contentChangedAt":"2026-09-08T04:26:47.755Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}