MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / verify_with_did

Method verify_with_did

atomic-core/src/change/attestation.rs:606–627  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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> {

Callers 4

verifyMethod · 0.80

Calls 5

did_signature_inputMethod · 0.80
decodeMethod · 0.45
as_bytesMethod · 0.45
as_sliceMethod · 0.45
verifyMethod · 0.45

Tested by

no test coverage detected