Coder Social home page Coder Social logo

onyx-ssi-sdk's Introduction

NOTE - All hackathon submissions for the Digital Identity Hackathon (Sept 12 - Oct 8) need to be sent to the hackathon organizer, Encode club. PRs will not be considered as offical submissions for the Digital Identity hackathon.

Onyx SSI SDK

Create SSI Ecosystems following W3C Standards for Verifiable Credentials and DIDs

  • Create and verify Verifiable Credentials and Verifiable Presentations
  • Support for did:ethr and did:key
  • Support for JWT as digital proof
  • Support for Verifiable Credential Schemas

How to Use REPO

Prerequisites

  • Nodejs v16

Installation

npm install @jpmorganchase/onyx-ssi-sdk

Build

This project is built to support both CommonJS and ECMAScript Module Formats

The CommonJS format is configured in configs/tsconfig.cjs.json and the ECMAScript is configured in configs/tsconfig.esm.json

npm install
npm run build

Tests

Unit Tests: npm run test

Hardhat:

npx hardhat compile
npx hardhat test

Navigating the SDK

  • DID Management: Create, Resolve, Update, and Delete the 2 supported DID Methods (did:key and did:ethr)
  • Credential Schema Management: Example of 4 Credential Types and their schemas as well as helper methods for Schema Management
  • JWT Signatures: Sign Verifiable Credentials as JWTs
  • Issuer: All functionality required to be a Credential Issuer
  • Holder: All functionality required to be a Credential Holder
  • Verifier: All functionality to perform basic Credential verification
  • KeyUtils: Helper functions for SDK supported keys

Full SSI Ecosystem Example

For examples of how to use the SDK, check out our onyx-ssi-sdk-examples repo

Below code shows the VC Creation, VP Presentation and Verification of W3C Credential/Presentation.

//DID Key
const didKey = new KeyDIDMethod()

//DID Ethr configs
const ethrProvider = {
    name: 'maticmum', 
    rpcUrl: 'https://rpc-mumbai.maticvigil.com/', 
    registry: "0x41D788c9c5D335362D713152F407692c5EEAfAae"}
   
console.log('-----------------VC Issuance---------------')
       
//create DID for Issuer (did:ethr)
const didEthr = new EthrDIDMethod(ethrProvider)
const issuerEthrDid = await didEthr.create();
   
//create DID for Holder of Credential (did:key)
const holderDID = await didKey.create();
   
//create DID for VC to support Revocation of Credential
const vcDID = await didEthr.create();
   
//Create a 'Proof of Name' VC
const subjectData = {
    "name": "Ollie"
}
   
//Additonal parameters can be added to VC including:
//vc id, expirationDate, credentialStatus, credentialSchema, etc
const additionalParams = {
    id: vcDID.did,
    expirationDate: "2024-01-01T19:23:24Z",
}
   
const vc = await createCredential(
    issuerEthrDid.did, holderDID.did, subjectData, PROOF_OF_NAME, additionalParams)
console.log(JSON.stringify(vc, null, 2))
   
const jwtService = new JWTService()
const jwtVC = await jwtService.signVC(issuerEthrDid, vc)
console.log(jwtVC)
   
console.log('-----------------VC Presentation---------------')
   
//Create Presentation from VC JWT
const vp = await createPresentation(holderDID.did, [jwtVC])
console.log(JSON.stringify(vp, null, 2))
   
const jwtVP = await jwtService.signVP(holderDID, vp)
console.log(jwtVP)
   
console.log('----------------------VERIFY VC/VP------------------')
       
//create DID resolvers
const ethrResolver = getEthrResolver(ethrProvider)
const keyResolver = getKeyResolver()
const didResolver = new Resolver({
    ...ethrResolver, 
    ...keyResolver})
   
   
//Verify VC JWT from Issuer
const resultVc = await verifyCredentialJWT(jwtVC, didResolver)
console.log(resultVc)
       
//Verify VP JWT from Holder
const resultVp = await verifyPresentationJWT(jwtVP, didResolver)
console.log(resultVp)

Standards and Specifications

Open Source Identity Packages

SDK Hackathon Challenges

As part of the hackathon we are offering 5 challenges to help improve our SDK.

To participate in these challenges please fork this repo, implement your changes, and submit your branch to Encode. We are not accepting PRs on this repo through the duration of the hackathon.

  • DIDs: Add support for a new DID method or support the Universal Resolver
  • JSON-LD Credentials: Provide support for JSON-LD Credentials
  • Revocation: Implement a new Credential Revocation scheme
  • SD-JWT: Implement the emerging SD-JWT spec for selective disclosure
  • Communication: Implement support for OIDC, DIDComm or Presentation Exchange

onyx-ssi-sdk's People

Contributors

apratt3377 avatar adityataday avatar t3rrym avatar leungy23 avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.