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

AnonCreds Credentials using the W3C Standard - wrappers #273

Merged
merged 28 commits into from
Jan 15, 2024

Conversation

Artemkaaas
Copy link
Contributor

  • Updated Python wrapper to expose new methods
  • Update NodeJS and React Native wrappers to expose new methods

@Artemkaaas Artemkaaas marked this pull request as draft November 14, 2023 14:28
@Artemkaaas Artemkaaas marked this pull request as ready for review November 15, 2023 12:22
@Artemkaaas Artemkaaas force-pushed the anoncreds-wc3-wrappers branch 2 times, most recently from e2a21ce to 075eba5 Compare November 22, 2023 07:53
@Artemkaaas Artemkaaas force-pushed the anoncreds-wc3-wrappers branch 2 times, most recently from fc52916 to 6d64da4 Compare December 2, 2023 08:07
Artemkaaas and others added 7 commits December 8, 2023 08:41
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois123@gmail.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
@Artemkaaas Artemkaaas force-pushed the anoncreds-wc3-wrappers branch 3 times, most recently from 01d1842 to e59d2bc Compare December 8, 2023 08:08
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Copy link
Member

@TimoGlastra TimoGlastra left a 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 }) {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

Comment on lines 757 to 783
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
}>
>
Copy link
Member

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

Copy link
Contributor Author

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.

Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
@Artemkaaas
Copy link
Contributor Author

@TimoGlastra I processed and resolved comments connected to using W3c instead W3C.
I will handle the rest of comments (relating to credential-offer/request duplication and credential methods for non-anoncreds proof) after discuss at the WG call. Unfortunately, I may miss today's call due to some personal errands.

Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
# Conflicts:
#	src/data_types/w3c/credential.rs
#	src/ffi/w3c/credential.rs
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>

# Conflicts:
#	src/ffi/w3c/credential.rs
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
…anoncreds-wc3-wrappers

# Conflicts:
#	src/services/w3c/prover.rs
…anoncreds-wc3-wrappers

# Conflicts:
#	src/data_types/w3c/proof.rs
@TimoGlastra
Copy link
Member

@Artemkaaas once #291 is merged, I'll take another look at this PR, but there's currently too much different changes

@swcurran
Copy link
Member

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

@swcurran
Copy link
Member

@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
Copy link
Member

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?

@andrewwhitehead
Copy link
Member

Looks good, with a couple tiny notes. We'll want to add the w3c tests to the CI.

Copy link
Member

@TimoGlastra TimoGlastra left a 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!


this.nativeAnoncreds.anoncreds_create_w3c_presentation(
presentationRequest,
credentialEntryList as unknown as Buffer,
Copy link
Member

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

@TimoGlastra
Copy link
Member

Also one more question/
: did you test the react native code already? Or should we do some
Testing in react native?

@Artemkaaas
Copy link
Contributor Author

Also one more question/ : did you test the react native code already? Or should we do some Testing in react native?

I only checked build and compile scripts for wrapper, but not tested integration into a react-native application.

Signed-off-by: artem.ivanov <artem.ivanov@dsr-corporation.com>
@TimoGlastra
Copy link
Member

Also one more question/ : did you test the react native code already? Or should we do some Testing in react native?

I only checked build and compile scripts for wrapper, but not tested integration into a react-native application.

We can do that once this is merged and released as dev 👍

@swcurran swcurran merged commit c5b4f1d into hyperledger:main Jan 15, 2024
26 checks passed
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.

6 participants