Skip to content

11. Key Binding

Lukas.J.Han edited this page Dec 18, 2023 · 1 revision

You can issue SD JWT with Key Binding JWT and verify it.

Issue

const { privateKey, publicKey } = createKeyPair();
const claims = {
   irstname: 'John',
  lastname: 'Doe',
  ssn: '123-45-6789',
  id: '1234',
};
const disclosureFrame: DisclosureFrame<typeof claims> = {
  _sd: ['firstname', 'id'],
};

const encodedSdjwt = await sdjwt.issue(claims, privateKey, disclosureFrame, {
  kb: {
    alg: 'EdDSA',
    payload: {
      iat: Math.floor(Date.now() / 1000),
      aud: 'https://example.com',
      nonce: '1234',
      _sd_hash: '1234',
    },
    privateKey,
  },
});

Verify

const verified = await sdjwt.verify(encodedSdjwt, publicKey, ['id', 'ssn'], {
  kb: {
    publicKey,
  },
});
console.log(verified);
Clone this wiki locally