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

Add JWT VC support for RSA keys; enable ZKP tests #24

Merged
merged 4 commits into from
Aug 28, 2020
Merged

Add JWT VC support for RSA keys; enable ZKP tests #24

merged 4 commits into from
Aug 28, 2020

Conversation

clehner
Copy link
Contributor

@clehner clehner commented Aug 26, 2020

#3

This adds the ability to encode a VC as a JWT (without or without signing) and decode a JWT as a VC (with or without signature verification). It also adds the ability to encode and sign a VP as a JWT. This uses the jsonwebtoken library, which uses the crypto library ring.

This implementation is focused on passing the jwt tests in vc-test-suite. The interface could probably be improved for library users that are not vc-test-suite.

For JWS algorithms, currently only RSA (RS256) is supported. Next should probably be HS256 and ES256 (Required, and Recommended+, respectively, by RFC 7518); and/or ES256K/secp256k1 ("P-256K"), which is the other one besides RS256 that is supported by vc-test-suite.

The implementation includes encoding JWK parameters into DER/ASN.1 format, since jsonwebtoken/ring doesn't yet support creating a RSA private key from components (briansmith/ring#699), only from DER or PEM.

Other code changes are also included in the single squashed commit: most notably, the various OneOrMany enums are consolidated into a single type, with helper functions; and we now have an Error type to contain the various errors from our modules and wrapping errors from the external libraries.

For tests, I added an RSA private key that I generated locally with openssl.

Re: #3

- Pass jwt tests in vc-test-suite
- Added RSA key for testing
- Convert RSA key to DER for use with jsonwebtoken/ring
- Consolidate OneOrMany enums
- Add Error type
@clehner clehner requested a review from wyc August 26, 2020 21:48
@wyc
Copy link
Contributor

wyc commented Aug 27, 2020

Thank you for your work! The tests pass, and we are even closer to finishing the test suite--good job.

We are getting from 0 to 1, so testing isn't the focus right now, but I wanted to make an issue to make sure this gets addressed prior to release: #25

Still walking through the code and will likely approve today or ask for minor changes.

@clehner
Copy link
Contributor Author

clehner commented Aug 27, 2020

@wyc I hope you don't mind I pushed another commit to this branch, as it is relatively minor and depends on these changes. It is to enable passing the remaining vc-test-suite tests - the zkp section.

@clehner clehner changed the title Add JWT VC support for RSA keys Add JWT VC support for RSA keys; enable ZKP tests Aug 27, 2020
Copy link
Contributor

@wyc wyc left a comment

Choose a reason for hiding this comment

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

great work. minor comments but happy to merge as-is. feel free to do either or both.

src/jwk.rs Show resolved Hide resolved
src/vc.rs Show resolved Hide resolved
src/vc.rs Show resolved Hide resolved
src/vc.rs Show resolved Hide resolved
src/der.rs Outdated Show resolved Hide resolved
@clehner
Copy link
Contributor Author

clehner commented Aug 27, 2020

Thanks @wyc

@wyc
Copy link
Contributor

wyc commented Aug 28, 2020

Thanks for adding the DER tags. LGTM

@clehner clehner merged commit 948b7a7 into master Aug 28, 2020
@clehner clehner deleted the jwt branch August 28, 2020 15:53
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.

2 participants