Indy Anoncreds verifier initialization
Verifier1 must first identify the credential definition ID from
issuer1. This ID is available on website of the issuer1 or another
public resource. It is similar to finding a public key of a certificate authority in the PKI system,
except that a credential definition ID is permanent and recorded on the ledger.
For example, <cred-def-id> is the credential definition ID (the value
of the id field in the previous response) used throughout this example.
During initialization, the verifier can optionally create a proof schema. The ID of this schema can be referenced for each verification. If you prefer not to create a schema during initialization, you can specify the proof request during each verification.
To create a proof schema for verifier1, use the following command:
curl --header 'Authorization: Bearer ${verifier_verifiable_credentials_access_token}' -X POST -d @proof_schema.json --location 'https://${service_url}/v1.0/diagency/proof_schemas -H 'Content-Type: application/json'
proof_schema.json file
contains:{
"name": "proof-schema1",
"version": "1.0",
"requested_attributes": [
{
"names": ["class", "grade"],
"restrictions": [{"cred_def_id": "<cred-def-id>"}]
},
{
"name": "phone_number"
}
],
"requested_predicates": [
{
"name": "rank",
"p_type": "<=",
"p_value": 10,
"restrictions": [{"cred_def_id": "<cred-def-id>"}]
}
],
"cred_filter": [
{
"attr_name": "class",
"attr_values": ["Math 100"]
"exclude": true
},
{
"attr_name": "class",
"attr_values": ["Math *"]
}
]
}<cred-def-id> must be replaced with the actual
value as determined in the previous section.requested_attributes and
requested_predicates are NOT applicable for JSONLD/BBS+ credentials.-
nameandversion: The combination ofnameandversionmust be unique for each proof schema. -
requested_attributes: This specifies the attributes. Eachrequested_attributeselement must include anameornamesfield. Ifnamesis used withrestrictions, all attribute names must originate from a single credential.To verify proofs, you need to ensure that
classandgradeattributes come from a single credential that is issued by a specific issuer that owns<cred-def-id>. Consider the following scenario:Faber College issues credentials with two attributes:
classandgrade. Alice holds two credentials from Faber College in her wallet:{"class":"Math 100", "grade":"A"} {"class":"Math 200", "grade":"D"}If
requested_attributesare specified as follows, Alice can return a proof with the class value ofMath 200from the second credential and the grade value ofAfrom the first credential."requested_attributes": [ { "name": "class", "restrictions": [{"cred_def_id": "<cred-def-id>"}] }, { "name": "grade", "restrictions": [{"cred_def_id": "<cred-def-id>"}] } ]This scenario demonstrates why you must always use the
namesformat when requiring multiple attributes to originate from a single credential, unless you intend to allow attributes from different credentials.A self-attested attribute can be requested by omitting the
restrictionsfield from arequested_attributeselement. In the previous example, a verifier requests the value of thephone_numberattribute, but it does not have to come from an issued credential. The prover can:- Manually provide the attribute value (not from a credential in the wallet of the prover).
- Use a value from a credential in the wallet of the prover, if available.
-
requested_predicates: This allows you to request proof of an attribute without revealing its exact value. A typical use case is verifying whether someone is 21 years old or older without revealing their actual age.Each
requested_predicatesentry must include the following fields:- name: Indicates he attribute name.
- p_type: Indicates the predicate operation (valid values are
>,>=,<,<=). - p_value: Indicates the value to which the attribute is compared.
In the example above, the value of the attribute
rankmust be less than or equal to 10.For each non-self-attested attribute or predicate, you must include a
restrictionsfield that lists the criteria that must be met. The value of therestrictionsfield is an array, where:- Each element of the array is connected by a logical OR.
- All keys within a single element are connected by a logical AND.
Consider the following example of restrictions field:
"restrictions": [{"schema_name": "myschema", "schema_version": "1.0"}, {"cred_def_id": "XXX"}]This can be interpreted as:(schema_name == 'myschema' AND schema_version == '1.0') OR cred_def_id == 'XXX'Supported restriction operators include:
-
cred_def_id: The credential definition ID. -
schema_id: The DID of a credential schema. -
schema_issuer_did: The DID of the schema issuer. -
schema_name: The name of the schema. -
schema_version: The schema version. -
issuer_did: The DID of the credential issuer.
Thecred_filter:cred_filterreduces the number of choices a prover has when selecting credentials. This reduction can be based on the value of one or more attributes in a credential.cred_filtervalue is an array of rules. The first rule that matches determines whether the credential is included or excluded from the prover’s view.The fields of each element of the rule are:-
attr_name: The name of an attribute in the credential (required). -
attr_values: An array of strings, each of which may be a regular expression. A rule matches if the credential contains the attribute name and the value matches any of the regular expressions in the list (required). -
exclude: A Boolean field that determines whether to include or exclude the credential if a rule matches. The default value isfalse(optional).
In the following example, two rules are applied:
-
Exclude credentials with a
classattribute value of"Math 100":{ "attr_name": "class", "attr_values": ["Math 100"] "exclude": true } -
Include credentials with a
classattribute value beginning with"Math ":{ "attr_name": "class", "attr_values": ["Math *"] }
-
The format of a proof schema is identical to that of a proof request. A proof schema serves as a reusable and referencable proof request. You can either create proof schemas or dynamically specify the proof request for each verification.