Skip to main content

Claim

In this section, you'll play the role of a claimer.

  • You'll first make a claim about yourself in the form of a Claim object;
  • But a claim in itself has no value. To become valid in the eyes of verifiers, it needs to be attested by an entity that verifiers trust: an attester. So you'll create a RequestForAttestation object from your Claim object, sign it with the DID, so that an attester can attest it.
  • The claim will eventually be attested.

We'll look into the attestation in the next steps - for now, let's just focus on your claim.

๐Ÿ’ก ProofID is an open system. Anyone/anything can make a claim about themselves. But a claim only has value if the verifier trusts the attester.

Create a file

Create a new file claim.js. All of the code for this step needs to go into this file.

Code: create a Claim

In the previous step, you've generated two mnemonics, DIDs and accounts. You'll now need the first mnemonic you've created; it's referred to as <claimerMnemonic> in the code snippet below.

We'll create a claim using the provided CTYPE and the claimer account.
Paste the following in claim.js.

const ProofID = require('@proofid/pid-ts-lib')

function createClaim(claimerLightDid, ctype) {
// These contents can be replaced following the schema types
const claimContents = {
name: 'Alice',
age: 25,
}

const claim = ProofID.Claim.fromCTypeAndClaimContents(
ctype,
claimContents,
claimerLightDid.did
)

return claim
}

module.exports.createClaim = createClaim

Don't forget to add imports into the index.js

Code: create a RequestForAttestation

Once your claim will be built, you will want to sign it and prepare it for the attester. To do so, let's build a RequestForAttestation object from your Claim.

Now let's create a new file requestForAttestation.js and paste the following code

const ProofID = require('@proofid/pid-ts-lib')

async function createRequestForAttestation(claimerLightDid, claim, keystore) {
const requestForAttestation = ProofID.RequestForAttestation.fromClaim(claim)

await requestForAttestation.signWithDid(keystore, claimerLightDid)

// log this so you can paste it locally
console.log(
'requestForAttestationJSONString:\n',
JSON.stringify(requestForAttestation)
)

return requestForAttestation
}

module.exports.createRequestForAttestation = createRequestForAttestation

Add the following imports to your main function inside index.js:

Run

Run the code by running this command in your terminal, still within your pid-app directory:

node index.js

This outputs all the previous code and now your RequestForAttestation object.

we'll need it in the next step to get it attested by an attester.

let others attest your claim

In a real-life setup, the different actors - claimer, attester and verifier - communicate with each other via a messaging system and can rely on the ProofID SDK's messaging capabilities.

We don't need to do this here.

If you're following this tutorial on your own, you're playing all three ProofID roles: claimer, attester and verifier. So you can simply copy the outputs of the different functions you're calling and use them as inputs for the other actors.

If you're following this as a workshop, you can simulate message exchange by exchanging your requests via chat, email, or simply by pasting requests for attestations or credentials in a shared document such as this hackmd.

OK, you've made a claim as a claimer and created a request for attestation.

Let's switch roles and get this attested!