{"action":"created","issue":{"url":"https://api.github.com/repos/BANKEX/web3swift/issues/63","repository_url":"https://api.github.com/repos/BANKEX/web3swift","labels_url":"https://api.github.com/repos/BANKEX/web3swift/issues/63/labels{/name}","comments_url":"https://api.github.com/repos/BANKEX/web3swift/issues/63/comments","events_url":"https://api.github.com/repos/BANKEX/web3swift/issues/63/events","html_url":"https://github.com/BANKEX/web3swift/issues/63","id":315398473,"number":63,"title":"I use contract verify signature, but the address is not correct?","user":{"login":"wufeiafei","id":3910941,"avatar_url":"https://avatars2.githubusercontent.com/u/3910941?v=4","gravatar_id":"","url":"https://api.github.com/users/wufeiafei","html_url":"https://github.com/wufeiafei","followers_url":"https://api.github.com/users/wufeiafei/followers","following_url":"https://api.github.com/users/wufeiafei/following{/other_user}","gists_url":"https://api.github.com/users/wufeiafei/gists{/gist_id}","starred_url":"https://api.github.com/users/wufeiafei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wufeiafei/subscriptions","organizations_url":"https://api.github.com/users/wufeiafei/orgs","repos_url":"https://api.github.com/users/wufeiafei/repos","events_url":"https://api.github.com/users/wufeiafei/events{/privacy}","received_events_url":"https://api.github.com/users/wufeiafei/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-04-18T09:22:24Z","updated_at":"2018-04-18T10:28:14Z","closed_at":null,"author_association":"NONE","body":"hi,\r\nI use web3swift method \"Web3Signer.signPersonalMessage\" make a signature, then I use the contract method \"validate\", but the result is not correct, the address is different with  the signature address.\r\nthis  is my contract:\r\n\r\npragma solidity ^0.4.17;\r\n\r\ncontract BBQ {\r\n    \r\n  //验签数据入口函数\r\n    function validate(uint8 v,bytes32 r,bytes32 s,uint number) view returns (address,bool){\r\n\r\n        string memory message = uint2str(number);\r\n        string memory lengths = uint2str(bytes(message).length);\r\n        string memory prefix = strConcat(\"\\u0019Ethereum Signed Message:\\n\",lengths);\r\n        bytes32 data = sha3(bytes(prefix),bytes(uint2str(number)));\r\n        bytes32 prefixedHash = sha3(data);\r\n        address endecodedAddress = ecrecover(prefixedHash, v, r, s);\r\n\r\n        return (endecodedAddress,msg.sender == endecodedAddress);\r\n    }\r\n    \r\n    function uint2str(uint i) internal pure returns (string){\r\n        if (i == 0) return \"0\";\r\n        uint j = i;\r\n        uint length;\r\n        \r\n        while (j != 0){\r\n            length++;\r\n            j /= 10;\r\n        }\r\n        \r\n        bytes memory bstr = new bytes(length);\r\n        uint k = length - 1;\r\n        \r\n        while (i != 0){\r\n            bstr[k--] = byte(48 + i % 10);\r\n            i /= 10;\r\n        }\r\n        return string(bstr);\r\n    }\r\n    \r\n    // 连接两个string\r\n    function strConcat(string _a, string _b) internal returns (string){\r\n        bytes memory _ba = bytes(_a);\r\n        bytes memory _bb = bytes(_b);\r\n\r\n        string memory abcde = new string(_ba.length + _bb.length);\r\n        bytes memory babcde = bytes(abcde);\r\n        uint k = 0;\r\n        for (uint i = 0; i < _ba.length; i++) babcde[k++] = _ba[i];\r\n        for (i = 0; i < _bb.length; i++) babcde[k++] = _bb[i];\r\n\r\n        return string(babcde);\r\n    }\r\n    \r\n}\r\n\r\n\r\n\r\nand this is my swift code:\r\n\r\n![1524043221014](https://user-images.githubusercontent.com/3910941/38923341-e15fcf22-432c-11e8-835b-ac635a0b874a.jpg)\r\n![1524043249556](https://user-images.githubusercontent.com/3910941/38923353-e6850cc4-432c-11e8-96ed-e6355752ea97.jpg)\r\n\r\n\r\n======\r\npls, help me check it?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/BANKEX/web3swift/issues/comments/382341238","html_url":"https://github.com/BANKEX/web3swift/issues/63#issuecomment-382341238","issue_url":"https://api.github.com/repos/BANKEX/web3swift/issues/63","id":382341238,"user":{"login":"shamatar","id":6467575,"avatar_url":"https://avatars2.githubusercontent.com/u/6467575?v=4","gravatar_id":"","url":"https://api.github.com/users/shamatar","html_url":"https://github.com/shamatar","followers_url":"https://api.github.com/users/shamatar/followers","following_url":"https://api.github.com/users/shamatar/following{/other_user}","gists_url":"https://api.github.com/users/shamatar/gists{/gist_id}","starred_url":"https://api.github.com/users/shamatar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shamatar/subscriptions","organizations_url":"https://api.github.com/users/shamatar/orgs","repos_url":"https://api.github.com/users/shamatar/repos","events_url":"https://api.github.com/users/shamatar/events{/privacy}","received_events_url":"https://api.github.com/users/shamatar/received_events","type":"User","site_admin":false},"created_at":"2018-04-18T10:28:14Z","updated_at":"2018-04-18T10:28:14Z","author_association":"MEMBER","body":"I’ve pushed a test into “developer” branch, it gives an idea of how to get a signature, get V, R, S from it and test it locally. I’ve also separately tested it with ethereumjs-util and got the same result"}}
{"actor":{"display_login":"shamatar"}}