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

0 Members and 1 Guest are viewing this topic.

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 »