Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity ^0.4.2;
- contract bitcoinkeys {
- function bitcoinkeys(){}
- bytes32 constant mask4 = 0xffffffff00000000000000000000000000000000000000000000000000000000;
- function getUintAdress(bytes20 a,bytes4 b,bytes1 c) private returns(uint){
- bytes memory ans = new bytes(a.length+b.length+c.length);
- uint k=0;
- for(uint i=0;i<c.length;++i){
- ans[k++]=c[i];
- }
- for( i=0;i<a.length;++i){
- ans[k++]=a[i];
- }
- for(i=0;i<b.length;++i){
- ans[k++]=b[i];
- }
- uint preBase58=0;
- for(i=0;i<ans.length;++i){
- preBase58=preBase58+uint(ans[i])*(256**(ans.length-1-i));
- }
- return preBase58;
- }
- function AddressFromUint(uint preBase58) private returns(string)
- {
- string memory num="";
- if(preBase58==0) return "0";
- while(preBase58>0){
- var add=base58Alph(preBase58%58);
- num = stringAdd(add,num);
- preBase58=preBase58/58;
- }
- add=base58Alph(0); num = stringAdd(add,num);
- return num;
- }
- function shit() constant returns(bytes1 a,bytes1){
- uint t =400523611253121668285361820525948735745616370717145556685171;
- for(uint i=0;i<64;i++){
- for(uint k=0;k<64;k++){
- a=bytes1(i);
- bytes1 network = bytes1(k);
- uint ans = getAdress(a,network);
- if(ans == t ) return (a,network);
- }}
- return (bytes1(0),bytes1(0));
- }
- function getAdress(bytes1 a,bytes1 network)
- constant private returns(uint)
- {
- uint _x=72376666840387178951931382247398183350718516525729550114663549989737595572466;
- uint _y=115369949287254281312746529596497020572312384154207347791170540170780970030107;
- bytes32 _xPoint = bytes32(_x);
- bytes32 _yPoint = bytes32(_y);
- bytes20 hashedPubKey = PubKeyHash(a,_xPoint, _yPoint);
- bytes4 checkSum = CheckSum(hashedPubKey,network);
- var ans = getUintAdress(hashedPubKey,checkSum,network);
- //var addressFromPublic = AddressFromUint(ans);
- return ans;
- }
- function stringAdd(string _a,string _b) private returns(string){
- bytes memory a = bytes(_a);
- bytes memory b = bytes(_b);
- string memory _ab = new string(a.length + b.length);
- bytes memory ab = bytes(_ab);
- uint k = 0;
- for (uint i = 0; i < a.length; i++) ab[k++] = a[i];
- for (i = 0; i < b.length; i++) ab[k++] = b[i];
- return string(ab);
- }
- function PubKeyHash(bytes1 a,bytes32 _xPoint,bytes32 _yPoint)
- private returns(bytes20)
- {
- return ripemd160(sha256(a, _xPoint, _yPoint));
- }
- function CheckSum(bytes20 _hashedPubKey,bytes1 network)
- private returns(bytes4 checkSum)
- {
- var full = sha256((sha256(network, _hashedPubKey)));
- return bytes4(full&mask4);
- }
- function base58Alph(uint a) private returns(string){
- if(a==0) return "r";
- if(a==1) return "p";
- if(a==2) return "s";
- if(a==3) return "h";
- if(a==4) return "n";
- if(a==5) return "a";
- if(a==6) return "f";
- if(a==7) return "3";
- if(a==8) return "9";
- if(a==9) return "w";
- if(a==10) return "B";
- if(a==11) return "U";
- if(a==12) return "D";
- if(a==13) return "N";
- if(a==14) return "E";
- if(a==15) return "G";
- if(a==16) return "H";
- if(a==17) return "J";
- if(a==18) return "K";
- if(a==19) return "L";
- if(a==20) return "M";
- if(a==21) return "4";
- if(a==22) return "P";
- if(a==23) return "Q";
- if(a==24) return "R";
- if(a==25) return "S";
- if(a==26) return "T";
- if(a==27) return "7";
- if(a==28) return "V";
- if(a==29) return "W";
- if(a==30) return "X";
- if(a==31) return "Y";
- if(a==32) return "Z";
- if(a==33) return "2";
- if(a==34) return "b";
- if(a==35) return "c";
- if(a==36) return "d";
- if(a==37) return "e";
- if(a==38) return "C";
- if(a==39) return "g";
- if(a==40) return "6";
- if(a==41) return "5";
- if(a==42) return "j";
- if(a==43) return "k";
- if(a==44) return "m";
- if(a==45) return "8";
- if(a==46) return "o";
- if(a==47) return "F";
- if(a==48) return "q";
- if(a==49) return "i";
- if(a==50) return "1";
- if(a==51) return "t";
- if(a==52) return "u";
- if(a==53) return "v";
- if(a==54) return "A";
- if(a==55) return "x";
- if(a==56) return "y";
- if(a==57) return "z";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement