Overview
AnonCreds provides:- Zero-knowledge proofs - Prove attributes without revealing them
- Selective disclosure - Share only required attributes
- Predicate proofs - Prove conditions (e.g., age > 18) without revealing exact values
- Revocation - Support for credential revocation
- Multi-ledger support - Works with Indy, Cheqd, Hedera, and more
Installation
Basic Setup
Multi-Registry Setup
Credo supports multiple AnonCreds registries simultaneously:Creating Schemas
import { TypedArrayEncoder } from '@credo-ts/core'
import { transformPrivateKeyToPrivateJwk } from '@credo-ts/askar'
const { privateJwk } = transformPrivateKeyToPrivateJwk({
type: { crv: 'Ed25519', kty: 'OKP' },
privateKey: TypedArrayEncoder.fromString('my-secure-seed-32-characters!!'),
})
const { keyId } = await agent.kms.importKey({ privateJwk })
await agent.dids.import({
did: 'did:indy:bcovrin:test:AHJzHqBc9tvv3E9Z2dzyPN',
overwrite: true,
keys: [{ didDocumentRelativeKeyId: '#verkey', kmsKeyId: keyId }],
})
const issuerId = 'did:indy:bcovrin:test:AHJzHqBc9tvv3E9Z2dzyPN'
import type { IndyVdrRegisterSchemaOptions } from '@credo-ts/indy-vdr'
const { schemaState } = await agent.modules.anoncreds.registerSchema<IndyVdrRegisterSchemaOptions>({
schema: {
name: 'UniversityDegree',
version: '1.0.0',
attrNames: ['name', 'degree', 'graduation_date'],
issuerId,
},
options: {
endorserMode: 'internal',
endorserDid: issuerId,
},
})
if (schemaState.state === 'finished') {
console.log('Schema ID:', schemaState.schemaId)
} else {
console.error('Schema registration failed:', schemaState.reason)
}
Creating Credential Definitions
After registering a schema, create a credential definition:Issuing Credentials with DIDComm
- V2 Protocol
- V1 Protocol (Legacy)
Accepting Credentials (Holder)
Create Link Secret
Before accepting credentials, create a link secret (once per wallet):Accept Credential Offer
Requesting Proofs
Request proof of credentials with various constraints:Basic Proof Request
Proof with Predicates
Prove conditions without revealing exact values:>=- Greater than or equal>- Greater than<=- Less than or equal<- Less than
Presenting Proofs (Holder)
Select Credentials for Proof
Accept Proof Request
Revocation Support
Enable credential revocation:Create Revocation Registry
Revoke a Credential
Registry-Specific Configuration
- Hyperledger Indy
- Cheqd
- Hedera
Complete Example
Here’s a complete issuer setup from the Credo demo:Next Steps
DIDComm
Integrate AnonCreds with DIDComm messaging
Multi-Tenancy
Use AnonCreds in multi-tenant deployments
OpenID4VC
Alternative credential format with OpenID4VC
API Reference
Full AnonCreds API documentation