How verification works
The verification process uses cryptographic signature recovery to confirm that Circle’s Attestation Service signed the message. It involves the following steps:1
Retrieve the public key
Fetch Circle’s current public key from the
GET /v2/publicKeys endpoint.2
Hash the message
Create a
keccak256 hash of the message bytes.3
Parse the attestation
Split the 65-byte attestation into its
r, s, and v components (ECDSA
signature format).4
Recover the signer
Use the signature and message hash to recover the public key that signed the
message.
5
Compare addresses
Convert both the recovered public key and Circle’s public key to Ethereum
addresses and compare them.
When to verify attestations
Attestation verification is optional because the CCTP contracts on the destination blockchain perform their own verification when you callreceiveMessage. However, you might want to verify attestations before
submitting the mint transaction if:
- Your application requires an additional layer of security: Verifying before minting provides defense-in-depth by catching invalid attestations at the application layer.
- You want to detect invalid attestations before paying gas fees: If an attestation is invalid, the mint transaction fails and you lose the gas fees. Pre-verification lets you catch this before submitting the transaction.
- You’re building a relayer service that batches multiple attestations: Relayers can verify each attestation in a batch before submitting, preventing a single invalid attestation from affecting the entire batch.
Verification code example
The following example shows how to verify an attestation signature using theethers library:
JavaScript