0

In the Ghost contract they have:

    function mint(uint8 quantity, bytes calldata signature)
        public
        payable
        callerIsUser
    {
        require(DA_ACTIVE == true, "DA isnt active");
        if (!directMintAllowed) {
            require(
                daSigner ==
                    keccak256(
                        abi.encodePacked(
                            "\x19Ethereum Signed Message:\n32",
                            bytes32(uint256(uint160(msg.sender)))
                        )
                    ).recover(signature),
                "Signer address mismatch."
            );
        }
        ...
    }

I feel like I'm missing something. Isn't this equivalent:

    function mint(uint8 quantity)
        public
        payable
        callerIsUser
    {
        require(DA_ACTIVE == true, "DA isnt active");
        if (!directMintAllowed) {
            require(daSigner == msg.sender, "Signer address mismatch.");
        }
        ...
    }

What is the value in adding a signed message check here?

1 Answer 1

1

They are not at all equivalent :

require(
         daSigner ==
             keccak256(
                 abi.encodePacked(
                     "\x19Ethereum Signed Message:\n32",
                     bytes32(uint256(uint160(msg.sender)))
                 )
             ).recover(signature),
         "Signer address mismatch."
);

Ensures that signature refers to a signed message from daSigner with a content set to the address of msg.sender.

Anyone holding a signed message from daSigner containing their address can pass this check. daSigner can give rights to any address of its choice to mint by signing the appropriate message. The user then takes that signature to the smart contracts and is allowed to mint. In that case, daSigner authorized a user to mint, but the user is paying the fees as he would be interacting with the contract.

In the second case :

require(daSigner == msg.sender, "Signer address mismatch.");

Ensures that msg.sender is daSigner Only daSigner can pass this check. In that case, daSigner would mint for a user and pay the fees.

1
  • Ah I see! This means that daSigner could sign a message for any other address (i.e. the other person who would be invoking mint would be msg.sender ) and with that the contract verifies that daSigner has approved them to mint.
    – Sooth
    Commented May 19, 2022 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.