Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

bug: signMessage generates incorrect signature for Hex message #606

Closed
1 task done
moldy530 opened this issue May 30, 2023 · 0 comments
Closed
1 task done

bug: signMessage generates incorrect signature for Hex message #606

moldy530 opened this issue May 30, 2023 · 0 comments

Comments

@moldy530
Copy link
Contributor

moldy530 commented May 30, 2023

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.3.39

Current Behavior

Currently, stringToBytes (used by hashMessage when signing a message) takes the string and UTF-8 encodes the string and converts it to a byte array. This is a problem when trying to interface with a SimpleAccount because the generated signature is not correct. The expected signature is an ERC-191 signed hash of the UserOp.

This was was only an issue after 0.3.17

Expected Behavior

I'd expect stringToBytes to check if the string is already a Hex and then just call hexToBytes instead of UTF-8 encoding the hex string.

Steps To Reproduce

// This is one of the test private keys in this repo
const ownerAccount = privateKeyToAccount(
    "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
);

expect(
  await ownerAccount.signMessage({
    message: "0xa70d0af2ebb03a44dcd0714a8724f622e3ab876d0aa312f0ee04823285d6fb1b"
  })
).toBe("0x1a7fd732f926be0a1dbfd1b4acbd7a6f7198fda1ab5ef69ef027a2eee89987785d210298e12119a1d62b5a7d2d9f24d075682675ae00f51a5602e725f0d180851b")

Link to Minimal Reproducible Example (StackBlitz, CodeSandbox, GitHub repo etc.)

No response

Anything else?

No response

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
1 participant