<blockquote>
  <p>What are the last bytes? (0a794dec)</p>
</blockquote>

<p>The checksum.</p>

<blockquote>
  <p>In the next operation (HMAC-SHA512) I used the chain code obtained, the key and the next depth (80000002), but I'm not sure.</p>
</blockquote>

<p>Yep, <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#private-parent-key--private-child-key" rel="nofollow noreferrer">that's it</a> : I can see you also prepanded the 0x00 (because serialized privkeys are 32 bytes while serialized compressed public keys are 33 bytes).</p>

<blockquote>
  <p>I got a 64 bytes result: the 32 bytes on the right become the child's chain code. I "added" the 32 bytes on the left to the parent's key.</p>
</blockquote>

<p>You need a proper tool to perform this addition : you need to compute this addition modulo the curve order.</p>

<p>Since you use <code>bx</code>, you might want to give <a href="https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-add-secrets" rel="nofollow noreferrer"><code>ec-add-secrets</code></a> a look.</p>

<blockquote>
  <p>Would anyone know how to recommend a Bx command or a tool to carry out this step?</p>
</blockquote>

<p>You could use <a href="https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-multiply" rel="nofollow noreferrer"><code>ec-multiply-secrets</code></a> by passing G (the generator point) as the <code>point</code> parameter.</p>

<p>G = 0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798</p>

<p>EDIT: As another tool if you know a bit of Python you might want to hack with <a href="https://github.com/darosior/python-bip32" rel="nofollow noreferrer">https://github.com/darosior/python-bip32</a> . I tried to keep it minimal.</p>

CC BY-SA 4.0
2020-05-11T16:05:55.567Z
How is the checksum obtained?
MaXbeMan
CC BY-SA 4.0
2020-05-11T17:19:15.603Z
@AndreaMelk : pure base58check, the double_sha256(serialized_payload) https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format :)
Antoine Poinsot
CC BY-SA 4.0
2020-05-10T18:03:47.730Z
2020-05-10T18:03:47.730Z
Antoine Poinsot
<p>I am trying to make the child key derivation using the extended keys of the BIP32 document (<a href="https://en.bitcoin.it/wiki/BIP_0032" rel="nofollow noreferrer">https://en.bitcoin.it/wiki/BIP_0032</a>). Assuming that an extended key is only a base58 encoded serialization of some data, i have decoded the extended keys that I find in "Test Vector 1":</p>

<pre><code>bx-windows-x64-icu.exe base58-decode 
 xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw
 0488b21e013442193e8000000047fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141035a784662a4a20a65bf6aab9ae98a6c068a81c52e4b032c0fb5400c706cfccc56b8b9c580
bx-windows-x64-icu.exe base58-decode 
 xprv9uHRZZhk6KAJC1avXpDAp4MDc3sQKNxDiPvvkX8Br5ngLNv1TxvUxt4cV1rGL5hj6KCesnDYUhd7oWgT11eZG7XnxHrnYeSvkzY7d2bhkJ7
 0488ade4013442193e8000000047fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae623614100edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea0a794dec
</code></pre>

<p>I decode the result obtained for the private key:</p>

<pre><code>0488ade4 is "magic" field for xprv 
01 is "depth"
3442193e is "parentfingerprint"
80000000 is "key index"
47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141 is chain code" 
00 edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea is "key"
</code></pre>

<blockquote>
  <p>What are the last bytes? (0a794dec)</p>
</blockquote>

<p>In the next operation (HMAC-SHA512) I used the chain code obtained, the key and the next depth (80000002), but I'm not sure. </p>

<pre><code>HMAC-SHA512( 47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141, 
          00edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea0a794dec80000002 )
</code></pre>

<p>I got a 64 bytes result: the 32 bytes on the right become the child's chain code. I "added" the 32 bytes on the left to the parent's key.</p>

<pre><code>3bf125923e89743b3414e76f30c662aae014e1cbd4f8251fea0d556758d66227+ edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea
= 29a406e1dd70f16211a89c5c1eaf341af96ed2f9c11c5cef315099b39a40d0d0
</code></pre>

<p>To get the fingerprint from the parent, I need to know the public key. Since it is in the form of a private key, we will have to multiply with the generator point. </p>

<blockquote>
  <p>Would anyone know how to recommend a Bx command or a tool to carry out
  this step?</p>
</blockquote>

<private-key><public-key><bip><child-chain><extended-fingerprint>
Tips for child key derivation
MaXbeMan
# Tips for child key derivation

(Asked by: username_0 on 2020-05-10)

I am trying to make the child key derivation using the extended keys of the BIP32 document (<https://en.bitcoin.it/wiki/BIP_0032>). Assuming that an extended key is only a base58 encoded serialization of some data, i have decoded the extended keys that I find in "Test Vector 1":

```
bx-windows-x64-icu.exe base58-decode 
 xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw
 0488b21e013442193e8000000047fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141035a784662a4a20a65bf6aab9ae98a6c068a81c52e4b032c0fb5400c706cfccc56b8b9c580
bx-windows-x64-icu.exe base58-decode 
 xprv9uHRZZhk6KAJC1avXpDAp4MDc3sQKNxDiPvvkX8Br5ngLNv1TxvUxt4cV1rGL5hj6KCesnDYUhd7oWgT11eZG7XnxHrnYeSvkzY7d2bhkJ7
 0488ade4013442193e8000000047fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae623614100edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea0a794dec

```

I decode the result obtained for the private key:

```
0488ade4 is "magic" field for xprv 
01 is "depth"
3442193e is "parentfingerprint"
80000000 is "key index"
47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141 is chain code" 
00 edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea is "key"

```

> What are the last bytes? (0a794dec)

In the next operation (HMAC-SHA512) I used the chain code obtained, the key and the next depth (80000002), but I'm not sure.

```
HMAC-SHA512( 47fdacbd0f1097043b78c63c20c34ef4ed9a111d980047ad16282c7ae6236141, 
          00edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea0a794dec80000002 )

```

I got a 64 bytes result: the 32 bytes on the right become the child's chain code. I "added" the 32 bytes on the left to the parent's key.

```
3bf125923e89743b3414e76f30c662aae014e1cbd4f8251fea0d556758d66227+ edb2e14f9ee77d26dd93b4ecede8d16ed408ce149b6cd80b0715a2d911a0afea
= 29a406e1dd70f16211a89c5c1eaf341af96ed2f9c11c5cef315099b39a40d0d0

```

To get the fingerprint from the parent, I need to know the public key. Since it is in the form of a private key, we will have to multiply with the generator point.

> Would anyone know how to recommend a Bx command or a tool to carry out
> this step?

**Tags:** private-key, public-key, bip, child-chain, extended-fingerprint


---

## 1 answers

### Answer by username_1 on 2020-05-10. Score: 1 | Accepted answer

> What are the last bytes? (0a794dec)

The checksum.

> In the next operation (HMAC-SHA512) I used the chain code obtained, the key and the next depth (80000002), but I'm not sure.

Yep, [that's it](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#private-parent-key--private-child-key) : I can see you also prepanded the 0x00 (because serialized privkeys are 32 bytes while serialized compressed public keys are 33 bytes).

> I got a 64 bytes result: the 32 bytes on the right become the child's chain code. I "added" the 32 bytes on the left to the parent's key.

You need a proper tool to perform this addition : you need to compute this addition modulo the curve order.

Since you use `bx`, you might want to give [`ec-add-secrets`](https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-add-secrets) a look.

> Would anyone know how to recommend a Bx command or a tool to carry out this step?

You could use [`ec-multiply-secrets`](https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-multiply) by passing G (the generator point) as the `point` parameter.

G = 0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798

EDIT: As another tool if you know a bit of Python you might want to hack with <https://github.com/darosior/python-bip32> . I tried to keep it minimal.

> **Comments:**
> **username_0**: How is the checksum obtained?  
> **username_1**: @AndreaMelk : pure base58check, the double_sha256(serialized_payload) https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format :)  

---

