#jwt #ssi #identity #ssi-sd-jwt

ssi-sd-jwt

Implementation of SD-JWT for the ssi library

2 unstable releases

0.3.0 Sep 20, 2024
0.2.0 Jul 26, 2024

#2299 in Cryptography

Download history 77/week @ 2024-12-21 38/week @ 2024-12-28 282/week @ 2025-01-04 743/week @ 2025-01-11 717/week @ 2025-01-18 908/week @ 2025-01-25 882/week @ 2025-02-01 890/week @ 2025-02-08 507/week @ 2025-02-15 638/week @ 2025-02-22 719/week @ 2025-03-01 602/week @ 2025-03-08 493/week @ 2025-03-15 406/week @ 2025-03-22 220/week @ 2025-03-29 412/week @ 2025-04-05

1,590 downloads per month
Used in 25 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

~19MB
~342K SLoC