Skip to main content
Version: v0.5.x

AnonCreds

The AnonCreds module provides functionality for issuing and verifying AnonCreds credentials in Credo. The AnonCreds implementation is based on AnonCreds RS, a direct implementation of the AnonCreds V1.0 specification that provides functionality like; creating a schema object, creating a credential definition object, creating a credential, verifying a proof presentation and much more.

Installing

When using Credo with AnonCreds, there are a few extra dependencies that need to be installed. We need to install @credo-ts/anoncreds package, which contains the interfaces, and @hyperledger/anoncreds-<platform> package which is an implementation which depends on a wrapper of anoncreds-rs. Currently there are bindings for Node.js, as @hyperledger/anoncreds-nodejs, and React Native as @hyperlegder/anoncreds-react-native.

yarn add @credo-ts/anoncreds@^0.5.3 @hyperledger/anoncreds-nodejs@^0.2.2

Adding AnonCreds to the agent

After installing the dependencies, we should register the AnonCredsModule on the agent.

import { Agent } from '@credo-ts/core'
import { agentDependencies } from '@credo-ts/node'
import { AskarModule } from '@credo-ts/askar'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'

import { anoncreds } from '@hyperledger/anoncreds-nodejs'
import { AnonCredsModule } from '@credo-ts/anoncreds'
import { IndyVdrAnonCredsRegistry } from '@credo-ts/indy-vdr'

const agent = new Agent({
config,
dependencies: agentDependencies,
modules: {
// Register the Askar module on the agent
// This is included as we need a wallet on our agent
askar: new AskarModule({
ariesAskar,
}),
anoncreds: new AnonCredsModule({
// Here we add an Indy VDR registry as an example, any AnonCreds registry
// can be used
registries: [new IndyVdrAnonCredsRegistry()],
anoncreds,
}),
},
})

Configuration

As you can see, the AnonCreds module takes a list of registry modules. These modules will be used to resolve the AnonCreds objects. Indy VDR can be used as an AnonCreds registry for Hyperledger Indy networks, and Cheqd can be used as an AnonCreds registry for Cheqd networks.