Skip to content

Latest commit

 

History

History
62 lines (50 loc) · 1.74 KB

example-flat-sd-jwt-01.md

File metadata and controls

62 lines (50 loc) · 1.74 KB

Example 1: Flat SD-JWT

Check specification Example 1: Flat SD-JWT

The example bellow demonstrates the usage of the library mixed with the Kotlinx Serialization DSL to produce a SD-JWT. The Issuer in this case made the following decisions:

  • The sub element and essential verification data (iss, iat, etc.) are always visible.
  • For address, the Issuer is using a flat structure, i.e., all of the claims in the address claim can only be disclosed in full.
val flatSdJwt =
    sdJwt {
        iss("https://issuer.example.com")
        iat(1683000000)
        exp(1883000000)
        sub("6c5c0a49-b589-431d-bae7-219122a9ec2c")

        sd {
            putJsonObject("address") {
                put("street_address", "Schulstr. 12")
                put("locality", "Schulpforta")
                put("region", "Sachsen-Anhalt")
                put("country", "DE")
            }
        }
    }

Produces

{
  "iss": "https://issuer.example.com",
  "iat": 1683000000,
  "exp": 1883000000,
  "sub": "6c5c0a49-b589-431d-bae7-219122a9ec2c",
  "_sd": [
    "jm7N0xvEn35gBZW2RYUJw8siDCFrkv81-w-nb81j7Is"
  ],
  "_sd_alg": "sha-256"
}

and the following disclosures (salt omitted):

[
  ["...salt...","address",{"street_address":"Schulstr. 12","locality":"Schulpforta","region":"Sachsen-Anhalt","country":"DE"}]
]

You can get the full code here.