Verify a V4 DID signature against the signer's Ed25519 public key. Any edited covered field — the covered changes and operations, the chain link, the evidence roots, the agent metadata, the signer itself — fails, as does a missing signature. `false` for MAC-signed or unsigned attestations.
(&self, public_key_bytes: &[u8; 32])
| 604 | /// — fails, as does a missing signature. `false` for MAC-signed or |
| 605 | /// unsigned attestations. |
| 606 | pub fn verify_with_did(&self, public_key_bytes: &[u8; 32]) -> bool { |
| 607 | use ed25519_dalek::Verifier; |
| 608 | let verifying_key = match ed25519_dalek::VerifyingKey::from_bytes(public_key_bytes) { |
| 609 | Ok(key) => key, |
| 610 | Err(_) => return false, |
| 611 | }; |
| 612 | let Some(signature) = self.signature.as_deref() else { |
| 613 | return false; |
| 614 | }; |
| 615 | let Ok(sig_bytes) = data_encoding::BASE32_NOPAD.decode(signature.as_bytes()) else { |
| 616 | return false; |
| 617 | }; |
| 618 | let Ok(sig) = <[u8; 64]>::try_from(sig_bytes.as_slice()) else { |
| 619 | return false; |
| 620 | }; |
| 621 | verifying_key |
| 622 | .verify( |
| 623 | &self.did_signature_input(), |
| 624 | &ed25519_dalek::Signature::from_bytes(&sig), |
| 625 | ) |
| 626 | .is_ok() |
| 627 | } |
| 628 | |
| 629 | /// The signer DID, when this attestation carries a non-MAC signer. |
| 630 | pub fn signer_did(&self) -> Option<&str> { |
no test coverage detected