Skip to content

Commit

Permalink
Create sdjwt challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
apratt3377 authored Sep 10, 2023
1 parent d5eeff6 commit db484a9
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/services/common/signatures/SDJWT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Selective Disclosure

Selective disclosure enables a Holder of a Verifiable Credential to choose which pieces of information will be revealed to a Verifier. This gives the Holder more flexibility and enables them to only share the information needed by the recipient without having to claim multiple atomic credentials.

There are different ways of performing selective disclosure with Verifiable Credentials including BBS+ signatures and SD-JWT. In this challenge we would like to explore implementing the SD-JWT spec. However, other selective disclosure implementations are welcome.

**Goal**: Provide support for creating a Verifiable Credential represented as a JWT that supports selective disclosure of claim values conforming to the SD-JWT spec.

## Spec

### SD-JWT

A [Selective Disclosure JSON Web Token (SD-JWT)](https://www.ietf.org/archive/id/draft-ietf-oauth-selective-disclosure-jwt-04.html) is a type of JSON Web Token in which the claims in the body are hashed, making them unreadable without disclosure.
The original values of the claims can only be revealed by providing the necessary disclosures.

* [Shorter explanation]( https://api-pilot.ebsi.eu/docs/specs/guidelines/selective-disclosure-sd-jwt) of spec from EBSI
* [Reference Implementation](https://github.com/christianpaquin/sd-jwt)

### Functionality to Implement
To complete this challenge, the below should be implemented:
* Functions to support Issuance of SD-JWT Verifiable Credential by an Issuer
* Functions to support Presentation of an SD-JWT Verifiable Credential from the Holder to a Verifier
* Functions to support Verification of an SD-JWT Verifiable Credential by a Verifier

## Where to Start/Implementation Details

A [`sdjwt.ts`](sdjwt.ts) starter file has been created to implement the sd-jwt spec for issuance, presentation, and verification of a selective disclosure Verifiable Credential

### Issuance of SD-JWT
1. Issuer creates Verifiable Credential as usual
2. Issuer transforms Credential into an SD-JWT
3. Issuer sends SD-JWT and all disclosures to holder

#### Transfomation of VC into SD-JWT
1. all or some of claims transformed into disclosures (salt + attributename + given value)
2. disclosure converted to base64 string
3. disclosure put into hash function
4. the hashed discl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LTI3Il0"

### Presenting a SD-JWT
1. Holder shares the SD-JWT with concatenated disclosures appended to JWT by ~

### Verifying a SD-JWT
1. Verifier receives disclosures and SD-JWT
2. Confirms that shared disclosures are part of SD-JWT by hashing the received disclosures and comparing the hashed values with the values present in SD-JWT

## Testing
The functionality added for this challenge should be unit tested. Tests can be added [here](../../../../tests/unit/signatures)

## Criteria For Completion
* All [functionality](#Functionality-to-Implement) has been implemented
* Code written has corresponding unit tests (90% coverage)
* Code is well documented
* Code passes CI github action (building, linting, and testing of SDK)

0 comments on commit db484a9

Please sign in to comment.