pragma solidity ^0.4.25; contract EcRecover { function getOriginAddress(bytes memory signedMessage, uint8 v, bytes32 r, bytes32 s) public pure returns(address addr) { bytes memory prefix = "\x19Ethereum Signed Message:\n"; string memory length = uint2str(signedMessage.length); bytes memory encodedPack = abi.encodePacked(prefix, length, signedMessage); bytes32 prefixedHash = keccak256(encodedPack); addr = ecrecover(prefixedHash, v, r, s); return addr; } function uint2str(uint i) internal pure returns (string) { if (i == 0) return "0"; uint j = i; uint length; while (j != 0){ length++; j /= 10; } bytes memory bstr = new bytes(length); uint k = length - 1; while (i != 0){ bstr[k--] = byte(48 + i % 10); i /= 10; } return string(bstr); } }
0.4.25