Private key format

+1 vote
Hi, I'm trying to use my wallet private key in my application. I got a Base58 string as the response of the dumpprivkey command which should be in the Wallet Import Format specified by bitcoin documentation. However the length of the dumped private key is wrong (41 bytes instead of the valid 32 or 33 depending of the compression) and also if I try to make a checksum validation it fails (verifying the last 4 checksum bytes against the double hash of the private key bytes without the last 4 bytes of checksum).

Can you please explain the dumped private key format you use in multichain? Thanks a lot

asked Feb 5, 2016 by Miklos

1 Answer

+1 vote

Thanks for this question - we need to document this properly. But for now you'll find a hint in the public address format page, which explains how the multiple version bytes in the private-key-version parameter are distributed throughout the private key. The address-checksum-value may also be used to XOR the checksum after calculating it, before appending to the end (not 100% sure about that - please check).

answered Feb 5, 2016 by MultiChain
Thanks, but this does not answer the question. The linked page explains how to generate the address from the private key, but my question how the private key is represented in the response of the dumpprivkey command. Thanks a lot
Actually, based on your recommendation I found the solution: every ninth byte of the primary key is injected from the version bytes (0, 9, 18, 27) and the hash is calculated by double digesting (SHA256) the extended primary key and by calculationg the XOR with address-checksum-value.
However I still have one question: can I get the value of the address-checksum-value parameter from any JSON-RPC commands? Or is it always the same? Thanks a lot!
Glad you worked it out. The API call you're looking for is getblockchainparams.
Thanks a lot for your help! Works like a charm!
can you please explain more about it?