From 1ea8a90572fa83b9d0515e0a1583a32847470a0d Mon Sep 17 00:00:00 2001 From: Cristian Gonzalez <113917899+cristianIOHK@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:43:25 -0400 Subject: [PATCH] docs: update SDK verification examples (#189) Signed-off-by: Cristian G --- .../docs/examples/SDKVerification.md | 59 +++++++++++++++---- 1 file changed, 47 insertions(+), 12 deletions(-) diff --git a/edge-agent-sdk/docs/examples/SDKVerification.md b/edge-agent-sdk/docs/examples/SDKVerification.md index 7de01a09a..872048f92 100644 --- a/edge-agent-sdk/docs/examples/SDKVerification.md +++ b/edge-agent-sdk/docs/examples/SDKVerification.md @@ -1,7 +1,7 @@ # Cross-Platform Edge SDK Verification ## Requirements 1. A working Identus Mediator and an Identus Cloud Agent. -2. A holder who already has a JWT Credential issued by a known issuer (prism:did) [Holder A] +2. A holder who already has a JWT or Anoncred Credential issued by a known issuer (prism:did) [Holder A] 3. A holder who does not have credentials but aims to start the Verification [Holder B (verifier)] 4. Holder A shares its peerDID with holder B. 5. Holder B will initiate a presentation request @@ -15,7 +15,7 @@ > NOTE: > It follows the [Identity Foundation Presentation-exchange V2 protocol](https://identity.foundation/presentation-exchange/spec/v2.0.0/#input-descriptor) > -> Claims can be +> Claims can be for JWT: > ```kotlin > data class InputFieldFilter( > val type: String, @@ -24,17 +24,25 @@ > val const: List? = null, > val value: Any? = null) > ``` +> +> Claims can be for Anoncreds: +> ```kotlin +> data class AnoncredsPresentationClaims( +> val predicates: Map, +> val attributes: Map) +> ``` ## Flow 1. Holder B Initiates the Presentation Request: creating a PresentationDefinitionRequest with specified requirements. -2. Holder A, will then create a Presentation Submission which contains the requested credential together with a randomised challenge. -3. Holder B, will receive the Presentation Submission and verify the following - * Holder A signed the JWT presentation with the correct signatures. - * Holder A signed the random challenge that required them to have the correct keys. - * Holder A includes a credential of its owns and not somebody else's. - * Holder A includes a credential with valid signatures, matching the issuer through the specified DID. - * (optional) Holder A has included a credential that the requested issuer has issued. - * (optional) Holder A has included a credential that satisfies the requested claims. +2. Holder A, will then create a Presentation which meets the criteria received as part of the request. +3. Holder B, will receive the Presentation and verify the following + * [JWT] Holder A signed the JWT presentation with the correct signatures. + * [JWT] Holder A signed the random challenge that required them to have the correct keys. + * [JWT] Holder A includes a credential of its owns and not somebody else's. + * [JWT] Holder A includes a credential with valid signatures, matching the issuer through the specified DID. + * [JWT] (optional) Holder A has included a credential that the requested issuer has issued. + * [JWT] (optional) Holder A has included a credential that satisfies the requested claims. + * [Anoncreds] Holder A presentation meets the attributes and predicates requested. 4. Holder B can then verify at any point in time that presentation request and show feedback in UI. ## Code Reference @@ -43,9 +51,9 @@ * The Edge Agent Verifier (SDK) will then send the Presentation Request to the desired holder -Example +Example for JWT ```kotlin -val claims = PresentationClaims( +val claims = JWTPresentationClaims( claims = mapOf( "email" to InputFieldFilter( type = "string", @@ -63,6 +71,33 @@ agent.initiatePresentationRequest( ) ``` +Example for Anoncreds +```kotlin +val claims = AnoncredsPresentationClaims( + predicates = mapOf( + "0_age" to AnoncredsInputFieldFilter( + type = "string", + name = "age", + gte = 18 + ) + ), + attributes = mapOf( + "0_name" to RequestedAttributes( + "name", + setOf("name"), + emptyMap(), + null + ) + ) +) + +agent.initiatePresentationRequest( + type = CredentialType.ANONCREDS_PROOF_REQUEST, + toDID = toDID, + presentationClaims = claims +) +``` + * The Edge Agent Holder will be asked to choose what credential wants to be used for that Presentation Request Example