-
Notifications
You must be signed in to change notification settings - Fork 208
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
feat(sd-jwt-vc): Module for Issuer, Holder and verifier #1607
feat(sd-jwt-vc): Module for Issuer, Holder and verifier #1607
Conversation
17e235e
to
d0d7f67
Compare
} | ||
} | ||
|
||
public getTags() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tags at all will make it especially hard to query the credentials for input in a VP...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah I was wondering what the best tag structure would be for this. Right now I added the disclosure keys as an array, but I am not sure whether that is supported within askar.
Will likely also include the claimKeys, combined with the selectively disclosable keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add arrays. It will currently be added as an <attr>:<value>: 1/0
I think. So disclosureKeys:age: 1
. Maybe askar also supports something for this natively, which we maybe should look into
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tags will be left as-is for now. Once we do the integration with openid they can be added as at that point we will know exactly how to query.
d0d7f67
to
7a818ef
Compare
Codecov Report
@@ Coverage Diff @@
## main #1607 +/- ##
========================================
Coverage 85.66% 85.67%
========================================
Files 950 959 +9
Lines 22879 23082 +203
Branches 4022 4049 +27
========================================
+ Hits 19600 19775 +175
- Misses 3095 3123 +28
Partials 184 184
|
packages/sd-jwt/src/SdJwtOptions.ts
Outdated
|
||
export type SdJwtReceiveOptions = { | ||
issuerDid: Key | ||
holderKey?: Key |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These will both already be in the JWT right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to issuerKey
and holderkey
which are used to confirm the signature and check whether the cnf
claim is correct. If this info is invalid the sd-jwt cannot be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now using issuerDidUrl
and holderDidUrl
.
Somehow I can't reply to your comment...
Yeah I was thinking about this for a bit and a did with key reference would be good. I did not do it like that for now as you would need to resolve your own did. I will add it where you have to pass a did with key reference. It will make the method slower though. |
a466b15
to
7385737
Compare
I think that is fine for now. We have this in a few other places, where we resolve our own did. But I thin we should solve this generically by allowing the did to be retrieved from local storage / cache. |
056df0a
to
413b6af
Compare
0bab1ab
to
75569fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work @berendsliedrecht. Mostly some small improvements
@karimStekelenburg @TimoGlastra Quickly before merging, should the module be called |
90fd94d
to
6767112
Compare
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
97af36b
to
e7eb71b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good overall. I left a few comments here and there, but they're mostly suggestions. I only see happy flow tests though. Doesn't have to bne noew, but I think we should add sad flow tests when we combine it with OID4VC.
}) | ||
}) | ||
|
||
describe('SdJwtService.present', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test where the holder tries to disclose a non-disclosable value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah good point regarding the non-happy flow tests. I would like to add them in a separate PR to keep this one "small".
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
e7eb71b
to
7eed255
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the simplicity of the API, seems to be very fun to use!
Just left a comment regarding an old discussion that we never completely materialized in code (maybe for a further breaking change PR now we are introducing a new major version).
packages/sd-jwt/src/SdJwtApi.ts
Outdated
return await this.sdJwtService.getAllCredentialRecords(this.agentContext) | ||
} | ||
|
||
public async findCredentialRecordsByQuery(query: Query<SdJwtRecord>): Promise<Array<SdJwtRecord>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the convention used in other module APIs (and services in general) we'd call it findAllCredentialRecordsByQuery
, to make more explicit about the fact that we expect multiple records to be retrieved. Actually, in most modules we make naming simpler (e.g. findAllByQuery
), but I see it's not the case here and W3cCredentialsApi
(the API this module is based on I guess).
Of course if we change this here and leave W3cCredentialsApi
as is, it would not be consistent. And if we change it in W3cCredentialsApi
as well we'll introduce a breaking change. But I just wanted to point out this to bother you 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good point! I think we can change this in a separate PR which changes both the w3c and this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am actually not sure what the best name would be here. I think findAllByQuery
is the best as it is already scoped under sdJwt
within the agent.modules
api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of them to findById
, findAllByQuery
. They will be removed in the future and I think they were too verbose before.
config: { label, walletConfig: { id: utils.uuid(), key: utils.uuid() } }, | ||
modules: { | ||
sdJwt: new SdJwtModule(), | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the problem here that required a ts-ignore? It's about not using askar-nodejs as direct dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected ariesAskar type did not match the one from the module as I think it used 0.2.0-dev.1 and I used 0.1.0. I think I can remove it again
packages/sd-jwt/tests/setup.ts
Outdated
@@ -0,0 +1,3 @@ | |||
import 'reflect-metadata' | |||
|
|||
jest.setTimeout(120000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you expect SD-JWT to take that long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copied from another test. It is quite quick, but askar and agent initialization makes some steps a bit slow. Better overestimate here I guess ;).
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
8d5ed0f
to
63a4987
Compare
Signed-off-by: Berend Sliedrecht <blu3beri@proton.me>
63a4987
to
c95fe6a
Compare
…oundation#1607) Signed-off-by: Berend Sliedrecht <blu3beri@proton.me> Signed-off-by: Martin Auer <martin.auer97@gmail.com>
…oundation#1607) Signed-off-by: Berend Sliedrecht <blu3beri@proton.me> Signed-off-by: Martin Auer <martin.auer97@gmail.com>
…oundation#1607) Signed-off-by: Berend Sliedrecht <blu3beri@proton.me> Signed-off-by: Ariel Gentile <gentilester@gmail.com>
Module for interacting with SD-JWTs as an issuer, holder and verifier.
The module is called
SdJwtModule
, however since we only deal withSdJwtVc
I think it should be renamed toSdJwtVcModule
.As an issuer you get the
SdJwtModule.create
function which allows you to create an sd-jwt-vc where the framework sets all the required properties (likeiat
). It returns a record and a compact form of the sd-jwt-vc. Since key binding is required in sd-jwt-vc, aholderDidUrl
is required for creation, which will be turned into aJWK
and embedded in the payload as acnf
claim.The holder gets the
SdJwtModule.receive
andSdJwtModule.present
. The receive function simply validates that the signature is correct and the correct holder key is used. The present method allows a user to remove certain items from the sd-jwt-vc. The present method returns a compact format of the sd-jwt-vc which can be send to the verifier.The verifier gets the
SdJwtModule.verify
method. This checks the keybinding, issuer signature and whether all the required fields are included.Note: The module also exposes some repository functionality as we do not have a generic repository module, yet.