This document describes how to create proof statements and how to verify them.
Table of Contents:
The SDK contains a helper to create statements about identities, which can then be proven.
To do so, use the IdStatementBuilder, to build a statement:
// Prover's age must be over 18:
statementBuilder.addMinimumAge(18);
// Prover's country of nationality to be a EU member state:
statementBuilder.addEUNationality();
// Prover's country of residency to be a EU member state:
statementBuilder.addEUResidency();
// Prover must not be living in Germany or Poland.
//statementBuilder.addNonMembership(AttributesKeys.countryOfResidence, [
// 'DE',
// 'PT',
//]);
// We also reveal the type of documentation of the prover.
statementBuilder.revealAttribute(AttributesKeys.idDocType);
// The statement we wish to prove:
const statement = statementBuilder.getStatement();
// Test that the statement is well formed (validly constructed).
// Will throw otherwise.
verifyIdstatement(statement);
console.log('Succesfully constructed statement \n');
The statement can then be proved using the getIdProof
, or be provided to a
wallet for them it to provide a proof for the statement. There are currently
4 types of the statements, and if multiple are added, the resulting statement
is the conjunction between them.
Attribute name | Format |
---|---|
firstName | string |
lastName | string |
sex | ISO/IEC 5218 |
dob | ISO8601 YYYYMMDD |
countryOfResidence | ISO3166-1 alpha-2 |
nationality | ISO3166-1 alpha-2 |
idDocType | na=0, passport=1, national id card=2, driving license=3, immigration card=4 |
idDocNo | string |
idDocIssuer | ISO3166-1 alpha-2 or ISO3166-2 if applicable |
idDocIssuedAt | ISO8601 YYYYMMDD |
idDocExpiresAt | ISO8601 YYYYMMDD |
nationalIdNo | string |
taxIdNo | string |
The first parameter of the statement builder is a boolean, which defaults to true, that specifies whether the statement should be checked while being built.
It checks that:
There is a helper function for specifying the prover must have some minimum age.
Example: add the statement that the prover must be born at least 18 years old:
statementBuilder.addMinimumAge(18);
There are helpers for specifying the country of residency or nationality to be one of the EU member states.
statementBuilder.addEUNationality();
statementBuilder.addEUResidency();
State that a given attribute should be revealed as part of the proof.
statementBuilder.revealAttribute(AttributesKeys.nationality);
State that a given attribute should be between 2 given values.
Example: add the statement that the prover must be born between January 1, 1941 and Februar 2, 2005.
statementBuilder.addRange(AttributesKeys.dob, 19410101, 20050202);
Note that this type of statement is only allowed for the following attributes:
Example: add the statement that the prover's country of residency is France or Spain:
statementBuilder.addMembership(AttributesKeys.CountryOfResidency, ['FR', 'ES']);
Note that this type of statement is only allowed for the following attributes:
Example: add the statement that the prover's country of residency not Germany nor Portugal:
statementBuilder.addNonMembership(AttributesKeys.CountryOfResidency, ['DE', 'PT']);
Note that this type of statement is only allowed for the following attributes:
The SDK provides a helper function (verifyIdstatement
) to verify a statement,
that it is well-formed and complies with the current rules. It will throw
an error if the statement does not verify:
const statement = ...
let isValid = true;
try {
verifyIdstatement(statement);
} catch (e) {
// States why the statement is not valid:
console.log(e.message);
isValid = false;
}
The SDK provides a helper function (getIdProof
) to prove an id statement:
const statement = ...
const challenge = ...
const proof = getIdProof({
idObject,
globalContext,
seedAsHex,
net: 'Mainnet',
identityProviderIndex,
identityIndex,
credNumber,
statement,
challenge,
})
Generated using TypeDoc