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

When will support the sha256 precompile function? #131

Closed
aewc opened this issue Aug 26, 2022 · 2 comments
Closed

When will support the sha256 precompile function? #131

aewc opened this issue Aug 26, 2022 · 2 comments

Comments

@aewc
Copy link

aewc commented Aug 26, 2022

I deploy the contract both in this evm and remix:

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.4;

contract C {
    function test() public pure returns (uint, uint, bytes32, bytes20, address) {
        bytes32 kec = keccak256("abc");
        // bytes32 sha = sha256("abc"); this evm not supports the sha256
        bytes20 rip = ripemd160("abc");

        uint add = addmod(10, 6, 9);
        uint mul = mulmod(4, 4, 9);

        bytes32 hash = 0x5cc4cee58087de1a2ea481fe9c65c92adc27cff464b7f00a486dc9bf6bb8efb3;
        bytes32 r = 0x32573a0b258f251971a4ec35511c018a7e7bf75a5886534b48d12e47263048a2;
        bytes32 s = 0xfe6e03543955255e235388b224704555fd036a954d3ee6dd030d9d1fea1830d7;
        uint8 v = 0x1c;

        address addr = ecrecover(hash, v, r, s);

        return (add, mul, kec,  rip, addr);
    }
}

bytes32 sha = sha256("abc"); this line can be called in remix, but can't be called in this evm:

trapped explicitly: Revert(Reverted)

after delete this line, everything is ok

@aewc
Copy link
Author

aewc commented Aug 26, 2022

And ripemd160, ecrecover, can call successfully, but return the all zero bytes

@aewc
Copy link
Author

aewc commented Aug 29, 2022

here is a good example to impl precompiles: https://github.com/axonweb3/axon/tree/main/core/executor/src/precompiles
solved.

@aewc aewc closed this as completed Aug 29, 2022
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

No branches or pull requests

1 participant