Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verifier calculating encodedSessionTranscript #28

Open
dalebowie opened this issue Nov 3, 2024 · 1 comment
Open

Verifier calculating encodedSessionTranscript #28

dalebowie opened this issue Nov 3, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@dalebowie
Copy link

A Holder performing a presentation uses this library's helper functions of the form usingSessionTranscript_____. Under the covers these construct appropriately formed CBOR-encodings of a DataItem using custom extensions to an external CBOR library. Without access to those custom CBOR extensions, how can a Verifier make the same calculation?

I could see two potential solutions:

  1. the library exports its cborEncode function so that verifiers can use it to calculate what the session transcript bytes should be; or
  2. additional helper functions like the usingSessionTranscript_____ on DeviceResponse are added to the Verifier class so that they can be called instead.
@siacomuzzi
Copy link
Contributor

+1, there is no need for the verifier to know how to construct the session transcript. We are implementing option 2 for v2 (see #16)
In the meantime, you need to install cbor-x as dependency (DataItem is already exported by the lib):

import { DataItem } from '@auth0/mdl';
import { Encoder } from 'cbor-x';

const cborEncode = (
  obj: unknown,
): Buffer => {
  const enc = new Encoder({
    tagUint8Array: false,
    useRecords: false,
    mapsAsObjects: false,
    useTag259ForMaps: false,
  });

  return enc.encode(obj);
};

const getSessionTranscriptBytes = (clId: string, respUri: string, nonce: string, mdocNonce: string) => cborEncode(
  DataItem.fromData([
    null, // DeviceEngagementBytes
    null, // EReaderKeyBytes
    [mdocNonce, clId, respUri, nonce], // Handover = OID4VPHandover
  ]),
);

const verifier = new Verifier(ISSUERS_CERTIFICATES);
await verifier.verify(encodedDeviceResponse, {
  encodedSessionTranscript: getSessionTranscriptBytes(clientId, responseUri, verifierGeneratedNonce, mdocGeneratedNonce),
});

@siacomuzzi siacomuzzi added the enhancement New feature or request label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants