Bool encoding ("0" & "false") discrepancy on TypedDataUtils.eip712Hash
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- blockchain, cryptography
Research direction
Start at the TypedDataUtils.eip712Hash entry point and reproduce the two examples using data_false as numeric 0 and string "false". Compare the resulting bool encoding with the EIP-712 rule that bool values match uint256 0 or 1; the issue is done when equivalent false inputs produce the same hash.
Written by the indexing model from the issue text.
Description
I was testing bool property encoding using TypedDataUtils.eip712Hash but I noticed different output when I change "false" to 0.
Proof
const hash = TypedDataUtils.eip712Hash(
{
types: {
EIP712Domain: [
{
name: 'name',
type: 'string',
},
{
name: 'version',
type: 'string',
},
{
name: 'chainId',
type: 'uint256',
},
{
name: 'verifyingContract',
type: 'address',
},
],
Message: [
{ name: 'data_true', type: 'bool' },
{ name: 'data_false', type: 'bool' },
],
},
primaryType: 'Message',
domain: {
name: 'com.test.test',
version: '1',
chainId: 1,
verifyingContract: '0xc000000000000000000000000000000000000000',
},
message: {
data_true: 'true',
data_false: 0,
},
},
SignTypedDataVersion.V4,
).toString('hex');
console.log(`result bool -> ${hash}`)
This gives "0737ed294ff3a12f840067c728e500008f23a7b79f4a62c09b5d1bbca85ddb2e"
- Change
data_false: 0todata_false: 'false'then the output is changed to "1a3a9fdfbecde2bb500792a5cdfc2d0deca9401edafa4186d71f5842ecf12d0b"
Seems "false" is wrongly mapped, when I give "false" and "1" it gives the same output
PS: According to Eip-712 spec bool values should be encoded same as uint256 0 or 1. I tested uint256 0 and 1 values and I confirm it gives correct output
- Dominant language
- TypeScript
- Stars
- 584
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MetaMask/eth-sig-util
-
team-wallet-framework
Difficulty 1/5 Under an hour Newbie friendliness 50/100
MetaMask/eth-sig-util#353 ·
-
tsconfig: Disable `strictNullChecks`, enable `strict`Possibly taken @itzKLAUS claimed this 31 days ago. Openteam-wallet-framework
Difficulty 1/5 Under an hour Newbie friendliness 55/100
MetaMask/eth-sig-util#352 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
MetaMask/eth-sig-util#328 ·
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 35/100
MetaMask/eth-sig-util#304 · 4 comments · 4 reactions ·
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 30/100
MetaMask/eth-sig-util#298 · 9 comments ·
All issues in MetaMask/eth-sig-util
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 74/100
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
remotion-dev/remotion#12905 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
supermomonga/paseo-plugin-zcode-provider#83 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
oxidecomputer/skepsis#102 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
voidzero-dev/void#677 ·
Maintainers usually reply within 1 day