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
- Host: GitHub
- URL: https://github.com/path-check/eddsa-jxt-sdk.js
- Owner: Path-Check
- License: gpl-3.0
- Created: 2021-06-09T00:44:07.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-14T20:58:59.000Z (about 5 years ago)
- Last Synced: 2025-08-25T02:40:54.814Z (10 months ago)
- Language: JavaScript
- Size: 142 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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