Identity Proofs

This document describes how to create proof statements and how to verify them.

Table of Contents:

Build Statement

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:

From ./../examples/nodejs/common/statements.ts#9~35

// 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:

  • The used attribute tag is a known one
  • There is not multiple statements on the same attribute
  • Lower, upper and sets members have the format expected of the attribute

Minimum Age

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);

Eu membership

There are helpers for specifying the country of residency or nationality to be one of the EU member states.

    statementBuilder.addEUNationality();
statementBuilder.addEUResidency();

Reveal statement

State that a given attribute should be revealed as part of the proof.

    statementBuilder.revealAttribute(AttributesKeys.nationality);

Range statement

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:

  • dob (date of birth)
  • idDocIssuedAt
  • idDocExpiresAt

Membership statement

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:

  • Nationality
  • CountryOfResidency
  • IdDocIssuer
  • IdDocType

Non membership statement

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:

  • Nationality
  • CountryOfResidency
  • IdDocIssuer
  • IdDocType

Verify Statement (verifyIdstatement)

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;
}

Prove Statement (getIdProof)

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