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

Signature Mismatch Issue with bytes #251

Closed
bolom opened this issue Nov 4, 2023 · 9 comments · Fixed by #252
Closed

Signature Mismatch Issue with bytes #251

bolom opened this issue Nov 4, 2023 · 9 comments · Fixed by #252
Labels
bug Something isn't working

Comments

@bolom
Copy link

bolom commented Nov 4, 2023

I am facing an issue with signing typed data in both Ruby and JavaScript. The signatures generated from the two languages do not match. Below, I have provided my Ruby and JavaScript code along with the respective signatures for your reference:

Ruby Code:

data = {
  types: {
    EIP712Domain: [
      { name: 'name', type: 'string' },
      { name: 'version', type: 'string' },
      { name: 'chainId', type: 'uint256' },
      { name: 'verifyingContract', type: 'address' },
    ],
    Data: [
       { name: 'data', type: 'bytes' },
     ],
  },
  primaryType: 'Data',
  domain: {
    name: 'Complex Data',
    version: '1',
    chainId: 421613, 
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
  },
  message: {
    data: "0xa2d6eae3",
  }
}
# Sign the typed data
signature = key.sign_typed_data(data)
# ...

JavaScript Code:

const domain = {
    name: 'Complex Data',
    version: '1',
    chainId: 421613,  // Make sure the chainId matches your Ethereum network
    verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
};

const types = {
  Data: [
        { name: 'data', type: 'bytes' },
    ]
};

const value = {
  data: "0xa2d6eae3",
};

async function signTypedData() {
    const wallet = new ethers.Wallet(PRIVATE_KEY);
    const signature = await wallet.signTypedData(domain, types, value);
    console.log('Signature:', signature);
}

signTypedData();
// ...

when data is type bytes, the signature doesn't match but when its a string it's working

@bolom bolom changed the title Signature Mismatch Issue between Ruby and JavaScript Signature Mismatch Issue with bytes Nov 4, 2023
@bolom
Copy link
Author

bolom commented Nov 5, 2023

@q9f Could you tell me what I did wrong?

@q9f q9f added the bug Something isn't working label Nov 6, 2023
@q9f
Copy link
Owner

q9f commented Nov 6, 2023

Thanks for reporting. This is a confirmed bug.

@bolom
Copy link
Author

bolom commented Nov 6, 2023

@q9f How I can help to fix the bug?

@q9f
Copy link
Owner

q9f commented Nov 6, 2023

Yes, I have patched it in #252

@bolom
Copy link
Author

bolom commented Nov 6, 2023

@q9f btw I would love to be a contributor, do you have any issue with the label "good to first issue" in the pipeline?

@q9f q9f closed this as completed in #252 Nov 6, 2023
q9f added a commit that referenced this issue Nov 6, 2023
* eth/eip721: fix data type bug for bytes, fix #251

* spec/eip721: clean up
@q9f
Copy link
Owner

q9f commented Nov 6, 2023

Contributions are very welcome! I don't have any good first issues, though. I'm still looking for someone to take on #102 or #103 - these are the biggest pain points but also need some work.

@bolom
Copy link
Author

bolom commented Nov 6, 2023

between both with one is more important. I would love to try

@q9f
Copy link
Owner

q9f commented Nov 6, 2023

#102 is more important.

@bolom
Copy link
Author

bolom commented Nov 6, 2023

I'll give it a go and read through it. If I have any questions, I'll ask in the thread

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants