• Forum has been upgraded, all links, images, etc are as they were. Please see Official Announcements for more information

Generating DRK addresses from blockchain

darkchild

Active member
I've setup a darkcoin-abe blockchain parser after a bit of tweaking and everything is running fine and dumping all the data into a MySQL database in realtime.

One of the tables created by darkcoin-abe is the pubkey table which stores the public key and public key hashes. Since the blockchain doesn't store the wallet addresses, one would need to generate the address used in transactions using the pubkey_hash value in the database.

I found some information on stackoverflow that shows how to generate Bitcoin addresses from the pubkey_hashes.

Does anyone know how to do this to generate Darkcoin addresses? I might be going about this the wrong way so I'd appreciate any insights.

Thanks.
 
I've setup a darkcoin-abe blockchain parser after a bit of tweaking and everything is running fine and dumping all the data into a MySQL database in realtime.

One of the tables created by darkcoin-abe is the pubkey table which stores the public key and public key hashes. Since the blockchain doesn't store the wallet addresses, one would need to generate the address used in transactions using the pubkey_hash value in the database.

I found some information on stackoverflow that shows how to generate Bitcoin addresses from the pubkey_hashes.

Does anyone know how to do this to generate Darkcoin addresses? I might be going about this the wrong way so I'd appreciate any insights.

Thanks.
me again :)
https://gist.github.com/UdjinM6/07f1feae8b7495c67480

EDIT: I guess that's too much for the answer - short version:
process is the same https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses just use 0x4c for Main Network instead of 0x00 on step 4
 
Last edited by a moderator:
Actually I was wondering about this as well. For the second step on this page, https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses what are you using? Specifically, this part:
1 - Take the corresponding public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate)

Is it the part highlighted in blue?
Full key decipher.

3081d30201010420ca7b50f41b2f43e1e913bdb6f6ff3289223d9ec0ebe610f801a1e93cb2564d54a08185308182020101302c06072a8648ce3d0101022100fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f300604010004010704210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798022100fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141020101a12403220003c0ef03fc45624122c85791557be9782cc7a2a813125f317aa0136b25ce5cec76

Run in terminal: ehco -n "3081.." | xxd -r -p | openssl asn1parse -i -inform DER -dump

0:d=0 hl=3 l= 211 cons: SEQUENCE
3:d=1 hl=2 l= 1 prim: INTEGER :01
6:d=1 hl=2 l= 32 prim: OCTET STRING
0000 - ca 7b 50 f4 1b 2f 43 e1-e9 13 bd b6 f6 ff 32 89 This is the private key.
0010 - 22 3d 9e c0 eb e6 10 f8-01 a1 e9 3c b2 56 4d 54 //ca7b50f41b2f43e1e913bdb6f6ff3289223d9ec0ebe610f801a1e93cb2564d54
40:d=1 hl=3 l= 133 cons: cont [ 0 ]
43:d=2 hl=3 l= 130 cons: SEQUENCE
46:d=3 hl=2 l= 1 prim: INTEGER :01
49:d=3 hl=2 l= 44 cons: SEQUENCE
51:d=4 hl=2 l= 7 prim: OBJECT :prime-field
60:d=4 hl=2 l= 33 prim: INTEGER :FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F
95:d=3 hl=2 l= 6 cons: SEQUENCE
97:d=4 hl=2 l= 1 prim: OCTET STRING
0001 - <SPACES/NULS>
100:d=4 hl=2 l= 1 prim: OCTET STRING
0000 - 07 .
103:d=3 hl=2 l= 33 prim: OCTET STRING
0000 - 02 79 be 66 7e f9 dc bb-ac 55 a0 62 95 ce 87 0b .y.f~....U.b....
0010 - 07 02 9b fc db 2d ce 28-d9 59 f2 81 5b 16 f8 17 .....-.(.Y..[...
0020 - 98 .
138:d=3 hl=2 l= 33 prim: INTEGER :FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
173:d=3 hl=2 l= 1 prim: INTEGER :01
176:d=1 hl=2 l= 36 cons: cont [ 1 ]
178:d=2 hl=2 l= 34 prim: BIT STRING
0000 - 00 03 c0 ef 03 fc 45 62-41 22 c8 57 91 55 7b e9 This is the public key. Exclude the first byte.
0010 - 78 2c c7 a2 a8 13 12 5f-31 7a a0 13 6b 25 ce 5c //03c0ef03fc45624122c86791557be9782cc7a2a813125f317aa0136b25ce5cec76
0020 - ec 76

I'd like to be able to parse the public key from a full key as above.

Edit: or would it be:
"4cFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"?

Or, "4c03c0ef03fc45624122c86791557be9782cc7a2a813125f317aa0136b25ce5cec760279be667ef9dcbbac55a06295ce870b07029bfcdb2dce68d959f2815b16f81798"

EDIT EDIT: Actually both of those are 33 so a single character would have to be dropped off somewhere.

EDIT EDIT EDIT: I guess to summarize, where is the x and y coordinate and what do you chop off?
 
Last edited by a moderator:
Actually I was wondering about this as well. For the second step on this page, https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses what are you using? Specifically, this part:

Is it the part highlighted in blue?


I'd like to be able to parse the public key from a full key as above.

Edit: or would it be:
"4cFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"?

Or, "4c03c0ef03fc45624122c86791557be9782cc7a2a813125f317aa0136b25ce5cec760279be667ef9dcbbac55a06295ce870b07029bfcdb2dce68d959f2815b16f81798"
That's for the second step on this page https://gist.github.com/UdjinM6/07f1feae8b7495c67480#file-bitwalletrecover-py-L68-L70
So it's simply calculated.
You can find a lot of info by private key there (tab "Wallet Details") http://walletgenerator.net/?currency=Darkcoin#
For example corresponding public key is
Public Key (130 characters [0-9A-F]):
04C0EF03FC45624122C85791557BE9782CC7A2A813125F317AA0136B25CE5CEC763E1A532BBF8495E74E9247D2FA0F20C6083EFB3B4A01F8757A0B5B03BA88F001
 
03c0ef03fc45624122c86791557be9782cc7a2a813125f317aa0136b25ce5cec76

Wouldn't it be "03" in the beginning just from going by the public key?

Then for the second part "3E1A532BBF8495E74E9247D2FA0F20C6083EFB3B4A01F8757A0B5B03BA88F001" How are you determing this? I don't see it in the ans1parse.
 
03c0ef03fc45624122c86791557be9782cc7a2a813125f317aa0136b25ce5cec76

Wouldn't it be "03" in the beginning just from going by the public key?

Then for the second part "3E1A532BBF8495E74E9247D2FA0F20C6083EFB3B4A01F8757A0B5B03BA88F001" How are you determing this? I don't see it in the ans1parse.
Both parts are calculated from ECDSA by function ( http://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm )
Public Key (130 characters [0-9A-F]):
04C0EF03FC45624122C85791557BE9782CC7A2A813125F317AA0136B25CE5CEC763E1A532BBF8495E74E9247D2FA0F20C6083EFB3B4A01F8757A0B5B03BA88F001
Public Key (compressed, 66 characters [0-9A-F]):
03C0EF03FC45624122C85791557BE9782CC7A2A813125F317AA0136B25CE5CEC76
So 03 - is for compressed key (could be 02 also) and it's calculated. In your original example there is only compressed public key that is stored. To get uncompressed public key you have to calculate it from private key.
 
UdjinM6 I think I understand. So you're taking the stored public key and then performing an ECDSA function on it to get the second part and then combine them. After that, regular hashing and base58.

Is it possible to do the ECDSA function in bash using openssl?

*I'm going to feel like an idiot if I'm still not understanding this*
 
UdjinM6 I think I understand. So you're taking the stored public key and then performing an ECDSA function on it to get the second part and then combine them. After that, regular hashing and base58.

Is it possible to do the ECDSA function in bash using openssl?

*I'm going to feel like an idiot if I'm still not understanding this*
Not exactly :) you take private key to calculate public key performing an ECDSA function on it then you can perform another function to get compressed public key
Can't help you with openssl, sorry...
 
Back
Top