Skip to content

Update workshop to v1 of SDK #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions code_examples/sdk_examples/src/workshop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { CType } from '@kiltprotocol/credentials'
import { getFunds } from '../getFunds'
// import { releaseWeb3Name } from '../core_features/web3names/04_release'

export function generateAccount() {
export function generateAccounts() {
const issuerAccount = Kilt.generateKeypair({ type: 'ed25519' })
const submitterAccount = Kilt.generateKeypair({ type: 'ed25519' })
const holderAccount = Kilt.generateKeypair({ type: 'ed25519' })
Expand Down Expand Up @@ -380,8 +380,8 @@ export async function runAll() {
seed: '0xe566550fec3ca23d80dfe9e9529ada463b93fc33f17219c1089de906f7253f1c'
})

const { issuerAccount, submitterAccount, holderAccount } = generateAccount()
const verifierAccount = generateAccount()
const { issuerAccount, submitterAccount, holderAccount } = generateAccounts()
const verifierAccount = generateAccounts()

// ┏━━━━━━━━━━━━┓
// ┃ Get funds ┃
Expand Down
13 changes: 0 additions & 13 deletions code_examples/sdk_examples/src/workshop/issuer/generateAccount.ts

This file was deleted.

2 changes: 1 addition & 1 deletion sdk/02_tutorial/01_welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ In this tutorial, you will:
✔ Get familiar with the essential concepts in KILT: accounts, DIDs, CTypes, claims, credentials, and more.
✔ Use the KILT SDK to implement the basic flow of a KILT claim, from creation until verification.

You'll create a claim as a <span className="label-role claimer">Claimer</span>, attest it as an <span className="label-role issuer">Issuer</span> and verify it as a <span className="label-role verifier">Verifier</span>.
You'll create a Credential as an <span className="label-role issuer">Issuer</span>, produce a Credential Presentation as a <span className="label-role holder">Holder</span>, and verify it as a <span className="label-role verifier">Verifier</span>.

✔ Use the KILT SDK to write onto and read from the KILT blockchain.

Expand Down
8 changes: 4 additions & 4 deletions sdk/02_tutorial/03_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ title: 👓 Overview

This tutorial runs through the full story of a claim.

It involves four actors which work together to create **distributed trust**:
It involves four roles which work together to create **distributed trust**:

- A <span className="label-role holder">Holder</span> claims to possess certain credentials, abilities, or other attributes.
- An <span className="label-role issuer">Issuer</span> verifies the claims of a <span className="label-role holder">Holder</span>.
- A <span className="label-role verifier">Verifier</span> asks for proof of a claim.
- A <span className="label-role submitter">Submitter</span> handles and pays for submitting transactions.
- <span className="label-role submitter">Submitter</span> accounts handles and pays for submitting transactions.

In a real-world use case, these actors could be different people and services, which this workshop simulates using different folders and functions for each service or actor.
In a real-world use case, these roles could be different people and services, which this workshop simulates using different folders and functions for each service or actor.

Each actor typically performs different roles:

Expand All @@ -25,7 +25,7 @@ Each actor typically performs different roles:

The <span className="label-role holder">Holder</span> has to register their DID on chain and needs KILT coins.

After both the <span className="label-role holder">Holder</span> and the <span className="label-role issuer">Issuer</span> have set up their identities, the <span className="label-role holder">Holder</span> can start the verification process by requesting an verification from the <span className="label-role issuer">Issuer</span>.
After both the <span className="label-role holder">Holder</span> and the <span className="label-role issuer">Issuer</span> have set up their identities, the <span className="label-role holder">Holder</span> can start the attestation process by requesting an attestation from the <span className="label-role issuer">Issuer</span>.

<!-- TODO: Correct diagrams -->

Expand Down
4 changes: 1 addition & 3 deletions sdk/02_tutorial/05_issuer/02_did.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,11 @@ The method returns a `TransactionHandler` type, which includes two methods:

:::info

The `submit()` method by default, waits for the block to be finalized. [You can override this behavior](https://kiltprotocol.github.io/sdk-js/interfaces/types_src.TransactionHandlers.html) by passing `false` as the second parameter.
The `submit()` method by default, waits for the block to be finalized. [You can override this behavior](https://kiltprotocol.github.io/sdk-js/interfaces/types_src.TransactionHandlers.html) by passing `false` to the `awaitFinalized` named parameter of the `submit` object.

:::

- `getSubmittable`: Produces a transaction that you can submit to a blockchain node for inclusion, or to be signed and submitted by an external service.

In this case, the example uses the `submit` method to submit the transaction to the chain.

:::info Bring your own account

Expand Down
4 changes: 2 additions & 2 deletions sdk/02_tutorial/05_issuer/03_issue_credential.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ A CType has the following attributes:

The [CTypeHUB](https://ctypehub.galaniprojects.de) is a repository of useful CTypes, but there are others. This tutorial uses a CType from [the test CTypeHUB](https://test.ctypehub.galaniprojects.de). You can also create your own CTypes.

Fetch a CType using the `fetchFromChain` method, passing the `$id` of the CType you want to fetch.
Futch a CType using the `fetchFromChain` method, passing the `$id` of the CType you want to fetch.

## Create and issue credential

Expand Down Expand Up @@ -92,4 +92,4 @@ export async function runAll() {
</TabItem>
</Tabs>

Before you can verify Credentials, you need a <span className="label-role holder">Holder</span> to request it.
Before you learn how to verify Credentials, you'll see how the Credential <span className="label-role holder">Holder</span> retains control over their data by deciding what attributes they reveal in a Credential Presentation.
2 changes: 1 addition & 1 deletion sdk/02_tutorial/05_issuer/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ This section of the workshop covers creating the <span className="label-role iss

:::tip

While you can pay deposits and fees with any KILT account you like, your DID stays the same and is the way Holders identify and trust you.
While you can pay deposits and fees with any KILT account you like, your DID stays the same and is the way Holders and Verifiers identify and trust you.

:::

Expand Down
2 changes: 1 addition & 1 deletion sdk/02_tutorial/06_holder/01_did.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This section covers creating a DID using the account you created for the <span c

## Create a DID

As an <span className="label-role holder">Holder</span> needs to interact with the chain, you must create a DID.
A <span className="label-role holder">Holder</span> needs a DID to attach their credentials to and identify the subject of any claims.

### Write DID to chain

Expand Down
6 changes: 3 additions & 3 deletions sdk/02_tutorial/06_holder/02_create_presentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The KILT SDK provides the `createPresentation` method from the `Holder` class to

- `credential`: The derived credential.
- `holder`: The details object of the Holder.
- `presentationOptions`: An optional object specifying what to consider a valid presentation.
- `presentationOptions`: An optional object holding parameters that allow defining when (e.g., how long) and under which circumstances the Credential Presentation is to be considered valid. These are important to ensure that a presentation is not taken out of context or (re-)used without your permission.

The method returns a `VerifiablePresentation` that a Verifier can now verify.

Expand Down Expand Up @@ -77,5 +77,5 @@ export async function runAll() {
</TabItem>
</Tabs>

OK, you've made a claim as a <span className="label-role holder">Holder</span> and created a presentation from it.
The next step is to finish the <span className="label-role issuer">Issuer</span> and get the credential verified!
OK, you've issued a credential as a <span className="label-role holder">Holder</span> and created a presentation from it.
The next step is to finish the <span className="label-role verifier">Verifier</span> and get the credential verified!
2 changes: 0 additions & 2 deletions sdk/02_tutorial/06_holder/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,5 @@ They can use their identity credentials to prove these claims, and third-party i
Anyone with an account can be a Holder.
You need a DID, to complete a CType, and create a claim.

Then, you can send these claims to Issuers for verification.

They store their identity credentials in their digital wallets, so they decide which information to provide to which service.
They have full control over their data and decide which data to share, where, and how.
18 changes: 9 additions & 9 deletions sdk/02_tutorial/07_verification.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@ The Verifier also needs an account and DID, but the tutorial omits these steps.

1. Take a `VerifiablePresentation` object supplied by a <span className="label-role holder">Holder</span>
2. Verify that its data is correct
3. Verify that the presentation is valid, i.e., its hash exists on-chain and the presentation hasn't been revoked
4. Verify that the <span className="label-role holder">Holder</span> sending the `Credential` owns it
3. Verify that the <span className="label-role holder">Holder</span> of the `Credential` has authorised and consented to its use in the current context by checking the presentation's signature and attributes.
4. Verify the authenticity and validity of the credential by checking its on-chain proof created by the Issuer and ensuring it hasn't been revoked since

:::info VerifiablePresentation object
:::info A VerifiablePresentation object

The <span className="label-role holder">Holder</span> uses a Credential to create the `VerifiablePresentation` object.
Unlike the credential, a `VerifiablePresentation` can hide some attributes that aren't required by the <span className="label-role verifier">Verifier</span> and can contain a holder-signed challenge.
A `VerifiablePresentation` also contains a proof that the <span className="label-role holder">Holder</span> owns the credential.
The <span className="label-role holder">Holder</span> uses a Credential to create an array of `VerifiablePresentation` objects as .

:::
A `VerifiablePresentation` object contains an array of `VerifiableCredential` objects, a `holder` value, and a `proof` that the <span className="label-role holder">Holder</span> owns the credential.

## Verify presentation
Each `VerifiableCredential` can hide or show properties, allowing for selective disclosure.

:::

## Verify presentation

The KILT SDK provides the `verifyPresentation` method from the `Verifier` class to verify a credential presentation. It takes the following parameters:

- `presentation`: The `VerifiableCredential` to verify.
- `verficationCriteria`: An object of criteria that need to pass to verify the presentation. These can be any combination of criteria.
<!-- TODO: Find out more link -->

The method returns a boolean value indicating whether the presentation is valid.
The method returns an object with a `verified` boolean that indicates whether the presentation is valid.


<TsJsBlock>
Expand Down
Loading