-
Notifications
You must be signed in to change notification settings - Fork 24
[INJIVER-1523] Fixed LSH comments - updated ReadMe, added design doc, fixed Code Rabbit comments from PR 230 for CWT #232
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ede6118
[INJIVER] Update Readme file and add cwt-vc-verification-support doc
jaswanthkumartw 57ed429
[INJIVER] Update Readme file and add cwt-vc-verification-support doc
jaswanthkumartw 4f2e7c6
[INJIVER] change text to past tense in Steps Involved section
jaswanthkumartw 6e4886e
[INJIVER] removed the unused library se.digg.cose and add new library…
jaswanthkumartw 31bba8c
[INJIVER] added the missing verify details in the sequenceDiagram
jaswanthkumartw 7f06313
[INJIVER] added the new exception unsupportDidUrl
jaswanthkumartw 5d2862c
[INJIVER] remove the new exception unsupportDidUrl
jaswanthkumartw 729dc50
[INJIVER] add the lib.cbor back
jaswanthkumartw 9844c59
[INJIVER] use initCause() to attach the original exception
jaswanthkumartw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| # Support for IETF CWT Verifiable Credential (CWT-VC) | ||
|
|
||
| This document provides a comprehensive overview of validating and verifying **CWT-based Verifiable Credentials (cwt-vc)** encoded using **CBOR Web Token (CWT)** and **COSE_Sign1**, as defined by IETF standards. | ||
|
|
||
| --- | ||
|
|
||
| ## Public key resolution support | ||
|
|
||
| - **HTTP / HTTPS Issuer** | ||
| - Retrieves issuer public key from `/.well-known/jwks.json` when `iss` is an HTTP(S) URL. | ||
|
|
||
| --- | ||
|
|
||
| ## Steps Involved | ||
|
|
||
| 1. Added the enum value `CWT_VC("cwt-vc")` to `CredentialFormat`. | ||
| 2. Created a new class `CwtVerifiableCredential` that implemented the `VerifiableCredential` interface. | ||
| - The `validate` method validated the credential structure and claims. | ||
| - The `verify` method verified the cryptographic signature. | ||
| 3. Created a `CwtValidator` class to validate the credential structure and claims. | ||
| 4. Created a `CwtVerifier` class to verify the credential signature. | ||
| 5. Implemented validation checks for COSE, headers, claims, and numeric date fields. | ||
| 6. Implemented signature verification using the issuer’s public key. | ||
| 7. Registered `CwtVerifiableCredential` in `CredentialVerifierFactory`. | ||
|
|
||
| --- | ||
|
|
||
| ## Sequence diagram – validate and verify `cwt-vc` credential | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| Wallet->>CredentialsVerifier: verify credential | ||
| CredentialsVerifier->>CredentialVerifierFactory: Create verifier | ||
| CredentialVerifierFactory->>CwtVerifiableCredential: Create instance | ||
| CredentialsVerifier->>CwtVerifiableCredential: Validate | ||
| CwtVerifiableCredential->>CwtValidator: Validate | ||
| CredentialsVerifier->>CwtVerifiableCredential: Verify | ||
| CwtVerifiableCredential->>CwtVerifier: Verify | ||
| CwtVerifier-->>CwtVerifiableCredential: Result | ||
| CwtVerifiableCredential-->>CredentialsVerifier: Result | ||
| ``` | ||
|
|
||
| ### Sequence diagram - validation process | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
|
|
||
| CwtVerifiableCredential->>CwtValidator: Validate CWT Credential | ||
| CwtValidator->>CwtValidator: Validate input is non-empty hex string | ||
| CwtValidator->>CwtValidator: Decode hex to CBOR | ||
| CwtValidator->>CwtValidator: Validate COSE_Sign1 structure | ||
| Note over CwtValidator: COSE_Sign1 must be a CBOR array of size 4 | ||
|
|
||
| CwtValidator->>CwtValidator: Decode protected header | ||
| CwtValidator->>CwtValidator: Validate protected header | ||
| Note over CwtValidator: alg must be present and must be an integer | ||
|
|
||
| CwtValidator->>CwtValidator: Decode CWT claims | ||
| CwtValidator->>CwtValidator: Validate CWT claims structure | ||
| Note over CwtValidator: CWT payload must be a CBOR map | ||
|
|
||
| CwtValidator->>CwtValidator: Validate numeric date claims | ||
| Note over CwtValidator: exp, nbf, iat are optional numeric dates | ||
|
|
||
| alt exp present and expired | ||
| CwtValidator-->>CwtVerifiableCredential: Return Validation Result as False (VC expired) | ||
| else nbf present and in future | ||
| CwtValidator-->>CwtVerifiableCredential: Return Validation Result as False (Not Before violation) | ||
| else iat present and in future | ||
| CwtValidator-->>CwtVerifiableCredential: Return Validation Result as False (Invalid iat) | ||
| else Validation Success | ||
| CwtValidator-->>CwtVerifiableCredential: Return Validation Result as True | ||
| end | ||
| ``` | ||
|
|
||
| ### Sequence diagram - verification process | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
|
|
||
| CwtVerifiableCredential->>CwtVerifier: Verify CWT Credential | ||
| CwtVerifier->>CwtVerifier: Decode hex to CBOR | ||
| CwtVerifier->>CwtVerifier: Validate CBOR Tag 61 (CWT) | ||
| alt Missing or invalid tag | ||
| CwtVerifier-->>CwtVerifiableCredential: Return Verification Result as False | ||
| else Valid CWT | ||
| CwtVerifier->>CwtVerifier: Extract COSE_Sign1 object | ||
| CwtVerifier->>CwtVerifier: Validate COSE_Sign1 structure | ||
| CwtVerifier->>CwtVerifier: Extract CWT claims | ||
jaswanthkumartw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| CwtVerifier->>CwtVerifier: Extract issuer (iss) | ||
| CwtVerifier->>CwtVerifier: Extract kid from protected or unprotected header | ||
| CwtVerifier->>PublicKeyResolverFactory: Resolve public key using issuer and kid | ||
| CwtVerifier->>CwtVerifier: Verify COSE_Sign1 signature | ||
| alt Signature Invalid | ||
| CwtVerifier-->>CwtVerifiableCredential: Return Verification Result as False | ||
| else Signature Valid | ||
| CwtVerifier-->>CwtVerifiableCredential: Return Verification Result as True | ||
| end | ||
| end | ||
|
|
||
|
|
||
| ``` | ||
| --- | ||
|
|
||
| ## Key Validation Rules Summary | ||
|
|
||
| ### COSE Structure | ||
| - Must be a CBOR array of exactly 4 elements. | ||
|
|
||
| ### Protected Header | ||
| - `alg` MUST be present and an integer. | ||
|
|
||
| ### CWT Claims | ||
| - Payload MUST be a CBOR map. | ||
| - `iss`, `exp`, `nbf`, `iat` validated as per spec. | ||
|
|
||
| ### Cryptographic Verification | ||
| - CBOR tag `61` required. | ||
| - Signature verified using COSE_Sign1. | ||
|
|
||
| --- | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.