Author [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] [EN] [ZH] [ES] [PT] [IT] [DE] [FR] [NL] [TR] [SR] [AR] [RU] Topic: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address  (Read 736 times)

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc

I offer 200 BTSX to the best solution for the following task.

Given: a bitcoin public key (in hexadecimal char vector)

Input:
 - from command line argument: public key for a bitcoin address in hexformat

Ouput:
 - the BTSX address that can be accessed if you own the private key to the input private key
 - the PTS address that can be accessed by the same private key

Hint .. go over to the BitShares Toolkit sources .. in the programs/utils folder there are tools that
can be expended to achieve this task. I tried figuring it out myself but just failed :(

Ah, yha, please post the documented source code (probably less than 50 lines of code)
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline cgafeng

Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #1 on: August 24, 2014, 11:43:36 PM »
   string client_impl::btctobts(const string& btcaddress)const
   {
      balance_record initial_balance(pts_address(btcaddress),
         asset(share_type(0), 0),
         0 /* Not voting for anyone */
         );
      return string(initial_balance.condition.get_address());
   }

this work on client.cpp.
« Last Edit: August 24, 2014, 11:45:50 PM by cgafeng »
BTC:1EYwcZ9cYVj6C9LMLafdcjK9wicVMDV376

Offline crazybit

  • Sr. Member
  • ****
  • Posts: 402
    • View Profile
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #2 on: August 25, 2014, 06:35:49 AM »
bts::blockchain::address btc _address convert_to_bts_address (std::string& ptsbase58str)
{
return address(pts_address(ptsbase58str ));
}


i write this with my phone, not test yet.
« Last Edit: August 25, 2014, 06:39:39 AM by crazybit »
Delegate IDs: dpos.crazybit | titan.crazybit | anchor.crazybit |crazybit

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #3 on: August 25, 2014, 07:02:49 AM »
nice solutions so far ...
As I am not a coder (and I figured those parts out my self already)
I'd really like to see a full-length compileable file ...
(from within the toolkit)

(best for me would be a git pull request to the official repo that includes that file in the utilities of the toolbox .. )

edit:// and I figured 200 BTSX is to few for that task ..
I will send both of you the 200 BTSX and as soon as I get to it I will raise the bounty price to sth. that is more like 40-50$ ..
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #4 on: August 27, 2014, 06:34:47 PM »
Code: [Select]
2014-08-27T18:33:54 332007    xeroc               cgafeng             200.00000 BTSX          bounty                                      0.50000 BTSX        56a975d8
 2014-08-27T18:34:04 332008    xeroc               crazybit            200.00000 BTSX          bounty                                      0.50000 BTSX        8891114b
Thanks for pointing me there .. I try to figure out the rest my self
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #5 on: August 27, 2014, 07:14:16 PM »
Code: [Select]
#include <bts/blockchain/address.hpp>
#include <bts/blockchain/pts_address.hpp>
#include <bts/utilities/key_conversion.hpp>
#include <fc/crypto/elliptic.hpp>
#include <iostream>

using namespace bts::blockchain;

bts::blockchain::address btc_address_convert_to_bts_address(const std::string& base58str)
{
 return address(pts_address(base58str));
}


int main( int argc, char** argv )
{
 if( argc == 1 )
 {
  std::cout << "useage: convert_btc_address <btcaddress>" <<"\n";
 }
 else
 {
  std::string myarg = argv[1];
  std::cout << "Input:       " << myarg << "\n";
  std::cout << "BTS address: " << std::string(btc_address_convert_to_bts_address(myarg)) << "\n";
 }
}

But it is not working as intended :(

I generated a random new key and added it to an existing account ... result
Code: [Select]
>> wallet_account_list_public_keys xeroc
[{
    "hex": "029ce4fb7d77478a8760d08b79b4664d78453958d2efeb1b8d91d033a175c35b7c",
    "native_pubkey": "BTSX65b1ez7zLiJZ5PwGQ3qdQ6bWr5goeyZnfwqYBtzjAVVZr9dxcP",
    "native_address": "BTSXEkMHfXiWnRb7hHSZ67Gw9iJ8ZbL8FEJKw",
    "pts_normal_address": "PdVJKUTwGdtV1RDrZ8TbXsC2dU874MSqyS",
    "pts_compressed_address": "PmLJC5PbKgL6WS51c823LciPsMbtKdSMSm",
    "btc_normal_address": "16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1",
    "btc_compressed_address": "1EQX3zhTZaP2iAGAEdNCBbULd7B4Vjt5Eq"
  },{

I took the BTC address 16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1 and put it into the executable:

Code: [Select]
./convert_btc_address 16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1                                                                                                                                                     
Input:       16ZXBPmoWXwRD9R1BdokNqwyPDhHBgfhH1
BTS address: BTSXPfmi29tucM9HRpPAEKD1dqJuFQRY5gqcY

BTS addresses don't match ... No what?
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline bytemaster

Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #6 on: August 27, 2014, 08:53:21 PM »
BTSX addresses are not used anywhere in the API...  we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
For the latest updates checkout my blog: http://bytemaster.bitshares.org
Anything said on these forums does not constitute an intent to create a legal obligation or contract between myself and anyone else.   These are merely my opinions and I reserve the right to change them at any time.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #7 on: August 27, 2014, 09:02:19 PM »
BTSX addresses are not used anywhere in the API...  we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
So I cannot register a name on the above results ...

can I convert a hex.formated bitcoin pubkey into a BTSX pubkey so that I can register a name on a bitcoin pubkey/address ?
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline crazybit

  • Sr. Member
  • ****
  • Posts: 402
    • View Profile
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #8 on: August 28, 2014, 09:20:41 AM »
BTSX addresses are not used anywhere in the API...  we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)

BM, how does the toolkit generates the balance id from the existing btc/pts address in genesis block?similar to the following logic? is  the balance id same with balance record owner ?

balance id =ripemd160(sha512(hash of public key))

Delegate IDs: dpos.crazybit | titan.crazybit | anchor.crazybit |crazybit

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #9 on: August 28, 2014, 09:32:01 AM »
BTSX addresses are not used anywhere in the API...  we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)

BM, how does the toolkit generates the balance id from the existing btc/pts address in genesis block?similar to the following logic? is  the balance id same with balance record owner ?

balance id =ripemd160(sha512(hash of public key))
The initial balances it stored in a BTSX ADDRESS .. the rest of the network works on BTSX PUBLIC KEYSs (ie, when you register a name, you register a pubkey .. not an address)

Thus, I cannot use the result of the above script to register a name on his behalf as I need to register a PUBKEY ... so I need to take the bitcoin pubkey of that address and convert that one to a bitsharesx pubkey ... just don't know yet how to do it :(
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #10 on: August 28, 2014, 01:57:25 PM »
BTSX addresses are not used anywhere in the API...  we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
I tried to figure this out .. but failed ... could you points me to some direction so that I can try figure this out myself?
Is it even possible to to register a btsx account using a pubkey generated from a bitcoin address pubkey .. so that the holder of the privkey (bitcoin) can import an account name I registered for him?
« Last Edit: August 28, 2014, 08:18:20 PM by xeroc »
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline cgafeng

Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #11 on: August 28, 2014, 02:28:44 PM »
BTSX addresses are not used anywhere in the API...  we use the public keys for the accounts, but there is no way to convert an address to a public key (address is hash of public key)
I tried to figure this out .. but failed ... could you points me to some direction so that I can try figure this out myself?
Is it even possible to to register a btsx account using a pubkey generated from a bitcoin address .. so that the holder of the privkey (bitcoin) can import an account name I registered for him?

I don't think this can work.
BTC:1EYwcZ9cYVj6C9LMLafdcjK9wicVMDV376

Offline pc

  • Hero Member
  • *****
  • Posts: 1001
    • View Profile
    • Bitcoin - Perspektive oder Risiko?
  • BTS: cyrano
  • Witness: cyrano
  • Payrate: 100%
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #12 on: August 28, 2014, 08:12:45 PM »
but there is no way to convert an address to a public key (address is hash of public key)
Is it even possible to to register a btsx account using a pubkey generated from a bitcoin address .. so that the holder of the privkey (bitcoin) can import an account name I registered for him?
You cannot "generate a pubkey from a bitcoin address" because the address is essentially a cryptographic hash of the pubkey. Cryptographic hashes are one way - it's easy to compute the hash for a key but close to impossible to find the key(s) generating a given hash.
Please vote for my BitShares witness "cyrano" and for my STEEM witness "cyrano.witness"!
Bitcoin - Perspektive oder Risiko? ISBN 978-3-8442-6568-2 http://bitcoin.quisquis.de

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #13 on: August 28, 2014, 08:17:26 PM »
You cannot "generate a pubkey from a bitcoin address" because the address is essentially a cryptographic hash of the pubkey. Cryptographic hashes are one way - it's easy to compute the hash for a key but close to impossible to find the key(s) generating a given hash.
I know that .. fixed the typo above
I want to generate a BTSX PubKey from a BTC PubKey!
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 11959
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BTS: xeroc
  • GitHub: xeroc
Re: [200BTSX] tool to convert bitcoin public key into BTSX/PTS address
« Reply #14 on: August 29, 2014, 06:15:34 PM »
I think i got it .. gonna have to test it first .. publish code next week ... have a nace weekend
Give BitShares a try! Use the http://testnet.bitshares.eu provided by http://bitshares.eu powered by ChainSquad GmbH

 

Google+