1

I'm trying to implement a barebones HD wallet generator in C#. I'm starting with a mnemonic and derivation path m/0' and want to generate BIP141 p2wpkh-in-p2sh addresses. Obviously for the Master Node the fingerprint is 0x00000000, but when I get to depth 1 (0'), I need to calculate the fingerprint of the parent key. My question is, is the formula RipeMD160(parentPrivKey) or RipeMD160(SHA256(parentPrivKey))? I've been looking at Ian Coleman's implementation in javascript (https://iancoleman.io/bip39/) and he seems to do the latter one. However, on this site under "Parent Fingerprint", it says it's the former.

1

It's ripemd160(sha256(parentpriv)) also known as hash160(parentpriv) source. There is also a python implementation here

| improve this answer | |
0

Can't use comments because of reputation, but both the question and the answer is saying that the fingerprint is based on private key. It should be the hash160 of the PUBLIC key. for even if you are deriving a private key you should use the parents PUBLIC key for generating the fingerprint. This is important to make both a derived public and a derived private key having the same fingerprint so you can relate them to each other.

| improve this answer | |
0

A number of HD wallet fingerprint test vectors for curves secp256k1, nist256p1, and ed25519 are provided at the bottom of https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-ed25519. Notice all top tier fingerprints are 00000000.

For https://github.com/satoshilabs/slips/blob/master/slip-0010.md#test-vector-1-for-secp256k1 Chain m/0H, the fingerprint is computed from its parent's public key as follows:

% echo 0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2 | bx sha256 | bx ripemd160 | cut -c 1-8

3442193e

% echo 0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2 | bx bitcoin160 | cut -c 1-8

3442193e

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.