An open API service indexing awesome lists of open source software.

https://github.com/path-check/eddsa-jxt-sdk.js

Verifiable QR SDK for W3C Vaccination Credentials with EDDSA Signatures and JSONXT
https://github.com/path-check/eddsa-jxt-sdk.js

Last synced: 12 days ago
JSON representation

Verifiable QR SDK for W3C Vaccination Credentials with EDDSA Signatures and JSONXT

Awesome Lists containing this project

README

          

# Verifiable QR SDK for EDDSA on JSON-XT Credentials

JavaScript Implementation of W3C Verifiable QR Credentials with EDDSA and minimization to a QR code with [JSON-XT](https://jsonxt.io/).

# Install

```sh
npm install @pathcheck/eddsa-jxt-sdk --save
```

# Usage

## 1. Generating Keys

Generate private and public keys with the provided script:

```js
npm explore @pathcheck/eddsa-jxt-sdk -- npm run-script keys
```

Example:
```js
npm explore @pathcheck/eddsa-jxt-sdk -- npm run-script keys PCF.PW 1A12 WEB1
```
Returns:
```js
/*******************************************************************************
Here are your SECRET keys. Key this private and use it to sign new packages.
*******************************************************************************/
{
'@context': [
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/suites/ed25519-2020/v1'
],
id: 'did:web:PCF.PW:1A12#WEB',
controller: 'did:web:PCF.PW:1A12',
type: 'Ed25519VerificationKey2020',
privateKeyMultibase: 'z4SnSYUVkioEPtzbeZ8wr8QJumzoLztf1gukRAFf7e4SrH3xWYj4mvFLQK1V6rDqHhFoyj2yA3ZSAcgZqYEmdNNKr',
publicKeyMultibase: 'zEzZ1wbzTHS232pKov6nfz38g5tkdtZ5d9ndCoaf9yG8G'
}

/***************************************************************************************************
Here are your PUBLIC DID document. Save this part as a .json and upload it to PCF.PW/1A10/did.json
****************************************************************************************************/
{
'@context': [
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/suites/ed25519-2020/v1'
],
id: 'did:web:PCF.PW:1A12',
type: 'Ed25519VerificationKey2020',
verificationMethod: [
{
'@context': [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
id: 'did:web:PCF.PW:1A12#WEB',
type: 'Ed25519VerificationKey2020',
controller: 'did:web:PCF.PW:1A12',
publicKeyMultibase: 'zEzZ1wbzTHS232pKov6nfz38g5tkdtZ5d9ndCoaf9yG8G'
}
],
authentication: [ 'did:web:PCF.PW:1A12#WEB' ],
assertionMethod: [ 'did:web:PCF.PW:1A12#WEB' ],
capabilityDelegation: [ 'did:web:PCF.PW:1A12#WEB' ],
capabilityInvocation: [ 'did:web:PCF.PW:1A12#WEB' ]
}
```

## 2. Uploading Public Keys

Copy the second segment (PUBLIC DID DOCUMENT) as a JSON file to your `domain/controllerName/did.json`

```json
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "did:web:PCF.PW:1A12",
"type": "Ed25519VerificationKey2020",
"verificationMethod": [
{
"@context": [
"https://www.w3.org/ns/did/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "did:web:PCF.PW:1A12#WEB",
"type": "Ed25519VerificationKey2020",
"controller": "did:web:PCF.PW:1A12",
"publicKeyMultibase": "zEzZ1wbzTHS232pKov6nfz38g5tkdtZ5d9ndCoaf9yG8G"
}
],
"authentication": [ "did:web:PCF.PW:1A12#WEB" ],
"assertionMethod": [ "did:web:PCF.PW:1A12#WEB" ],
"capabilityDelegation": [ "did:web:PCF.PW:1A12#WEB" ],
"capabilityInvocation": [ "did:web:PCF.PW:1A12#WEB" ]
}
```

The DID:WEB Resolver will point to that address (e.g. [`http://pcf.pw/1A12/did.json`](http://pcf.pw/1A12/did.json)) to download your public keys and verify the package.

## 3. Preparing to Sign

With the keys:

```js
const keyPair = {
'@context': [
'https://www.w3.org/ns/did/v1',
'https://w3id.org/security/suites/ed25519-2020/v1'
],
id: 'did:web:PCF.PW:1A12#WEB',
controller: 'did:web:PCF.PW:1A12',
type: 'Ed25519VerificationKey2020',
privateKeyMultibase: 'z4SnSYUVkioEPtzbeZ8wr8QJumzoLztf1gukRAFf7e4SrH3xWYj4mvFLQK1V6rDqHhFoyj2yA3ZSAcgZqYEmdNNKr',
publicKeyMultibase: 'zEzZ1wbzTHS232pKov6nfz38g5tkdtZ5d9ndCoaf9yG8G'
};
```

And a JSON-LD Payload (We are using EU's Digital COVID Certificate, version 1.2.0, as an example)

```js
const TEST_PAYLOAD = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/dgc/v1",
],
type: ["VerifiableCredential"],
issuer: "did:web:PCF.PW:1A12",
issuanceDate: "2021-05-18T16:06:06Z",
credentialSubject: {
"@context": ["https://w3id.org/dgc/v1"],
type: "DGCCertificate",
personalInformation: {
"@context": ["https://w3id.org/dgc/v1"],
type: "DGCSubject",
familyName: "d'Arsøns - van Halen",
givenName: "François-Joan",
stdFamilyName: "DARSONS