Skip to content

Commit

Permalink
[openwallet-foundation-labs#38]Add comments on README example
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas <Lukas@hopae.io>
  • Loading branch information
lukasjhan committed Dec 20, 2023
1 parent 34ab8d2 commit 413ca84
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,36 @@ Here's a basic example of how to use this library:
```jsx
import sdjwt from '@hopae/sd-jwt';

// Define the claims object with the user's information
const claims = {
firstname: 'John',
lastname: 'Doe',
ssn: '123-45-6789',
id: '1234',
};

// Define the disclosure frame to specify which claims should be disclosed
const disclosureFrame = {
_sd: ['firstname', 'lastname', 'ssn'],
};

// Issue a signed JWT credential with the specified claims and disclosure frame
// return a Encoded SD JWT.
const credential = await sdjwt.issue(claims, privateKey, disclosureFrame);

// Define the presentation frame to specify which claims should be presented
const presentationFrame = ['firstname', 'id'];
const presentation = await sdjwt.present(encodedSdjwt, presentationFrame);

const verified = sdjwt.verify(presentation, publicKey, ['firstname', 'id']);
// Create a presentation using the issued credential and the presentation frame
// return a Encoded SD JWT.
const presentation = await sdjwt.present(credential, presentationFrame);

// Define the required claims that need to be verified in the presentation
const requiredClaims = ['firstname', 'id'];

// Verify the presentation using the public key and the required claims
// return a boolean result
const verified = sdjwt.verify(presentation, publicKey, requiredClaims);
```

Check out more details in our [documentation](https://github.com/openwallet-foundation-labs/sd-jwt-js/wiki)
Expand Down

0 comments on commit 413ca84

Please sign in to comment.