2 unstable releases

0.3.0 Sep 20, 2024
0.2.0 Jul 26, 2024

#1154 in Parser implementations

Download history 271/week @ 2024-07-26 35/week @ 2024-08-02 164/week @ 2024-08-09 179/week @ 2024-08-16 172/week @ 2024-08-23 293/week @ 2024-08-30 490/week @ 2024-09-06 321/week @ 2024-09-13 750/week @ 2024-09-20 275/week @ 2024-09-27 310/week @ 2024-10-04 222/week @ 2024-10-11 132/week @ 2024-10-18 160/week @ 2024-10-25 201/week @ 2024-11-01 30/week @ 2024-11-08

535 downloads per month
Used in 15 crates (2 directly)

Apache-2.0

405KB
9K SLoC

Selective Disclosure for JWTs (SD-JWT).

Usage

Contrarily to regular JWTs or JWSs that can be verified directly after being decoded, SD-JWTs claims need to be revealed before being validated. The standard path looks like this:

┌───────┐                     ┌──────────────┐                            ┌───────────────┐
│       │                     │              │                            │               │
│ SdJwt │ ─► SdJwt::decode ─► │ DecodedSdJwt │ ─► DecodedSdJwt::reveal ─► │ RevealedSdJwt │
│       │                     │              │                            │               │
└───────┘                     └──────────────┘                            └───────────────┘

The base SD-JWT type is SdJwt (or SdJwtBuf if you want to own the SD-JWT). The SdJwt::decode function decodes the SD-JWT header, payload and disclosures into a DecodedSdJwt. At this point the payload claims are still concealed and cannot be validated. The DecodedSdJwt::reveal function uses the disclosures to reveal the disclosed claims and discard the non-disclosed claims. The result is a RevealedSdJwt containing the revealed JWT, and a set of JSON pointers (JsonPointerBuf) mapping each revealed claim to its disclosure. The RevealedSdJwt::verify function can then be used to verify the JWT as usual.

Alternatively, if you don't care about the byproducts of decoding and revealing the claims, a SdJwt::decode_reveal_verify function is provided to decode, reveal and verify the claims directly.

Dependencies

~20–31MB
~492K SLoC