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

Canonical TypedData conversion #9

Closed
clehner opened this issue Apr 14, 2021 · 1 comment
Closed

Canonical TypedData conversion #9

clehner opened this issue Apr 14, 2021 · 1 comment

Comments

@clehner
Copy link
Member

clehner commented Apr 14, 2021

Generate canonical TypedData from arbitrary JSON input.

Instead of passing Types in the proof or credential schema, generate them from the input message. Traverse the objects in the message, depth-first, ordered by keys, to visit the objects in a canonical order. For each object, define a new struct type, incrementing a counter to create a new type name. Add members to the type definition for each property of the object. For object values, use the struct type for that object previously defined (or use recursion).

Convert array values to objects with numeric keys, but name their type differently (e.g. "Array" + counter, instead of "Struct' + counter) so that they hash differently. Converting objects to arrays allows for arrays to have values of different types, and avoids having to deal with problematic array hashing (MetaMask/eth-sig-util#106).

This algorithm could be used if messageSchema is absent. It would be desirable so that types do not have to be manually defined and passed in the proof or resolved from a URI.

@awoie
Copy link
Collaborator

awoie commented Oct 14, 2021

Closing this PR since we have merged the schema generation PR #25

@awoie awoie closed this as completed Oct 14, 2021
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

No branches or pull requests

2 participants