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

[Fix] Solidity 103, Lession 37, Change the visibility of recoverSigner function and verify function from internal to public #246

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

ramsayleung
Copy link

@ramsayleung ramsayleung commented Oct 13, 2024

问题

在Solidity 103 的第37课数字签名中, 讲解到「步骤4通过签名和消息恢复公钥」和「步骤5 对比公钥并验证签名」, 通过截图展示了在Remix IDE 上 调用 recoverSigner 函数和 verify 函数的过程:

但是 recoverSignerverify 函数都被声明成 internal 函数,internal 函数是无论从合约外被调用的,即使是使用 Remix IDE进行调试

    // @dev 从_msgHash和签名_signature中恢复signer地址
    function recoverSigner(bytes32 _msgHash, bytes memory _signature) internal pure returns (address){
    }

    /**
     * @dev 通过ECDSA,验证签名地址是否正确,如果正确则返回true
     * _msgHash为消息的hash
     * _signature为签名
     * _signer为签名地址
     */
    function verify(bytes32 _msgHash, bytes memory _signature, address _signer) internal pure returns (bool) {
        return recoverSigner(_msgHash, _signature) == _signer;
    }

解决方案

修改 recoverSignerverify 函数的可见性,从 internal 修改成 public, 从而使截图与代码实际行为一致.

另外一个解决方法是在课程中加以强调,说明是为了方便调试所以改成 public, 实际应该是 internal.

Copy link

vercel bot commented Oct 13, 2024

@ramsayleung is attempting to deploy a commit to the WTF Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant