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

Invalid TypedData encoding with specific int/uint sizes (e.g. int24) #25932

Closed
valdikamenarov opened this issue Oct 5, 2022 · 2 comments
Closed
Labels

Comments

@valdikamenarov
Copy link

valdikamenarov commented Oct 5, 2022

System information

Geth version: 1.10.25
OS & Version: Ubuntu 20.04.5 LTS

Description

Typed Data providing int/uint types that differ from the primitive golang types are not supported while being valid Solidity types.

According to EIP-712 atomic types of type int/uint can be a size ranging between 8 - 256 bits

Expected behaviour

Should be able to successfully encode typed data with valid int/uint types between 8 - 256.

Actual behaviour

Encoding fails due to unknown primitive type.

Steps to reproduce the behaviour

package main

import (
	"github.com/ethereum/go-ethereum/common/math"
	"github.com/ethersphere/bee/pkg/crypto/eip712"
)

func main() {
	typedData := eip712.TypedData{
		Domain: eip712.TypedDataDomain{
			Name:    "ABC",
			Version: "0.0.1",
			ChainId: math.NewHexOrDecimal256(1),
		},
		Types: eip712.Types{
			"EIP712Domain": {
				{Name: "name", Type: "string"},
				{Name: "version", Type: "string"},
				{Name: "chainId", Type: "uint256"},
				{Name: "verifyingContract", Type: "address"},
			},
			"MainType": {
				{Name: "number1", Type: "int160"}, // missing valid Solidity type.
				{Name: "number2", Type: "int24"},  // missing valid Solidity type.
			},
		},
		PrimaryType: "MainType",
		Message: eip712.TypedDataMessage{
			"number1": "13",
			"number2": "13",
		},
	}

	_, err := typedData.HashStruct("EIP712Domain", typedData.Domain.Map())
	if err != nil {
		panic(err)
	}
	_, err = typedData.HashStruct(typedData.PrimaryType, typedData.Message)
	if err != nil {
		panic(err)
	}
}

Error

unknown type "int160"
unknown type "int24"
@holiman
Copy link
Contributor

holiman commented Oct 25, 2022

github.com/ethersphere/bee/pkg/crypto/eip712 -- please file it over there instead :)

@valdikamenarov
Copy link
Author

FYI: Issue has been resolved here #26770

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants