cheqd support for Ledger-Agnostic AnonCreds CredDefs
cheqd AnonCreds Object Method for CredDefs
In the ledger-agnostic AnonCredsspecification, Credential Definitions are used to specify the following information all in one place, to create an immutable record of:
The DID of the credential issuer
The schema the issued credentials will be based upon
The public/private key pairs that will be used to sign the claims within an issued credential
A cryptographic secret, embedded within the CredDef Object content, creating an uncorrelatable 'link secret' between the issuer and holder
Information necessary for the revocation of credentials, if revocation is to be enabled by the Issuer for this type of credential (Optional).
This documentation will guide an implementor of AnonCreds on cheqd on how the cheqd AnonCreds Object Method defines and structures cheqd CredDef IDs, CredDef Request formats and CredDef Response formats, with and without revocation enabled.
Hyperledger AnonCreds CredDef Object
If you are not familiar with the latest Ledger-Agnostic AnonCreds CredDef structure, click the collapsible tile below to learn about the new format.
This means that an AnonCreds CredDef Object ID does not need to be formatted in any particular syntax, in the latest version of the AnonCreds Specification.
Credential Definition Object Content is distinct in the way it is structured. The inputs and outputs generated when creating a CredDef are as follows:
Create CredDef input
The following inputs are required to create a CredDef:
A schema on which the CredDef will be based
A tag, an arbitrary string defined by the Issuer, enabling an Issuer to create multiple CredDefs for the same schema.
An optional flag support_revocation (default false) which if true generates some additional data in the CredDef to enable credential revocation.
r_key is an object defining the private key for the CKS revocation scheme.
x is a Big (128-bit?) integer selected at random from the the group of integers defined by the order of the bilinear groups q
sk is a Big (128-bit?) integer selected at random from the the group of integers defined by the order of the bilinear groups q
x and sk are used as part of the revocation public key generation as defined below.
Create CredDef output (public)
The output of a create CredDef transaction is a JSON structure that is generated using cryptographic primitives.
A CredDef has a couple of important characteristics:
Each of the schema attributes is individually signed using a public key fragment.
Each CredDef includes a master_secret attribute. This value is blindly contributed to the credential during issuance and used to bind the issued credential to the entity it was issued to.
Using the Legacy AnonCreds Object method as a reference point, the composite string of the cred_def_id should include the same values as are in the CredDef Object Content.
An example of a CredDef Object content with revocation is below:
Rather than using a composite string for the CredDef Resource ID. The cheqd AnonCreds object method uses a UUID to identify the CredDef Object Content which includes additional CredDef Object Content Metadata, providing the required fields for equivalence with Hyperledger Indy implementations.
For example, the following DID URL is cheqd's representation of a credDefId:
Another supported format for a credDefId may be used in applications where it is important to derive the credDefId, revocRegDefId and statusListEntryId from the same root.
It is important to differentiate between the Request format for creating an AnonCreds object on cheqd, and the Response format, for how an AnonCreds objectshould be compiled by SDKs and the cheqd DID Resolver.
The request format may be specific to each AnonCreds Object Method. However, the response format should be standardised to enable any AnonCreds supported application to understand the object, without needing custom or method-specific logic.
cheqd CredDef Request Format
The cheqd CredDef request format comprises of:
A Resource file for the CredDef object content (e.g. degreeCredDef.json); and
A Payload file (including the signing keys and additional inputs to create a DID-Linked Resource).
Both of these inputs are required to provide the ledger enough information to:
This CredDef Resource file inputs should be replicated where possible within the Payload file, to populate a DID-Linked resource stored on cheqd, with the following mapping:
CredDef Object field
CredDef Object expected input
Mapped Payload file field
Mapped Payload file input
"type"
"CL"
"resourceType"
"anonCredsCredDef"
"tag"
""
"resourceVersion"
""
What this means is that if the Resource file has an object of "type" = "CL" then this should be represented as the "resourceType" = "anonCredsCredDef" within the Payload file.
CredDef Payload File
The Payload file utilises the inputs from the Resource file where possible, mapping common fields across. The Payload file may also require additional inputs to be provided by the creator to create a DID-Linked Resource for inputs not provided in the Resource file.
Below is an example of a Payload file:
{
"payload": {
"collectionId": "zF7rhDBfUt9d1gJPjx7s1J",
"id": "77465164-5646-42d9-9a0a-f7b2dcb855c0",
"name": "universityDegree", // this is an additional input
"version": "1.0", // this is an additional input which can be derived from the tag
"resourceType": "anonCredsCredDef",
"alsoKnownAs": []
},
"signInputs": [
{
"verificationMethodID": "did:cheqd:mainnet:zF7rhDBfUt9d1gJPjx7s1J#key1",
"privKey": "y4B5qis9BXUq/mODsrWtS3q5ejOk/okSIXlX1/a9HvuG3PgYmekfQmq3QhJ4JSzN/rkiGCQDNKoTXMmxuXDHbg=="
}
]
}
When passing the Payload file to the ledger, additional inputs may be required within the Payload file to populate the DID-Linked Resource. In this instance, the only additional information required is:
Additional parameter
Expected input
Rationale
"name"
"universityDegree"
The Payload file drawing inputs from the Resource file on its own does not provide the ledger the requisite amount of information to create a full DID-Linked Resource. resourceName must be provided as an additional input parameter
Publishing resource using CLI
For example, the full request format using a CLI should be structured as follows:
Once you have created your resource on cheqd, the following metadata will be generated in the DID Document Metadata associated with did:cheqd:mainnet:zF7rhDBfUt9d1gJPjx7s1J
Importantly, this allows each new resource to be indexed and versioned by their:
resourceName
resourceType
New resources can be created to update the existing CredDef or RevRegDef, whilst maintaining the historical state of the previous versions. See the documentation on Publishing a New Version of a Resource to understand this further.
We propose that the resourceName for CredDefs, Revocation Registry Definitions and Status Lists should remain the same when each of these resources is part of the same AnonCred. This will make it easier for resources to query by resourceName and resourceType to delineate between the three resources using a common root.
Note: across all three of these queries, the resolver would fetch the latest version of the resource by default
Constructing an AnonCred with this logic
The AnonCreds construction below uses this logic to demonstrate how an application could derive the latest Status List using the "rev_reg_id" since it shares the same root and would only require replacing "anonCredsRevocRegDef" with "anonCredsStatusList".
This is similar to how Hyperledger Indy uses composite strings to derive assoicated AnonCreds Objects from others. For example:
Like with Schema Objects, each CredDef Object ID (cred_def_id) was previously a composite string, consisting of the following elements:
issuer DID: The DID of the Issuer, the issuer of the credentials that will utilise the CredDef.
object type: The type of object. 3 is used for CredDefs.
signature_type: The signature_type item for the CredDef (this is 'CL' in the AnonCreds Specification)
schema_id: Also referred to as the ref, this should be a URL for the schema_id.
tag: A unique name or tag given to the CredDef.
Note: the schema_id as part of the_ cred_def_id is a recent change from the AnonCreds Working Group. Previously, this was the Schema TXN ID. However, the Schema TXN ID could not accommodate for non-Hyperledger Indy networks.
The cred_def_id therefore was formatted in the following way:
Through combining each of the components into one string, it provides client applications all of the information they need to know about the CredDef in a simple and easily consumable format.
This is important to mention, since many client applications may still expect CredDef IDs or CredDef Content to contain the information or specific syntax of this Legacy cred_def_id.