jolocom / jolocom-lib

Library for interacting with the identity solution provided by Jolocom.
MIT License
24 stars 18 forks source link

Add support for JWT encoded verifiable presentations. #346

Open Exulansis opened 5 years ago

Exulansis commented 5 years ago

Similar to the approach outlined above, but instead of using a simple JSON-LD document containing a proof section, a JWT is used. An example as given by the spec (example 30):

{
  "iss": "did:example:ebfeb1f712ebc6f1c276e12ec21",
  "jti": "urn:uuid:3978344f-8596-4c3a-a978-8fcaba3903c5",
  "aud": "did:example:4a57546973436f6f6c4a4a57573",
  "iat": 1541493724,
  "exp": 1573029723,
  "nonce": "343s$FSFDa-",
  "vp": {
    "@context": [
      "https://www.w3.org/2018/credentials/v1",
      "https://www.w3.org/2018/credentials/examples/v1"
    ],
    "type": ["VerifiablePresentation", "CredentialManagerPresentation"],
    // base64url-encoded JWT as string
    "verifiableCredential": ["..."]
  }
}

The Verifiable presentation is represented as a linked data document, associated with the vp key of the JWT

Keys one would normally find in the JSON-LD document are replaced (where possible) with JWT keys, e.g. iss (issuer), jti (id), exp (expirationDate). The full list of claim names that MUST be used is listed in the specification.

The header section of the JWT would look as follows:

{
    "alg": "RS256",
    "typ": "JWT",
    "kid": "did:example:abfe13f712120431c276e12ecab#keys-1"
}
PeterTheOne commented 4 years ago

fyi: did-jwt-vc does this here https://github.com/decentralized-identity/did-jwt-vc/blob/f3977c5711917521ace6ce8f247bdd147c21e740/src/index.ts#L92 and https://github.com/decentralized-identity/did-jwt-vc/blob/f3977c5711917521ace6ce8f247bdd147c21e740/src/converters.ts#L382