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

SD-JWT implementation improvements #612

Merged
merged 14 commits into from
Sep 17, 2024
Merged

Conversation

timothee-haudebourg
Copy link
Contributor

@timothee-haudebourg timothee-haudebourg commented Sep 16, 2024

This PR brings the SD-JWT implementation up to date with the rest of ssi.

Main changes

  • Dedicated sized and unsized types for SD-JWTs: Jwt, JwtBuf, DecodedJwt, etc.
  • Explicit interface to reveal concealed claims, creating a RevealedSdJwt.
  • Improves on the previous interface that provided no means of actually creating disclosures. We can now create disclosures using JSON pointers to the claims we want to conceal.

Other changes

  • Renamed CompactJWS, CompactJWSBuf, CompactJWSStr and CompactJWSString into JwsSlice, JwsVec, JwsStr and JwsString. Tried to make the distinction and limitation of each clearer.
  • Added a new Jws/JwsBuf type, that is now the base type for JWS, strictly following RFC 7515 without the RFC 7797 (Unencoded Payload Option) complications.
  • Used the same naming conventions in ssi-jwt.

As a result, all ssi-jws, ssi-jwt and ssi-sd-jwt share the same API patterns.

There are a lot of changed files, but that's actually due to the renaming of JWS types. The most important changes are all located in ssi-sd-jwt. It's a bit lacking documentation for now, but ready for review. In the meantime, the tests are a good starting point to understand how it works.

@timothee-haudebourg
Copy link
Contributor Author

I don't know why cargo-rdme is unable to resolve some doc links 🤔

sd_alg: SdAlg,
pointers: &[impl Borrow<JsonPointer>],
) -> Result<(Self, Vec<DecodedDisclosure<'static>>), ConcealError> {
let mut disclosures = Vec::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using Vec::with_capacity, e.g.:

let mut disclosures = Vec::with_capacity(pointers.len());

Copy link
Member

@sbihel sbihel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why cargo-rdme is unable to resolve some doc links 🤔

If you remove the leading crate:: it seems to work?

@timothee-haudebourg
Copy link
Contributor Author

If you remove the leading crate:: it seems to work?

It does! Maybe it's a new version of cargo-rdme. I remember adding crate:: specifically for cargo-rdme to generate the correct link.

@timothee-haudebourg timothee-haudebourg merged commit b830db0 into main Sep 17, 2024
4 checks passed
@timothee-haudebourg timothee-haudebourg deleted the sd-jwt-refactor branch September 17, 2024 11:15
@timothee-haudebourg
Copy link
Contributor Author

aaand I found a bug just after merging of course: #614

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants