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.
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
- Nodejs v16
npm install @jpmorganchase/onyx-ssi-sdk
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
Unit Tests: npm run test
Hardhat:
npx hardhat compile
npx hardhat test
- 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
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)
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