Skip to content

Instantly share code, notes, and snippets.

@Exulansis
Last active September 25, 2019 13:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Exulansis/903ab4a77b4173c2268f7a0ef90521ac to your computer and use it in GitHub Desktop.
Save Exulansis/903ab4a77b4173c2268f7a0ef90521ac to your computer and use it in GitHub Desktop.
Jolocom Resources

Jolocom

The did:jolo method spec can be found here. A simple diagram illustarting the identity creation flow (using the Wallet) can be found here.

In order to create and interact with Jolocom identities, the Jolocom Library and SmartWallet (links to source code posted below) can be used. Some additional software components can make developing / debugging (also linked below) a bit easier.

Jolocom DID implementation.

DID Document example:

{
  specVersion: 0.13,
  '@context': [
    'https://www.w3.org/2019/did/v1',
    'https://w3id.org/did/v0.11',
    'https://w3id.org/did/v1',
    { EcdsaKoblitzSignature2016: 'sec:EcdsaKoblitzSignature2016' },
    {
      xsd: 'http://www.w3.org/2001/XMLSchema#',
      sec: 'https://w3id.org/security#',
      schema: 'http://schema.org/',
      didv: 'https://w3id.org/did#',
      publicKeyHex: 'sec:publicKeyHex',
      updated: { '@id': 'didv:updated', '@type': 'xsd:dateTime' },
      specVersion: 'schema:version',
      Secp256k1VerificationKey2018: 'sec:Secp256k1VerificationKey2018',
      JolocomPublicProfile: 'https://identity.jolocom.com/terms/PublicProfile',
    },
  ],
  id:
    'did:jolo:1ff29fd63b896ca94b5efe35bd61eba809b5293a1cdf995dfa9cc7a8a8e1c348',
  authentication: [
    'did:jolo:1ff29fd63b896ca94b5efe35bd61eba809b5293a1cdf995dfa9cc7a8a8e1c348#keys-1',
  ],
  publicKey: [
    {
      controller:
        'did:jolo:1ff29fd63b896ca94b5efe35bd61eba809b5293a1cdf995dfa9cc7a8a8e1c348',
      id:
        'did:jolo:1ff29fd63b896ca94b5efe35bd61eba809b5293a1cdf995dfa9cc7a8a8e1c348#keys-1',
      type: 'Secp256k1VerificationKey2018',
      publicKeyHex:
        '031cb4105e392208c78085cb618a2695ee4e732534bc8f6b2f699f116c9607b84d',
    },
  ],
  service: [],
  created: '2019-08-10T13:56:40.240Z',
  updated: '2019-08-10T13:56:40.934Z',
  proof: {
    created: '2019-08-10T13:56:40.934Z',
    type: 'EcdsaKoblitzSignature2016',
    nonce: '730c39662aa79d17',
    signatureValue:
      'edcffa601bfbe5ece45c513799e34b5a8d957ce7eb94441efc250f7ba7749d10424a0d7f54ba8837b89f804fed52992cf1ac00d874b5215068876a6345359394',
    creator:
      'did:jolo:1ff29fd63b896ca94b5efe35bd61eba809b5293a1cdf995dfa9cc7a8a8e1c348#keys-1',
  },
}

Using the libary to resolve an identity given a DID:

import { JolocomLib } from 'jolocom-lib'

const registry = JolocomLib.registries.jolocom.create()
const did = 'did:jolo:ffcc8f84fae1b6ad253561d7b78167a661d72f58e86e60dbd04cd9b81096cdbe'

registry.resolve(did).then(async identity => {
  console.log(identity.did)
  console.log(identity.publicProfile)
  console.log(identity.didDocument)
})

Using the library to create a new identity:

An example of identity creation can be found here.

In general, the integration tests on the Jolocom Library, can be used as a guide for using the Jolocom Library to go through some typicall flows.

Jolocom verifiable credentials implementation.

Verifiable credential example:

{
  '@context': [
    'https://w3id.org/identity/v1',
    'https://identity.jolocom.com/terms',
    'https://w3id.org/security/v1',
    'https://w3id.org/credentials/v1',
    'http://schema.org'
  ],
  id: 'claimId:25453fa543da7',
  name: 'Email address',
  issuer: 'did:jolo:ffcc8f84fae1b6ad253561d7b78167a661d72f58e86e60dbd04cd9b81096cdbe',
  type: ['Credential', 'ProofOfEmailCredential'],
  claim: {
    id: 'did:jolo:ffcc8f84fae1b6ad253561d7b78167a661d72f58e86e60dbd04cd9b81096cdbe',
    email: 'eugeniu@jolocom.com'
  },
  issued: 2018-08-14T15:09:26.709Z,
  proof: {
    type: 'EcdsaKoblitzSignature2016',
    created: 2018-08-14T15:09:26.710Z,
    creator: 'did:jolo:ffcc8f84fae1b6ad253561d7b78167a661d72f58e86e60dbd04cd9b81096cdbe#keys-1',
    nonce: 'd62dab8e29e11',
    signatureValue: '6UgXjR6668RWLw45PEOsoxytWbX00prza733mbNKO+NpI4QcqPUUbsVEzRQ10E6YF0OZv+d8pzng+djLfweA2w=='
  }
}

Using the library to create a new signed credential:

An example of creating verifiable credentials using the Jolocom Library can be found here. The aforementioned integration tests also contain examples of creating self issued credentials (i.e. here)

Extra resources

Appendix:

Credential request JWT example:

{
  "interactionToken": {
    "credentialRequirements": [
      {
        "type": [
          "Credential",
          "ProofOfDemoIdCredential"
        ], // Same as the "type" key in the Verifiable Credential,
        "constraints": [
          {
            "==": [
              {
                "var": "issuer"
              },
              "did:jolo:b2d5d8d6cc140033419b54a237a5db51710439f9f462d1fc98f698eca7ce9777"
            ] // For constraints we use the JsonLogic package (http://jsonlogic.com/), these can be easily client side using the package. Can be empty.
          }
        ]
      }
    ],
    "callbackURL": "https://botm-university-demo.jolocom.com/authenticate/"
  },
  "typ": "credentialRequest",
  "iat": "1562238821834",
  "exp": "1562242421834",
  "iss": "did:jolo:6b8e4245e9863a976b475b7a7c1dc70e290c9fbf0de9eec751d821944658b564#keys-1", // The DID of the requesting service.
  "jti": "a3396a442ecdc" // Unique identiier for this token
}

Credential Offer Example:

{
  "header": { "typ": "JWT", "alg": "ES256K" },
  "payload": {
    "interactionToken": {
      "callbackURL": "https://906f927d.ngrok.io/receive/",
      "offeredCredentials": [
        {
          "type": "TesterCredential",
          "renderInfo": {
            "logo": {
              "url": "https://miro.medium.com/fit/c/240/240/1*jbb5WdcAvaY1uVdCjX1XVg.png"
            },
            "background": {
              "url": "https://jolocom.io/wp-content/themes/jolocom/images/Solution-hero-mobile.jpg"
            },
            "text": { "color": "#ffffff" },
            "renderAs": "document"
          },
          "metadata": { "asynchronous": false }
        }
      ]
    },
    "typ": "credentialOfferRequest",
    "iat": 1564486939433,
    "exp": 1564490539433,
    "iss": "did:jolo:b2d5d8d6cc140033419b54a237a5db51710439f9f462d1fc98f698eca7ce9777#keys-1",
    "jti": "7147887a03582"
  },
  "signature": "145b8ad4c954155ee8823b727b00559c7592611d0f40ac5e0354588525dcd647775a49e8a81e0b93594c4c9b791c4b2fa0afa8ef4a8d87f2dba81b851213b3e4"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment