Credentials
The Credentials SDK offers developers a way to manage the life-cycle of credentials including creation, proving and verification. The SDK also enables the storage of credentials using the Files SDK. The list of credentials is ONLY visible to the Wallet owner and is used for storage purposes only.
Note: The length of each entry in the Credential is constrained by a maximum of 32 characters
Import the necessary libraries:
Instantiating the NotVault classes:
With these statements, we instantiate the NotVault
, Files
, and Credentials
classes, providing the necessary foundations for credential operations.
Defining a dataset:
Here, we define a dataset that will be verified to create a credential. The example below describes a passport dataset.
Defining a schema for the credential:
We create a schema defining the structure of the credential.
Issuing a credential:
Issuing a Credential is the process of creating a cryptographic dataset which is derived from an initial dataset. The Credential is an attestation of the integrity of the original dataset.
Creating a query:
A query with constraints or criteria is necessary to generate a proof. We are proving that a Credential respects certain constraints. In the example below, we are proving that the date of birth in Credential above is between specified values. Furthermore, we are sharing an aggregated hash of the Last Name and Country fields, as this example relates to a passport.
Upper and lower boundary constraints are only applied to numbers and dates. Text data can only be verified by exact matches. Read more on this in the verification section below.
The proof will not be generated if the numerical data is not within the ranges stated in the constraints.
Generating a proof:
A query with constraints or criteria is necessary to generate a proof. We are proving that a Credential respects certain constraints. In the example below, we are proving that the date of birth in Credential above is between specified values. Furthermore, we are sharing an aggregated hash of the Last Name and Country fields, as this example relates to a passport.
Upper and lower boundary constraints are only applied to numbers and dates. Text data can only be verified by exact matches. Read more on this in the verification section below.
The proof will not be generated if the numerical data is not within the ranges stated in the constraints.
Verifying a credential:
Verifying a proof requires the values of the fields above. As mentioned, proofs are only generated if the numerical constraints are met. The proof will contain an aggregated hash of the text data.
The verification happens when the verifier creates an aggregated hash of the text values, which they expect the credential to contain. The first parameter below contains this information and the verification function will only return true if this information matches the information implicitly contained in the proof.
Listing all credentials:
We fetch all credentials.
Adding a new credential:
We add a new credential to the list.
Removing a credential:
We eliminate a credential from the private list.
Please refer to the original TypeScript code context for a detailed breakdown of the parameters required for each function.
Last updated