sd-jwt-0.1.0.0: Selective Disclosure for JSON Web Tokens (RFC 9901)
Safe HaskellNone
LanguageHaskell2010

SDJWT.Internal.Presentation

Description

SD-JWT presentation: Creating presentations with selected disclosures.

This module provides functions for creating SD-JWT presentations on the holder side. The holder selects which disclosures to include when presenting to a verifier.

Synopsis

Documentation

createPresentation Source #

Arguments

:: SDJWT 
-> [EncodedDisclosure]

Selected disclosures to include

-> SDJWTPresentation 

Create a presentation with selected disclosures.

This is a simple function that creates an SDJWTPresentation from an SDJWT and a list of selected disclosures. The selected disclosures must be a subset of the disclosures in the original SDJWT.

selectDisclosures Source #

Arguments

:: SDJWT 
-> [EncodedDisclosure]

Disclosures to include

-> Either SDJWTError SDJWTPresentation 

Select disclosures from an SD-JWT (more flexible version).

This function allows selecting disclosures directly by providing the disclosure objects themselves. Useful when you already know which disclosures to include.

selectDisclosuresByNames Source #

Arguments

:: SDJWT 
-> [Text]

Claim names to include in presentation (supports JSON Pointer syntax for nested paths, including array indices)

-> Either SDJWTError SDJWTPresentation 

Select disclosures from an SD-JWT based on claim names.

This function:

  1. Decodes all disclosures from the SD-JWT
  2. Filters disclosures to include only those matching the provided claim names
  3. Handles recursive disclosures (Section 6.3): when selecting nested claims, automatically includes parent disclosures if they are recursively disclosable
  4. Validates disclosure dependencies (ensures all required parent disclosures are present)
  5. Returns a presentation with the selected disclosures

Note: This function validates that the selected disclosures exist in the SD-JWT. Supports JSON Pointer syntax for nested paths:

  • Object properties: ["address/street_address", "address/locality"]
  • Array elements: ["nationalities/0", "nationalities/2"]
  • Mixed paths: ["address/street_address", "nationalities/1"]
  • Nested arrays: ["nested_array/0/0", "nested_array/1/1"]

Paths with numeric segments (e.g., ["x/22"]) are resolved by checking the actual claim type: if x is an array, it refers to index 22; if x is an object, it refers to property "22".

addKeyBinding Source #

Arguments

:: JWKLike jwk 
=> HashAlgorithm

Hash algorithm to use for sd_hash computation

-> jwk

Holder private key (Text or jose JWK object)

-> Text

Audience claim (verifier identifier)

-> Text

Nonce provided by verifier

-> Int64

Issued at timestamp (Unix epoch seconds)

-> SDJWTPresentation

The SD-JWT presentation to add key binding to

-> Object

Optional additional claims (e.g., exp, nbf). Default: empty object

-> IO (Either SDJWTError SDJWTPresentation) 

Add key binding to a presentation.

Creates a Key Binding JWT and adds it to the presentation, converting it to SD-JWT+KB format. The KB-JWT proves that the holder possesses a specific key.

Returns the presentation with key binding added, or an error if KB-JWT creation fails.