Author Topic: Tool to convert btc pubkeys into btsx pubkeys  (Read 4531 times)

0 Members and 1 Guest are viewing this topic.

Offline Strip

  • Full Member
  • ***
  • Posts: 63
    • View Profile
here we go .. I just updated the "pytshares" repo on github .. now there are two different scripts:

Code: [Select]
└─(1:%) ./genbtskey.py                                                                                                                                                                                                          ─┘
Secret Exponent         : b3a5255b0567f73da73a27663c0ea5998c67cb6bf860f6dad23af7c1f03290b5
Private Key             : 5KBQNg7LVWcfyZKYzYMVnwsV3d1JS351rD6EhddZvSSzpX2C34X
BTC Address             : 1Bfy6Pv7t1z4hXW89zGHbydnspevDdg9fN
--------------------------------------------------------------------------------
BTC Pubkey (compressed) : 02885d9abff5ca754bdea9c70c9fd95f3d1ea9200b563b2e43081a4d75bc63a1e5
BTC Address             : 1Bfy6Pv7t1z4hXW89zGHbydnspevDdg9fN
--------------------------------------------------------------------------------
BTS PubKey              : BTS5vYdYntohDkUyCCUmzp1QZE2isBwyS6ZARdA6P4gxWgzvFr9qz
BTS Address             : BTSPfYihuV1t7f7HczrY4oJXoX9tULALksLD
--------------------------------------------------------------------------------
┌─(xeroc@hermike:pts/2)────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(~/pytshares)─┐
└─(%) ./convertbtcpubkey.py 02885d9abff5ca754bdea9c70c9fd95f3d1ea9200b563b2e43081a4d75bc63a1e5                                                                                                                                  ─┘
BTC PubKey      : 02885d9abff5ca754bdea9c70c9fd95f3d1ea9200b563b2e43081a4d75bc63a1e5
BTC Address     : 1BSxmaYgptZ2ZZeknMN8wNjmHViyW8SpC4
BTS PubKey      : BTS5vYdYntohDkUyCCUmzp1QZE2isBwyS6ZARdA6P4gxWgzvFr9qz
BTS Address     : BTSPfYihuV1t7f7HczrY4oJXoX9tULALksLD


Thank you a lot! Testing.

Seems working in both scripts(modified bitcoin_utils.py and new convertbtcpubkey.py . Just needed to import compressed public key.
« Last Edit: December 09, 2014, 10:04:37 pm by Strip »
BTS: strip

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
here we go .. I just updated the "pytshares" repo on github .. now there are two different scripts:

Code: [Select]
└─(1:%) ./genbtskey.py                                                                                                                                                                                                          ─┘
Secret Exponent         : b3a5255b0567f73da73a27663c0ea5998c67cb6bf860f6dad23af7c1f03290b5
Private Key             : 5KBQNg7LVWcfyZKYzYMVnwsV3d1JS351rD6EhddZvSSzpX2C34X
BTC Address             : 1Bfy6Pv7t1z4hXW89zGHbydnspevDdg9fN
--------------------------------------------------------------------------------
BTC Pubkey (compressed) : 02885d9abff5ca754bdea9c70c9fd95f3d1ea9200b563b2e43081a4d75bc63a1e5
BTC Address             : 1Bfy6Pv7t1z4hXW89zGHbydnspevDdg9fN
--------------------------------------------------------------------------------
BTS PubKey              : BTS5vYdYntohDkUyCCUmzp1QZE2isBwyS6ZARdA6P4gxWgzvFr9qz
BTS Address             : BTSPfYihuV1t7f7HczrY4oJXoX9tULALksLD
--------------------------------------------------------------------------------
┌─(xeroc@hermike:pts/2)────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────(~/pytshares)─┐
└─(%) ./convertbtcpubkey.py 02885d9abff5ca754bdea9c70c9fd95f3d1ea9200b563b2e43081a4d75bc63a1e5                                                                                                                                  ─┘
BTC PubKey      : 02885d9abff5ca754bdea9c70c9fd95f3d1ea9200b563b2e43081a4d75bc63a1e5
BTC Address     : 1BSxmaYgptZ2ZZeknMN8wNjmHViyW8SpC4
BTS PubKey      : BTS5vYdYntohDkUyCCUmzp1QZE2isBwyS6ZARdA6P4gxWgzvFr9qz
BTS Address     : BTSPfYihuV1t7f7HczrY4oJXoX9tULALksLD


Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
xeroc,

I'm struggling too understand how to use this code for several hour by now. Can you explain a little bit, please.

I have the BTC address and I want to convert in BTS format. What argument to btsxaddr.py should I give?
It won't take BTC address. But it take hash160 but results not identical if I give the private key for the same address.
Oh .. I should write some more lines about that ...
the genbts.py script int "pytshares" is just createing a private key and the bts addresses ..

if you only have the public key and want that one converted to bts address you need to use my modified "pycoin" repo and install that one .. than you can use the bitcoin_utils.py (or "bu") tool that is installed .. that one takes the pubkey and converts it to the pubkey and address ..
I will try to write a separated file to do that .. give me 30 minutes or so .

Offline Strip

  • Full Member
  • ***
  • Posts: 63
    • View Profile
xeroc,

I'm struggling too understand how to use this code for several hour by now. Can you explain a little bit, please.

I have the BTC address and I want to convert in BTS format. What argument to btsxaddr.py should I give?
It won't take BTC address. But it take hash160 but results not identical if I give the private key for the same address.

Brainwallets can be uses in the original client too... check this out:

   help wallet_create
Holy moly! It is so easy!
« Last Edit: December 09, 2014, 08:36:43 pm by Strip »
BTS: strip

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
+5%
Thank you! It's awesome! Now we could do brain wallets!
Brainwallets can be uses in the original client too... check this out:

   help wallet_create

Offline Strip

  • Full Member
  • ***
  • Posts: 63
    • View Profile
 +5%
Thank you! It's awesome! Now we could do brain wallets!
BTS: strip

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Can I create a BTS address through oclvanitygen, then import it and register the key to a Titan name? If so what would the -X flag variable be?
Not without major code modifications ..

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
What is the implication of this?

It sounds similar to sharedropping but rather than coins / shares it is addresses.

Does this imply you could send BTS to a bitcoin account, or a bitcoin account could send BTC to to a BTS wallet?

It does, but think in terms of bitBTC instead of BTS :)
you cannot do crosschain transactions .. but you can reuse the.private key ..

If you want to send 2bitUSD to someone only having a btc pubkey (address) you can convert the pubkey to a bts pubkey or address and send BTS there .. the other guy can redeem the bts by importing the btc privkey into bts

Offline NewMine

  • Hero Member
  • *****
  • Posts: 552
    • View Profile
Can I create a BTS address through oclvanitygen, then import it and register the key to a Titan name? If so what would the -X flag variable be?

Offline monsterer

What is the implication of this?

It sounds similar to sharedropping but rather than coins / shares it is addresses.

Does this imply you could send BTS to a bitcoin account, or a bitcoin account could send BTC to to a BTS wallet?

It does, but think in terms of bitBTC instead of BTS :)
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline Thom

What is the implication of this?

It sounds similar to sharedropping but rather than coins / shares it is addresses.

Does this imply you could send BTS to a bitcoin account, or a bitcoin account could send BTC to to a BTS wallet?
Injustice anywhere is a threat to justice everywhere - MLK |  Verbaltech2 Witness Reports: https://bitsharestalk.org/index.php/topic,23902.0.html

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Multiple keys per account .. yes

Offline monsterer

Never worked wih addresses... but you can take a random key .. import into the wallet and  heck with wallet_account_list_public_keys .. it shows the pubkey and adresses

Using wallet_import_private_key?

edit: does this overwrite the private key of the account?.... I guess it can't actually. So there are multiple private keys for each account?
« Last Edit: December 05, 2014, 02:12:25 pm by monsterer »
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
Never worked wih addresses... but you can take a random key .. import into the wallet and  heck with wallet_account_list_public_keys .. it shows the pubkey and adresses

Offline monsterer

Can I get a confirmation on this pseudo code for going from bitcoin pub key to BTS address?

Code: [Select]
addr = ripemd160(sha512(bitcoinPubKeyBinary))
check = ripemd160(addr)
finalBinary = addr + first_four_bytes(check)
finalBase58 = 'BTS' + base58(finalBinary)
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
You just have to add those lines in the patch above that start with a + sign .. at the acording place .. or anywhere pretty below in the main procedure ..

Plus you need to define the prefix somewhere ... if you cant manage drop me a line and i can post a patches file .. i am mobile atm

Offline monsterer

I don't suppose you have the patched file to save me trying to figure out how to apply it? :)
My opinions do not represent those of metaexchange unless explicitly stated.
https://metaexchange.info | Bitcoin<->Altcoin exchange | Instant | Safe | Low spreads

Offline spartako

  • Sr. Member
  • ****
  • Posts: 401
    • View Profile
wallet_account_set_approval spartako

Offline cass

  • Hero Member
  • *****
  • Posts: 4311
  • /(┬.┬)\
    • View Profile
█║▌║║█  - - -  The quieter you become, the more you are able to hear  - - -  █║▌║║█

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
I modified the "bu.py" script from pycoin to produce BTSX pubkeys given a public key from bitcoin:

pycoin: https://github.com/richardkiss/pycoin.git
particular bu.py sourcecode: https://github.com/richardkiss/pycoin/blob/master/pycoin/scripts/bitcoin_utils.py

The patch looks like this:
Code: [Select]
*** pycoin/pycoin/scripts/bitcoin_utils.py      2014-09-14 16:32:55.171411937 +0200
--- btsxaddrutil/btsxaddr.py    2014-09-14 18:46:21.691527277 +0200
*************** from pycoin.ecdsa import secp256k1
*** 10,11 ****
--- 10,13 ----
 
+ BTS_ADDRESS_PREFIX = "BTS"
+
  def parse_as_number(s):
*************** def main():
*** 103,104 ****
--- 105,109 ----
              hash160_unc = encoding.public_pair_to_hash160_sec(public_pair, compressed=False)
+             myeccpoint = encoding.public_pair_to_sec(public_pair, compressed=True)
+             myhash     = encoding.ripemd160( myeccpoint ).digest(  )
+             print("BTSX PubKey:     %s" % BTS_ADDRESS_PREFIX + encoding.b2a_base58(myeccpoint + myhash[ :4 ]))
          else:
(patch comes as is ... no warranty ... AT ALL!! check results your self)

nothing too complicated .. but it took me some hours to figure it out :)

Output looks like this
Code: [Select]
─(%) ./btsxaddr.py 04c089455cd1554f05e723a1de8331fc0b947119966db60f4409036fdaf6663e1f5f61a8c0656704e98775382c240d8eb1ee0df827342fd7054b1284d41c1bea2c                                                                          ─┘
public pair x:   87086603698720170063321393822553237916438159845584726570308491679063372873247
public pair y:   43142269461068752177588100742336804615736633778602002937675098874341555431980
  x as hex:      c089455cd1554f05e723a1de8331fc0b947119966db60f4409036fdaf6663e1f
  y as hex:      5f61a8c0656704e98775382c240d8eb1ee0df827342fd7054b1284d41c1bea2c
even
key pair as sec: 02c089455cd1554f05e723a1de8331fc0b947119966db60f4409036fdaf6663e1f
  uncompressed:  04c089455cd1554f05e723a1de8331fc0b947119966db60f4409036fdaf6663e1f\
                   5f61a8c0656704e98775382c240d8eb1ee0df827342fd7054b1284d41c1bea2c
BTSX PubKey:     BTS6MHS4JNrh6wVVe1uZAugJbuQpJpr9ENYyaQ74fjv8DZUadY4fq
hash160:         fa6dc9a5cdd1a2d9b5bd1845a1201711ae4eb7ae
  uncompressed:  ef1567d36cd10b8fe6d0849123c22f1356cc90bb
Bitcoin address: 1Pq9T97Ces8HHBYaSr5jphxsW5EAmEUNNu
  uncompressed:  1NoA98grVfXfVqysU4ijM9jhMBD8vmrUC8
« Last Edit: November 26, 2014, 09:47:07 am by xeroc »