Skip to content
This repository has been archived by the owner on Jun 2, 2019. It is now read-only.

eth_signTypedData_v3 produces invalid signature #45

Open
leroldary opened this issue Jun 1, 2019 · 1 comment
Open

eth_signTypedData_v3 produces invalid signature #45

leroldary opened this issue Jun 1, 2019 · 1 comment

Comments

@leroldary
Copy link

Using EIP-712 (eth_signTypedData_v3) with the provided example data an invalid signature is produced. Ios version of trust wallet had the same problem (trustwallet/trust-wallet-ios#967, now fixed).
Example: https://dicether.github.io/js-eth-personal-sign-examples/ ("Sign Typed Data V3")

Example Data:

  const typedData = {
  types:{
    EIP712Domain:[
      {name:"name",type:"string"},
      {name:"version",type:"string"},
      {name:"chainId",type:"uint256"},
      {name:"verifyingContract",type:"address"}
    ],
    Person:[
      {name:"age",type:"uint64"},
      {name:"name",type:"string"},
      {name:"wallet",type:"address"}
    ],
    Mail:[
      {name:"from",type:"Person"},
      {name:"to",type:"Person"},
      {name:"contents",type:"string"},
      {name: "id", type: "uint256"},
    ]
  },
  primaryType:"Mail",
  domain:{name:"Ether Mail",version:"1",chainId:1,verifyingContract:"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},
  message:{
    from:{age: 46,name:"Cow",wallet:"0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},
    to:{age: 445711732, name:"Bob",wallet:"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"},
    contents:"Hello, Bob!",
    id: "18446744073709551617"}
  };

The expected hash is: 0xd7452bcc4deef52ad1a3f658f4100fa870fcb849b2f8c7738c23bd8e736e6c7b

@hewigovens
Copy link

hewigovens commented Jun 2, 2019

@leroldary The root cause is that we use float type to handle JSON number value, we will fix it in later releasees , current workaround is use uint256 type or smaller value, in this case 445711732 causes precision loose

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

No branches or pull requests

2 participants