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

[EIP-712] Invalid TypedData encoding with specific int/uint sizes (e.g. int24) #3462

Closed
valdikamenarov opened this issue Oct 26, 2022 · 1 comment
Labels
issue needs-triaging new issues that need triaging

Comments

@valdikamenarov
Copy link

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"

P.S. Issue was raised here as suggested by the go-ethereum community (ethereum/go-ethereum#25932)

@valdikamenarov valdikamenarov added the needs-triaging new issues that need triaging label Oct 26, 2022
@bee-runner bee-runner bot added the issue label Oct 26, 2022
@valdikamenarov
Copy link
Author

Resolved here ethereum/go-ethereum#26770

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue needs-triaging new issues that need triaging
Projects
None yet
Development

No branches or pull requests

1 participant