Welcome to the Dash Forum!

Please sign up to discuss the most innovative cryptocurrency!

Public key form private key

Discussion in 'Daemon and QT Wallet Support' started by Marian, Mar 22, 2017.

  1. Marian

    Marian New Member

    Joined:
    Mar 21, 2017
    Messages:
    12
    Likes Received:
    1
    Trophy Points:
    3
    Hello

    How can I get a public key from a private one? I need to do it in Java, but rpc procedure is ok as well.
     
    • Like Like x 1
  2. flare

    flare Administrator
    Dash Core Team Moderator

    Joined:
    May 18, 2014
    Messages:
    2,287
    Likes Received:
    2,406
    Trophy Points:
    1,183
  3. Bertrand256

    Bertrand256 Active Member

    Joined:
    Feb 13, 2017
    Messages:
    228
    Likes Received:
    272
    Trophy Points:
    123
    Dash Address:
    XwZzf7yqYoUBnDFqE7r3zuNmpwKo1CYLMC
    Hi, As far as I know, algorithm to convert priv to pub in Dash is exactly the same as for Bitcoin and is based on Elliptic Curve multiplication. It is well described in Andreas Antonopolous book: https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc#public-keys

    In turn, the conversion public key to it's Dash address is a bit different, but only in that, that it uses a different version prefix (76 instead of 00).

    I think, that for priv->pub conversion you can simply use some existing Java bitcoin library .
     
    • Agree Agree x 1
    • Useful Useful x 1
  4. Marian

    Marian New Member

    Joined:
    Mar 21, 2017
    Messages:
    12
    Likes Received:
    1
    Trophy Points:
    3

    Thank you, conversion from public key to Dash address was easy to made by changing bitcoinJ library.

    I still have a small problem with checking if private key if from Dash world. There is a parameter called "dumpedPrivateKeyHeader" in Bitcoin witch needs to be set to 128 in order to confirm that it is private bitcoin key. When I try to guess that parameter for Dash, number 204 seems to work, can someone confirm that?
     
  5. UdjinM6

    UdjinM6 Official Dash Dev
    Dash Core Team Moderator

    Joined:
    May 20, 2014
    Messages:
    3,637
    Likes Received:
    3,536
    Trophy Points:
    1,183
    Yes, https://github.com/dashpay/dash/blob/master/src/chainparams.cpp#L140
     
    • Like Like x 1