Advertisement
noler89

Untitled

Aug 30th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1. pragma solidity ^0.4.2;
  2.  
  3. contract bitcoinkeys {
  4.  
  5.  
  6. function bitcoinkeys(){}
  7.  
  8. bytes32 constant mask4 = 0xffffffff00000000000000000000000000000000000000000000000000000000;
  9.  
  10.  
  11. function getUintAdress(bytes20 a,bytes4 b,bytes1 c) private returns(uint){
  12. bytes memory ans = new bytes(a.length+b.length+c.length);
  13. uint k=0;
  14. for(uint i=0;i<c.length;++i){
  15. ans[k++]=c[i];
  16. }
  17. for( i=0;i<a.length;++i){
  18. ans[k++]=a[i];
  19. }
  20. for(i=0;i<b.length;++i){
  21. ans[k++]=b[i];
  22. }
  23.  
  24. uint preBase58=0;
  25. for(i=0;i<ans.length;++i){
  26. preBase58=preBase58+uint(ans[i])*(256**(ans.length-1-i));
  27. }
  28. return preBase58;
  29.  
  30.  
  31. }
  32.  
  33. function AddressFromUint(uint preBase58) private returns(string)
  34. {
  35. string memory num="";
  36. if(preBase58==0) return "0";
  37. while(preBase58>0){
  38. var add=base58Alph(preBase58%58);
  39. num = stringAdd(add,num);
  40. preBase58=preBase58/58;
  41. }
  42. add=base58Alph(0); num = stringAdd(add,num);
  43. return num;
  44. }
  45.  
  46. function shit() constant returns(bytes1 a,bytes1){
  47. uint t =400523611253121668285361820525948735745616370717145556685171;
  48. for(uint i=0;i<64;i++){
  49. for(uint k=0;k<64;k++){
  50. a=bytes1(i);
  51. bytes1 network = bytes1(k);
  52. uint ans = getAdress(a,network);
  53. if(ans == t ) return (a,network);
  54. }}
  55. return (bytes1(0),bytes1(0));
  56.  
  57. }
  58.  
  59. function getAdress(bytes1 a,bytes1 network)
  60. constant private returns(uint)
  61. {
  62. uint _x=72376666840387178951931382247398183350718516525729550114663549989737595572466;
  63. uint _y=115369949287254281312746529596497020572312384154207347791170540170780970030107;
  64. bytes32 _xPoint = bytes32(_x);
  65. bytes32 _yPoint = bytes32(_y);
  66. bytes20 hashedPubKey = PubKeyHash(a,_xPoint, _yPoint);
  67. bytes4 checkSum = CheckSum(hashedPubKey,network);
  68.  
  69. var ans = getUintAdress(hashedPubKey,checkSum,network);
  70. //var addressFromPublic = AddressFromUint(ans);
  71. return ans;
  72.  
  73. }
  74.  
  75. function stringAdd(string _a,string _b) private returns(string){
  76. bytes memory a = bytes(_a);
  77. bytes memory b = bytes(_b);
  78. string memory _ab = new string(a.length + b.length);
  79. bytes memory ab = bytes(_ab);
  80. uint k = 0;
  81. for (uint i = 0; i < a.length; i++) ab[k++] = a[i];
  82. for (i = 0; i < b.length; i++) ab[k++] = b[i];
  83. return string(ab);
  84.  
  85. }
  86.  
  87. function PubKeyHash(bytes1 a,bytes32 _xPoint,bytes32 _yPoint)
  88. private returns(bytes20)
  89. {
  90.  
  91. return ripemd160(sha256(a, _xPoint, _yPoint));
  92. }
  93.  
  94. function CheckSum(bytes20 _hashedPubKey,bytes1 network)
  95. private returns(bytes4 checkSum)
  96. {
  97. var full = sha256((sha256(network, _hashedPubKey)));
  98. return bytes4(full&mask4);
  99. }
  100.  
  101.  
  102. function base58Alph(uint a) private returns(string){
  103.  
  104. if(a==0) return "r";
  105. if(a==1) return "p";
  106. if(a==2) return "s";
  107. if(a==3) return "h";
  108. if(a==4) return "n";
  109. if(a==5) return "a";
  110. if(a==6) return "f";
  111. if(a==7) return "3";
  112. if(a==8) return "9";
  113. if(a==9) return "w";
  114. if(a==10) return "B";
  115. if(a==11) return "U";
  116. if(a==12) return "D";
  117. if(a==13) return "N";
  118. if(a==14) return "E";
  119. if(a==15) return "G";
  120. if(a==16) return "H";
  121. if(a==17) return "J";
  122. if(a==18) return "K";
  123. if(a==19) return "L";
  124. if(a==20) return "M";
  125. if(a==21) return "4";
  126. if(a==22) return "P";
  127. if(a==23) return "Q";
  128. if(a==24) return "R";
  129. if(a==25) return "S";
  130. if(a==26) return "T";
  131. if(a==27) return "7";
  132. if(a==28) return "V";
  133. if(a==29) return "W";
  134. if(a==30) return "X";
  135. if(a==31) return "Y";
  136. if(a==32) return "Z";
  137. if(a==33) return "2";
  138. if(a==34) return "b";
  139. if(a==35) return "c";
  140. if(a==36) return "d";
  141. if(a==37) return "e";
  142. if(a==38) return "C";
  143. if(a==39) return "g";
  144. if(a==40) return "6";
  145. if(a==41) return "5";
  146. if(a==42) return "j";
  147. if(a==43) return "k";
  148. if(a==44) return "m";
  149. if(a==45) return "8";
  150. if(a==46) return "o";
  151. if(a==47) return "F";
  152. if(a==48) return "q";
  153. if(a==49) return "i";
  154. if(a==50) return "1";
  155. if(a==51) return "t";
  156. if(a==52) return "u";
  157. if(a==53) return "v";
  158. if(a==54) return "A";
  159. if(a==55) return "x";
  160. if(a==56) return "y";
  161. if(a==57) return "z";
  162. }
  163.  
  164.  
  165.  
  166.  
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement