ETH Price: $3,281.30 (+0.05%)
Gas: 7 Gwei

Contract

0xeFcFed8a9E2FFEeb605b96D7120B2Cb6ab092097
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
0x6105a161148433602022-05-25 18:12:30794 days ago1653502350IN
 Create: ECDSA
0 ETH0.0278205976.32871445

Advanced mode:
Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ECDSA

Compiler Version
v0.8.7+commit.e28d00a7

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
/**
 *Submitted for verification at Etherscan.io on 2022-05-25
*/

library ECDSA {

    ///// Signer Address Recovery /////
    
    // In its pure form, address recovery requires the following parameters
    // params: hash, v, r ,s

    // First, we define some standard checks
    function checkValidityOf_s(bytes32 s) public pure returns (bool) {
        if (uint256(s) > 
            0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            revert("recoverAddressFrom_hash_v_r_s: Invalid s value");
        }
        return true;
    }
    function checkValidityOf_v(uint8 v) public pure returns (bool) {
        if (v != 27 && v != 28) {
            revert("recoverAddressFrom_hash_v_r_s: Invalid v value");
        }
        return true;
    }

    // Then, we first define the pure form of recovery.
    function recoverAddressFrom_hash_v_r_s(bytes32 hash, uint8 v, bytes32 r,
    bytes32 s) public pure returns (address) {
        // First, we need to make sure that s and v are in correct ranges
        require(checkValidityOf_s(s) && checkValidityOf_v(v));

        // call recovery using solidity's built-in ecrecover method
        address _signer = ecrecover(hash, v, r, s);
        
        require(_signer != address(0),
            "_signer == address(0)");

        return _signer;
    }

    // There are also other ways to receive input without v, r, s values which
    // you will need to parse the unsupported data to find v, r, s and then
    // use those to call ecrecover.

    // For these, there are 2 other methods:
    // 1. params: hash, r, vs
    // 2. params: hash, signature

    // These then return the v, r, s values required to use recoverAddressFrom_hash_v_r_s

    // So, we will parse the first method to get v, r, s
    function get_v_r_s_from_r_vs(bytes32 r, bytes32 vs) public pure 
    returns (uint8, bytes32, bytes32) {
        bytes32 s = vs & 
            bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        
        uint8 v = uint8((uint256(vs) >> 255) + 27);

        return (v, r, s);
    }

    function get_v_r_s_from_signature(bytes memory signature) public pure 
    returns (uint8, bytes32, bytes32) {
        // signature.length can be 64 and 65. this depends on the method
        // the standard is 65 bytes1, eip-2098 is 64 bytes1.
        // so, we need to account for these differences

        // in the case that it is a standard 65 bytes1 signature
        if (signature.length == 65) {
            uint8 v;
            bytes32 r;
            bytes32 s;

            // assembly magic
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }

            // return the v, r, s 
            return (v, r, s);
        }

        // in the case that it is eip-2098 64 bytes1 signature
        else if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;

            // assembly magic 
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }

            return get_v_r_s_from_r_vs(r, vs);
        }

        else {
            revert("Invalid signature length");
        }
    }

    // ///// Embedded toString /////

    // // We need this in one of the methods of returning a signed message below.

    // function _toString(uint256 value_) internal pure returns (string memory) {
    //     if (value_ == 0) { return "0"; }
    //     uint256 _iterate = value_; uint256 _digits;
    //     while (_iterate != 0) { _digits++; _iterate /= 10; } // get digits in value_
    //     bytes memory _buffer = new bytes(_digits);
    //     while (value_ != 0) { _digits--; _buffer[_digits] = bytes1(uint8(
    //         48 + uint256(value_ % 10 ))); value_ /= 10; } // create bytes of value_
    //     return string(_buffer); // return string converted bytes of value_
    // }

    // ///// Generation of Hashes /////
    
    // // We need these methods because these methods are used to compare
    // // hash generated off-chain to hash generated on-chain to cross-check the
    // // validity of the signatures

    // // 1. A bytes32 hash to generate a bytes32 hash embedded with prefix
    // // 2. A bytes memory s to generate a bytes32 hash embedded with prefix
    // // 3. A bytes32 domain seperator and bytes32 structhash to generate 
    // //      a bytes32 hash embedded with prefix

    // // See: EIP-191
    // function toEthSignedMessageHashBytes32(bytes32 hash) public pure 
    // returns (bytes32) {
    //     return keccak256(abi.encodePacked(
    //         // Magic prefix determined by the devs
    //         "\x19Ethereum Signed Message:\n32",
    //         hash
    //     ));
    // }

    // // See: EIP-191
    // function toEthSignedMessageHashBytes(bytes memory s) public pure
    // returns (bytes32) {
    //     return keccak256(abi.encodePacked(
    //         // Another magic prefix determined by the devs
    //         "\x19Ethereum Signed Message:\n", 
    //         // The bytes length of s
    //         _toString(s.length),
    //         // s itself
    //         s
    //     ));
    // }

    // // See: EIP-712
    // function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) public
    // pure returns (bytes32) {
    //     return keccak256(abi.encodePacked(
    //         // Yet another magic prefix determined by the devs
    //         "\x19\x01",
    //         // The domain seperator (EIP-712)
    //         domainSeparator,
    //         // struct hash
    //         structHash
    //     ));
    // }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"checkValidityOf_s","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint8","name":"v","type":"uint8"}],"name":"checkValidityOf_v","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"vs","type":"bytes32"}],"name":"get_v_r_s_from_r_vs","outputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"get_v_r_s_from_signature","outputs":[{"internalType":"uint8","name":"","type":"uint8"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"recoverAddressFrom_hash_v_r_s","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"}]

6105a161003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100615760003560e01c806321fc4465146100665780635f72e0331461008e5780638435334c146100b95780638ee0498c146100cc578063b1303440146100fe575b600080fd5b6100796100743660046103e6565b610111565b60405190151581526020015b60405180910390f35b6100a161009c366004610421565b6101a7565b6040516001600160a01b039091168152602001610085565b6100796100c736600461050d565b610283565b6100df6100da36600461045c565b610301565b6040805160ff9094168452602084019290925290820152606001610085565b6100df61010c3660046103ff565b6103a6565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a082111561019f5760405162461bcd60e51b815260206004820152602e60248201527f7265636f7665724164647265737346726f6d5f686173685f765f725f733a204960448201526d6e76616c696420732076616c756560901b60648201526084015b60405180910390fd5b506001919050565b60006101b282610111565b80156101c257506101c284610283565b6101cb57600080fd5b6040805160008082526020820180845288905260ff871692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa15801561021f573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661027a5760405162461bcd60e51b81526020600482015260156024820152745f7369676e6572203d3d206164647265737328302960581b6044820152606401610196565b95945050505050565b60008160ff16601b1415801561029d57508160ff16601c14155b1561019f5760405162461bcd60e51b815260206004820152602e60248201527f7265636f7665724164647265737346726f6d5f686173685f765f725f733a204960448201526d6e76616c696420762076616c756560901b6064820152608401610196565b600080600083516041141561032c5750505060208101516040820151606083015160001a919061039f565b835160401415610357576020840151604085015161034a82826103a6565b945094509450505061039f565b60405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e67746800000000000000006044820152606401610196565b9193909250565b600080806001600160ff1b038416816103c460ff87901c601b61052f565b97919550909350505050565b803560ff811681146103e157600080fd5b919050565b6000602082840312156103f857600080fd5b5035919050565b6000806040838503121561041257600080fd5b50508035926020909101359150565b6000806000806080858703121561043757600080fd5b84359350610447602086016103d0565b93969395505050506040820135916060013590565b60006020828403121561046e57600080fd5b813567ffffffffffffffff8082111561048657600080fd5b818401915084601f83011261049a57600080fd5b8135818111156104ac576104ac610555565b604051601f8201601f19908116603f011681019083821181831017156104d4576104d4610555565b816040528281528760208487010111156104ed57600080fd5b826020860160208301376000928101602001929092525095945050505050565b60006020828403121561051f57600080fd5b610528826103d0565b9392505050565b6000821982111561055057634e487b7160e01b600052601160045260246000fd5b500190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212207fc912550929a21afed7aed3907097951026034c151471cb7729fd617f5bb74364736f6c63430008070033

Deployed Bytecode

0x73efcfed8a9e2ffeeb605b96d7120b2cb6ab09209730146080604052600436106100615760003560e01c806321fc4465146100665780635f72e0331461008e5780638435334c146100b95780638ee0498c146100cc578063b1303440146100fe575b600080fd5b6100796100743660046103e6565b610111565b60405190151581526020015b60405180910390f35b6100a161009c366004610421565b6101a7565b6040516001600160a01b039091168152602001610085565b6100796100c736600461050d565b610283565b6100df6100da36600461045c565b610301565b6040805160ff9094168452602084019290925290820152606001610085565b6100df61010c3660046103ff565b6103a6565b60007f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a082111561019f5760405162461bcd60e51b815260206004820152602e60248201527f7265636f7665724164647265737346726f6d5f686173685f765f725f733a204960448201526d6e76616c696420732076616c756560901b60648201526084015b60405180910390fd5b506001919050565b60006101b282610111565b80156101c257506101c284610283565b6101cb57600080fd5b6040805160008082526020820180845288905260ff871692820192909252606081018590526080810184905260019060a0016020604051602081039080840390855afa15801561021f573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661027a5760405162461bcd60e51b81526020600482015260156024820152745f7369676e6572203d3d206164647265737328302960581b6044820152606401610196565b95945050505050565b60008160ff16601b1415801561029d57508160ff16601c14155b1561019f5760405162461bcd60e51b815260206004820152602e60248201527f7265636f7665724164647265737346726f6d5f686173685f765f725f733a204960448201526d6e76616c696420762076616c756560901b6064820152608401610196565b600080600083516041141561032c5750505060208101516040820151606083015160001a919061039f565b835160401415610357576020840151604085015161034a82826103a6565b945094509450505061039f565b60405162461bcd60e51b815260206004820152601860248201527f496e76616c6964207369676e6174757265206c656e67746800000000000000006044820152606401610196565b9193909250565b600080806001600160ff1b038416816103c460ff87901c601b61052f565b97919550909350505050565b803560ff811681146103e157600080fd5b919050565b6000602082840312156103f857600080fd5b5035919050565b6000806040838503121561041257600080fd5b50508035926020909101359150565b6000806000806080858703121561043757600080fd5b84359350610447602086016103d0565b93969395505050506040820135916060013590565b60006020828403121561046e57600080fd5b813567ffffffffffffffff8082111561048657600080fd5b818401915084601f83011261049a57600080fd5b8135818111156104ac576104ac610555565b604051601f8201601f19908116603f011681019083821181831017156104d4576104d4610555565b816040528281528760208487010111156104ed57600080fd5b826020860160208301376000928101602001929092525095945050505050565b60006020828403121561051f57600080fd5b610528826103d0565b9392505050565b6000821982111561055057634e487b7160e01b600052601160045260246000fd5b500190565b634e487b7160e01b600052604160045260246000fdfea26469706673582212207fc912550929a21afed7aed3907097951026034c151471cb7729fd617f5bb74364736f6c63430008070033

Deployed Bytecode Sourcemap

0:5832:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;225:287;;;;;;:::i;:::-;;:::i;:::-;;;2507:14:1;;2500:22;2482:41;;2470:2;2455:18;225:287:0;;;;;;;;793:506;;;;;;:::i;:::-;;:::i;:::-;;;-1:-1:-1;;;;;2290:32:1;;;2272:51;;2260:2;2245:18;793:506:0;2118:211:1;518:210:0;;;;;;:::i;:::-;;:::i;2097:1271::-;;;;;;:::i;:::-;;:::i;:::-;;;;4706:4:1;4694:17;;;4676:36;;4743:2;4728:18;;4721:34;;;;4771:18;;;4764:34;4664:2;4649:18;2097:1271:0;4470:334:1;1768:321:0;;;;;;:::i;:::-;;:::i;225:287::-;284:4;332:66;305:93;;301:182;;;415:56;;-1:-1:-1;;;415:56:0;;3904:2:1;415:56:0;;;3886:21:1;3943:2;3923:18;;;3916:30;3982:34;3962:18;;;3955:62;-1:-1:-1;;;4033:18:1;;;4026:44;4087:19;;415:56:0;;;;;;;;301:182;-1:-1:-1;500:4:0;;225:287;-1:-1:-1;225:287:0:o;793:506::-;903:7;1006:20;1024:1;1006:17;:20::i;:::-;:44;;;;;1030:20;1048:1;1030:17;:20::i;:::-;998:53;;;;;;1151:24;;;1133:15;1151:24;;;;;;;;;2761:25:1;;;2834:4;2822:17;;2802:18;;;2795:45;;;;2856:18;;;2849:34;;;2899:18;;;2892:34;;;1151:24:0;;2733:19:1;;1151:24:0;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;1151:24:0;;-1:-1:-1;;1151:24:0;;;-1:-1:-1;;;;;;;1204:21:0;;1196:68;;;;-1:-1:-1;;;1196:68:0;;3554:2:1;1196:68:0;;;3536:21:1;3593:2;3573:18;;;3566:30;-1:-1:-1;;;3612:18:1;;;3605:51;3673:18;;1196:68:0;3352:345:1;1196:68:0;1284:7;793:506;-1:-1:-1;;;;;793:506:0:o;518:210::-;575:4;596:1;:7;;601:2;596:7;;:18;;;;;607:1;:7;;612:2;607:7;;596:18;592:107;;;631:56;;-1:-1:-1;;;631:56:0;;3139:2:1;631:56:0;;;3121:21:1;3178:2;3158:18;;;3151:30;3217:34;3197:18;;;3190:62;-1:-1:-1;;;3268:18:1;;;3261:44;3322:19;;631:56:0;2937:410:1;2097:1271:0;2182:5;2189:7;2198;2483:9;:16;2503:2;2483:22;2479:882;;;-1:-1:-1;;;2679:4:0;2664:20;;2658:27;2729:4;2714:20;;2708:27;2787:4;2772:20;;2766:27;2522:7;2758:36;;2658:27;2861:16;;2479:882;2974:9;:16;2994:2;2974:22;2970:391;;;3150:4;3135:20;;3129:27;3201:4;3186:20;;3180:27;3245:26;3129:27;3180;3245:19;:26::i;:::-;3238:33;;;;;;;;;;2970:391;3315:34;;-1:-1:-1;;;3315:34:0;;4319:2:1;3315:34:0;;;4301:21:1;4358:2;4338:18;;;4331:30;4397:26;4377:18;;;4370:54;4441:18;;3315:34:0;4117:348:1;2970:391:0;2097:1271;;;;;:::o;1768:321::-;1847:5;;;-1:-1:-1;;;;;1895:94:0;;1847:5;2026:25;2042:3;2027:18;;;2049:2;2026:25;:::i;:::-;2010:42;2079:1;;-1:-1:-1;1768:321:0;;-1:-1:-1;;;;1768:321:0:o;14:156:1:-;80:20;;140:4;129:16;;119:27;;109:55;;160:1;157;150:12;109:55;14:156;;;:::o;175:180::-;234:6;287:2;275:9;266:7;262:23;258:32;255:52;;;303:1;300;293:12;255:52;-1:-1:-1;326:23:1;;175:180;-1:-1:-1;175:180:1:o;360:248::-;428:6;436;489:2;477:9;468:7;464:23;460:32;457:52;;;505:1;502;495:12;457:52;-1:-1:-1;;528:23:1;;;598:2;583:18;;;570:32;;-1:-1:-1;360:248:1:o;613:387::-;697:6;705;713;721;774:3;762:9;753:7;749:23;745:33;742:53;;;791:1;788;781:12;742:53;827:9;814:23;804:33;;856:36;888:2;877:9;873:18;856:36;:::i;:::-;613:387;;846:46;;-1:-1:-1;;;;939:2:1;924:18;;911:32;;990:2;975:18;962:32;;613:387::o;1005:921::-;1073:6;1126:2;1114:9;1105:7;1101:23;1097:32;1094:52;;;1142:1;1139;1132:12;1094:52;1182:9;1169:23;1211:18;1252:2;1244:6;1241:14;1238:34;;;1268:1;1265;1258:12;1238:34;1306:6;1295:9;1291:22;1281:32;;1351:7;1344:4;1340:2;1336:13;1332:27;1322:55;;1373:1;1370;1363:12;1322:55;1409:2;1396:16;1431:2;1427;1424:10;1421:36;;;1437:18;;:::i;:::-;1512:2;1506:9;1480:2;1566:13;;-1:-1:-1;;1562:22:1;;;1586:2;1558:31;1554:40;1542:53;;;1610:18;;;1630:22;;;1607:46;1604:72;;;1656:18;;:::i;:::-;1696:10;1692:2;1685:22;1731:2;1723:6;1716:18;1771:7;1766:2;1761;1757;1753:11;1749:20;1746:33;1743:53;;;1792:1;1789;1782:12;1743:53;1848:2;1843;1839;1835:11;1830:2;1822:6;1818:15;1805:46;1893:1;1871:15;;;1888:2;1867:24;1860:35;;;;-1:-1:-1;1875:6:1;1005:921;-1:-1:-1;;;;;1005:921:1:o;1931:182::-;1988:6;2041:2;2029:9;2020:7;2016:23;2012:32;2009:52;;;2057:1;2054;2047:12;2009:52;2080:27;2097:9;2080:27;:::i;:::-;2070:37;1931:182;-1:-1:-1;;;1931:182:1:o;4809:225::-;4849:3;4880:1;4876:6;4873:1;4870:13;4867:136;;;4925:10;4920:3;4916:20;4913:1;4906:31;4960:4;4957:1;4950:15;4988:4;4985:1;4978:15;4867:136;-1:-1:-1;5019:9:1;;4809:225::o;5039:127::-;5100:10;5095:3;5091:20;5088:1;5081:31;5131:4;5128:1;5121:15;5155:4;5152:1;5145:15

Swarm Source

ipfs://7fc912550929a21afed7aed3907097951026034c151471cb7729fd617f5bb743

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.