2
I'm using NBitcoin and I created an ExtKey object. Now I need to get the Master Chain Code (see page 89 of Mastering Bitcoin for a good explanation) for this HD node. How do I do this?
According to Mastering Bitcoin a root seed is used with HMAC-SHA512 to create a 512-bits output. The left 256 bits are used for the master private key, the right 256 bits are used for the master chain code. When I call GetBytes() on my ExtKey object, however, it returns a byte[74] array. This corresponds to 592 bits. I don't know what the extra 80 bits are so I can't just take the right 256 bits.
1No, that's not what I need. WIF and Chain Code are two completely different things. WIF is just a way to encode a private key. – Leon Cullens – 2016-05-22T18:31:38.983
Anyway, I added a change to NBitcoin that exposes the chain code through a property, see PR 156 https://github.com/MetacoSA/NBitcoin/pull/156. It has been merged into NBitcoin 3.0.0.28, available on NuGet.
– Leon Cullens – 2016-05-22T18:32:58.303