-
Notifications
You must be signed in to change notification settings - Fork 55
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
AnonCreds Credentials using the W3C Standard - wrappers #273
AnonCreds Credentials using the W3C Standard - wrappers #273
Conversation
Artemkaaas
commented
Nov 14, 2023
- Updated Python wrapper to expose new methods
- Update NodeJS and React Native wrappers to expose new methods
1fbdc06
to
fc31dae
Compare
19edff7
to
106d702
Compare
e2a21ce
to
075eba5
Compare
fc52916
to
6d64da4
Compare
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: Abdulbois <[email protected]> Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
3004b69
to
19ca275
Compare
Signed-off-by: artem.ivanov <[email protected]>
01d1842
to
e59d2bc
Compare
Signed-off-by: artem.ivanov <[email protected]>
e59d2bc
to
2b903fe
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.
Mostly looked at the JS wrapper ,as I have more experience with it.
I think overall looks good, but I think we can reduce the number of method exposed in the wrapper, as well as have some more consistency in using w3c in names
@@ -102,6 +102,16 @@ export class NodeJSAnoncreds implements Anoncreds { | |||
return handleReturnPointer<string>(ret) | |||
} | |||
|
|||
public w3cCredentialGetAttribute(options: { objectHandle: ObjectHandle; name: string }) { |
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.
Is there a reason why there is a separate method for w3c? Getting an attribute is the same for w3c and non w3c credentials 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 do not understand your point. w3cCredentialGetAttribute
method calls anoncreds_w3c_credential_get_attribute
external Rust function which obtain W3C credential object from handle and returns value for requesting attribute.
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 thinking more of that whether the object is an AnonCreds representation or a W3C representation doesn't really change the input or output of this method, so from an user POV it could be the same method right?
wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts
Outdated
Show resolved
Hide resolved
wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts
Outdated
Show resolved
Hide resolved
wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts
Outdated
Show resolved
Hide resolved
public createW3CPresentation(options: { | ||
presentationRequest: ObjectHandle | ||
credentials: NativeCredentialEntry[] | ||
credentialsProve: NativeCredentialProve[] | ||
linkSecret: string | ||
schemas: Record<string, ObjectHandle> | ||
credentialDefinitions: Record<string, ObjectHandle> | ||
}): ObjectHandle { | ||
const { presentationRequest, linkSecret } = serializeArguments(options) | ||
|
||
const credentialEntries = options.credentials.map((value) => | ||
CredentialEntryStruct({ | ||
credential: value.credential.handle, | ||
timestamp: value.timestamp ?? -1, | ||
rev_state: value.revocationState?.handle ?? 0 | ||
}) | ||
) | ||
|
||
const credentialEntryList = CredentialEntryListStruct({ | ||
count: credentialEntries.length, | ||
data: credentialEntries as unknown as TypedArray< | ||
StructObject<{ | ||
credential: number | ||
timestamp: number | ||
rev_state: number | ||
}> | ||
> |
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 there's a lot of code here for w3c methods that is basically the same except for the end result. Do you think we can reuse some code here? I think this can lead to inconsistencies in functionality
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 added helper methods doing conversion of parameters in order to reduce code duplication.
But left w3c* methods.
I think methods here should be mapped one to one with external C API. Do not see a sense to combine w3c and legacy methods.
wrappers/javascript/packages/anoncreds-nodejs/tests/api.test.ts
Outdated
Show resolved
Hide resolved
wrappers/javascript/packages/anoncreds-nodejs/tests/api.test.ts
Outdated
Show resolved
Hide resolved
wrappers/javascript/packages/anoncreds-react-native/src/ReactNativeAnoncreds.ts
Outdated
Show resolved
Hide resolved
wrappers/javascript/packages/anoncreds-shared/src/api/Credential.ts
Outdated
Show resolved
Hide resolved
wrappers/javascript/packages/anoncreds-shared/src/api/W3CCredential.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: artem.ivanov <[email protected]>
@TimoGlastra I processed and resolved comments connected to using |
Signed-off-by: artem.ivanov <[email protected]>
9f26c7d
to
c276c2a
Compare
# Conflicts: # src/data_types/w3c/credential.rs # src/ffi/w3c/credential.rs
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]> # Conflicts: # src/ffi/w3c/credential.rs
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
Signed-off-by: artem.ivanov <[email protected]>
…anoncreds-wc3-wrappers # Conflicts: # src/services/w3c/prover.rs
…anoncreds-wc3-wrappers # Conflicts: # src/data_types/w3c/proof.rs
@Artemkaaas once #291 is merged, I'll take another look at this PR, but there's currently too much different changes |
cb837a5
to
65c7ca6
Compare
…anoncreds-wc3-wrappers
The plan (per requests from @TimoGlastra and @andrewwhitehead ) is to merge #273 first (once the test failure is fixed), so this is easier to check. Tests are passing here, so hopefully this one will be easy to approve once #273 is merged. FYI @Artemkaaas Thanks |
@TimoGlastra , @andrewwhitehead -- can you please do a review of this PR. The other two have been merged, so this should be easier to review. Thanks. |
} | ||
``` | ||
|
||
### Examples |
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 we not want to keep the examples?
Looks good, with a couple tiny notes. We'll want to add the w3c tests to the CI. |
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.
LGTM! I already played with the api a bit for creating the test vectors and it made sense to me
Only thing is maybe that there's quite some duplication between the w3c and non w3c code in the JS wrapper, but we can look at that in the future maybe. Would ne good to have this merged
And reelased!
wrappers/javascript/packages/anoncreds-nodejs/src/NodeJSAnoncreds.ts
Outdated
Show resolved
Hide resolved
|
||
this.nativeAnoncreds.anoncreds_create_w3c_presentation( | ||
presentationRequest, | ||
credentialEntryList as unknown as Buffer, |
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.
Lots of casts should be avoided if possible
Also one more question/ |
54a1118
to
ab97435
Compare
I only checked build and compile scripts for wrapper, but not tested integration into a react-native application. |
Signed-off-by: artem.ivanov <[email protected]>
ab97435
to
f0c2901
Compare
We can do that once this is merged and released as dev 👍 |