Skip to content

Encode name and version in EIP712Domain packet hash #4

@NIC619

Description

@NIC619

In the generated GET_EIP712DOMAIN_PACKETHASH function, name and version of EIP712Domain struct are of dynamic type (string), should they be encoded as the hash of their contents ?

function GET_EIP712DOMAIN_PACKETHASH (EIP712Domain memory _input) public pure returns (bytes32) {
    
    bytes memory encoded = abi.encode(
      EIP712DOMAIN_TYPEHASH,
      _input.name,
      _input.version,
      _input.chainId,
      _input.verifyingContract
    );
    
    return keccak256(encoded);
}

Expected:

function GET_EIP712DOMAIN_PACKETHASH (EIP712Domain memory _input) public pure returns (bytes32) {
    
    bytes memory encoded = abi.encode(
      EIP712DOMAIN_TYPEHASH,
      keccak256(bytes(_input.name)),
      keccak256(byes(_input.version)),
      _input.chainId,
      _input.verifyingContract
    );
    
    return keccak256(encoded);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions