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

Implement EthereumEip712Signature2021 #213

Merged
merged 2 commits into from
Jun 25, 2021
Merged

Implement EthereumEip712Signature2021 #213

merged 2 commits into from
Jun 25, 2021

Conversation

clehner
Copy link
Contributor

@clehner clehner commented Jun 16, 2021

Implement Ethereum EIP712 Signature 2021.

The Ethereum EIP712 Signature Suite specification is a work item proposal in W3C CCG: w3c-ccg/community#194

This signature suite is like ssi's Eip712Method2021 and EthereumPersonalSignature2021, but uses EIP-712 structured data as a data model rather than RDF.

A proof option is added, "eip712Domain", for the corresponding proof property from the specification. This is not ideal because it's a breaking change and not standard in vc-http-api, but I don't know how else to pass this information currently. The eip712Domain object contains the EIP712 type definitions (messageSchema) as a dereferencable URI or object, domain object, and primaryType string. These three values are meta-data which are combined with the document and proof to create the signing input. After signing, the eip712Domain object is placed into the proof object along with the signature (proofValue).

Remote loading of type definitions is not implemented currently but some may be bundled in ssi. Using the object form of messageSchema may therefore be preferred. However, if a document using EthereumEip712Signature2021 with such form is embedded in another one, e.g. a verifiable presentation, the complexity of the types is increased, since a type definition is needed for the type definitions in the embedded message.

A JSON-LD context file is added. Even though this signature suite does not use JSON-LD and the term definitions in the context do not affect signing input, the context file is intended to assist embedding verifiable credentials using this format in verifiable presentations using linked-data-based signature suites. This context file is not from the specification, however.

This signature suite maps currently does not allow arrays of values of different types, so putting objects alongside URIs in @context will not work.

I was not able to verify the signature from the specification's test vector example 5 (non-normative); more information may be needed to verify it.

  • Add initial scaffolding for signature suite.
  • Draft JSON-LD context.
  • Implement JSON conversion for LinkedDataDocument.
  • Support remote and/or bundled loading of type definitions.
  • Construct TypedData from LinkedDataDocument, proof, and type definitions.
  • [ ] Verify test vector from specification.
  • Add test vector for verifiable credential.
  • Disallow properties not in types

Screenshot

Signing request in MetaMask

Copy link
Member

@sbihel sbihel left a comment

Choose a reason for hiding this comment

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

Looks good and it works well as we've seen with the demo.

src/vc.rs Show resolved Hide resolved
@wyc
Copy link
Contributor

wyc commented Jun 24, 2021

Please rebase and fix conflicts. Thanks!

clehner added a commit that referenced this pull request Jun 25, 2021
Error if data has properties without corresponding type definitions,
rather than ignoring them.
@clehner
Copy link
Contributor Author

clehner commented Jun 25, 2021

Rebased and squashed.

This PR now changes the signedTypeData key_op to cause this signature suite to be used instead of Eip712Signature2021.

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.

3 participants