Verify Credentials
Tutorial: Verify a Verifiable Credential
This tutorial walks you through verifying a Verifiable Credential (VC) using LearnCard. Verification checks that:
The credential's cryptographic proof is valid
The credential hasn't been tampered with
The credential hasn't expired
Prerequisites
Node.js (v18+)
Basic familiarity with Verifiable Credentials
Installation
npm install @learncard/initBasic Verification
import { initLearnCard } from '@learncard/init';
// Initialize LearnCard (no seed needed for verification-only)
const learnCard = await initLearnCard();
// Example signed credential (you'd receive this from an issuer)
const signedCredential = {
"@context": ["https://www.w3.org/2018/credentials/v1"],
"type": ["VerifiableCredential"],
"issuer": "did:key:z6MkjZ...",
"issuanceDate": "2024-01-01T00:00:00Z",
"credentialSubject": {
"id": "did:key:z6Mkp...",
"achievement": "Completed Tutorial"
},
"proof": {
"type": "Ed25519Signature2020",
// ... proof details
}
};
// Verify the credential
const result = await learnCard.invoke.verifyCredential(signedCredential);
console.log(result);
// { checks: ['proof', 'expiration'], warnings: [], errors: [] }Understanding Results
Valid Credential
Human-Readable Output
For a more detailed, human-readable result, pass true as the third argument:
Handling Invalid Credentials
Complete Example
Next Steps
Learn about Verifiable Presentations for sharing credentials
Explore Trust Registries for validating issuers
Last updated
Was this helpful?