Skip to content

Commit

Permalink
chore: add challenge to presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Feb 23, 2022
1 parent ae82e04 commit 8cd592e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,18 @@ A verifier usually requires a claimer to fulfil some requirements before providi
The verifier needs to initiate the verification process by requesting a presentation for a specific CType.
In this case, the verifier wants to verify the name of the claimer.
To do so, it will send a request for credential message to the claimer.
The request for credential can optionally contain a challenge that will be used by the verifier to ensure that the claimer owns the identity specified in the provided credentials at the time the presentation is generated.

```typescript
const challenge = Kilt.Utils.UUID.generate()
const requestForCredentialMessage = new Kilt.Message(
{
type: Kilt.Message.BodyType.REQUEST_CREDENTIAL,
content: {
cTypes: [
{ cTypeHash: ctype.hash, trustedAttesters: [attesterFullDid.did] },
],
challenge,
},
},
verifierLightDid.did,
Expand All @@ -548,6 +551,7 @@ const selectedCredential = await credential.createPresentation({
selectedAttributes: ['name'],
signer: keystore,
claimerDid: claimerLightDid,
challenge,
})
console.log('Presentation:')
console.log(JSON.stringify(selectedCredential))
Expand Down
3 changes: 3 additions & 0 deletions docs/getting-started.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,15 @@ async function main(): Promise<void> {
console.log(`Verifier DID: ${verifierLightDid.did}`)

/* 5.2 Ask for credentials */
const challenge = Kilt.Utils.UUID.generate()
const requestForCredentialMessage = new Kilt.Message(
{
type: Kilt.Message.BodyType.REQUEST_CREDENTIAL,
content: {
cTypes: [
{ cTypeHash: ctype.hash, trustedAttesters: [attesterFullDid.did] },
],
challenge,
},
},
verifierLightDid.did,
Expand All @@ -301,6 +303,7 @@ async function main(): Promise<void> {
selectedAttributes: ['name'],
signer: keystore,
claimerDid: claimerLightDid,
challenge,
})
console.log('Presentation:')
console.log(JSON.stringify(selectedCredential))
Expand Down

0 comments on commit 8cd592e

Please sign in to comment.