-
Notifications
You must be signed in to change notification settings - Fork 21.9k
signer/core: fix complex typed data signing (EIP-712) #24102
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -369,6 +369,7 @@ func (typedData *TypedData) HashStruct(primaryType string, data TypedDataMessage | |
|
|
||
| // Dependencies returns an array of custom types ordered by their hierarchical reference tree | ||
| func (typedData *TypedData) Dependencies(primaryType string, found []string) []string { | ||
| primaryType = strings.TrimSuffix(primaryType, "[]") | ||
| includes := func(arr []string, str string) bool { | ||
| for _, obj := range arr { | ||
| if obj == str { | ||
|
|
@@ -471,7 +472,7 @@ func (typedData *TypedData) EncodeData(primaryType string, data map[string]inter | |
| if err != nil { | ||
| return nil, err | ||
| } | ||
| arrayBuffer.Write(encodedData) | ||
| arrayBuffer.Write(crypto.Keccak256(encodedData)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why
|
||
| } else { | ||
| bytesValue, err := typedData.EncodePrimitiveValue(parsedType, item, depth) | ||
| if err != nil { | ||
|
|
||
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.
Isn't this a bit naive?
If we use this approach, then it only solves
Foobar[], but notFoobar[8]orFoobar[][].I'm not saying it's optimal as it is right now, but I'm kind of wondering how far to go with this.
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.
Foobar[8]is a data, which specific to a item in typeFoobar[], hereprimaryTypemeans a type not a dataIn my mind, the EIP-712 does not support 2d (or more) arrays?