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 Presentation Definition and use test vectors #192

Merged
merged 10 commits into from
May 10, 2024
Merged

Add Presentation Definition and use test vectors #192

merged 10 commits into from
May 10, 2024

Conversation

diehuxx
Copy link
Contributor

@diehuxx diehuxx commented May 9, 2024

Copy algorithm for selectCredentials laid out here decentralized-identity/web5-go#143.
Use web5-spec submodule to get test vectors. As we use test vectors more, we'll want to establish a common pattern and DRY up the code.

}

impl InputDescriptor {
pub fn select_credentials(&self, vc_jwts: &Vec<String>) -> Result<Vec<String>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

lol pex is so hard, can you give some documentation on the overall algorithm here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For sure. I'll also clean up the code a bit. I'm not good at making things readable in rust yet

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. If it's still hard to read, let me know and I'll take another pass :)

pub path: &'a String,
}

impl InputDescriptor {
Copy link
Contributor

Choose a reason for hiding this comment

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

in the other libs we have

PresentationExchange.select_credentials
PresentationExchange.createPresentationFromCredentials

...

Was the plan to keep it similar or are there other api design changes in the pipeline?

https://github.com/TBD54566975/web5-js/tree/main/packages/credentials#presentationexchange

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The priority for now (keep me honest @frankhinek @mistermoe) is only select_credentials since that is needed for TBDex but createPresentationFromCredentials is not. Instead of using Presentation Submissions in TBDex RFQ messages, we submit a list of claims in the Rfq.data.required_claims field.

Copy link
Contributor

@nitro-neal nitro-neal left a comment

Choose a reason for hiding this comment

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

If it works it works! My understanding of the rust language is still rusty 😃
but this works by

  1. doing some preprocessing creating a token mapping for each field
  2. you do processing on each element in the jwt payload and see if it matches?
  3. then do the jsonpath and if it matches then it is successful

something like that right?

@mistermoe
Copy link

@nitro-neal

the algorithm compiles an input_descriptor's constraints.fields into:

  • a list of tokenized fields (1 path, 1 token)
  • an aggregate JSON schema includes the filter of each field element that has a filter. The token is used as the name of the property in the json schema

once an ID is compiled into ^, the tokenized fields are iterated through to build a selectionCandidate object that is a map of token: <value found at path>. This selection candidate is then eval'd against the aggregate json schema

@diehuxx diehuxx merged commit dcc0283 into main May 10, 2024
6 checks passed
@diehuxx diehuxx deleted the pex branch May 10, 2024 03:22
@KendallWeihe
Copy link
Contributor

this is really amazing work 💯

created #195 and #196 as follow-ups

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.

4 participants