<p>Non-hardened parents effectively use the public key to derive their children, where hardened parents derive their children from the private key.</p>

<p>The derivation of a child private key from a non-hardened parent private key <code>k</code> uses the following hash function:</p>

<pre><code>HMAC-SHA512(chainCode, point(k) || i)
</code></pre>

<p>We know that <code>K = point(k)</code>, where <code>K</code> is the parent public key. Thus, if we only know <code>K</code> and not necessarily <code>k</code>, we are still able to derive the child key by replacing <code>point(k)</code> with <code>K</code>, and follow the regular process.</p>

<p>With hardened private keys, the hashing is done differently:</p>

<pre><code>HMAC-SHA512(chainCode, 0x00 || k || i)
</code></pre>

<p>Here you can see that there is no possible way that you could compute this hmac without knowing <code>k</code>. Just knowing the public key <code>K</code> will not help.</p>

<hr>

<p>It looks as though you need to use the <code>deriveHardened</code> function in bitcoinjs rather than plain <code>derive</code>.</p>

CC BY-SA 4.0
2020-01-27T18:22:19.623Z
The even shorter answer is that you cannot derive hardened public keys from xpubs, because hardening is specifically designed to make exactly that impossible.
Pieter Wuille
CC BY-SA 4.0
2019-12-28T15:28:20.373Z
2019-12-28T15:28:20.373Z
Mark H
<p>I'm trying to understand bip32 hardened mechanism, but I'm confused about it.</p>

<p>I got xpubKey from <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">this site</a>, and what I'm trying to do is demonstrate failure when trying to generate child pubkey from hardened xpubkey.</p>

<p>Here's my test details.</p>

<ul>
<li>network : bitcoin testnet</li>
<li>mnemonic : dash axis fat pilot truly river guitar sea tonight popular type ill inmate quote upset</li>
<li>parent path : m/44'</li>
<li><p>parent xpubKey : tpubDA4h4NTsxqEXATU9dPS22ZVuBHd2jVketkP8RNhBZ6fMhW9WuMhrjf37qNmfmLQZoFreLmHf9LsTnvW2eJYx1fkzo7vVxsf7bKVixz2FjGw</p></li>
<li><p>target child path : m/44'/0 (non regular, just for test)</p></li>
</ul>

<p>and I wrote some js code, and I assumed to fail, but succeeded.</p>

<pre><code>const bitcoinjs = require('bitcoinjs-lib');

const xpubKey = 'tpubDA4h4NTsxqEXATU9dPS22ZVuBHd2jVk...';

const parentNode = bitcoinjs.bip32.fromBase58(xpubKey, bitcoinjs.networks.testnet);

////////
// I THOUGHT BELOW WILL FAIL!
//////// 

// trying to get m/44'/0
const derived = parentNode.derive(0);

// result was valid public key for m/44'/0
console.log(derived.publicKey);
</code></pre>

<p>In my thought, if I have a valid xpubKey(hardened or not), means that I have a valid chain code and public key for current node (means that I can derive children).</p>

<p>So what's meaning of </p>

<blockquote>
  <p>Hardened public keys cannot derive any children?</p>
</blockquote>

<p>FYI, I quoted that in <a href="https://youtu.be/OVvue2dXkJo?t=1224" rel="nofollow noreferrer">this video (20:24)</a>.</p>

<bip32-hd-wallets>
Why hardended xpub key cannot generate child public key?
Jason
# Why hardended xpub key cannot generate child public key?

(Asked by: username_0 on 2019-12-28)

I'm trying to understand bip32 hardened mechanism, but I'm confused about it.

I got xpubKey from [this site](https://iancoleman.io/bip39/), and what I'm trying to do is demonstrate failure when trying to generate child pubkey from hardened xpubkey.

Here's my test details.

* network : bitcoin testnet
* mnemonic : dash axis fat pilot truly river guitar sea tonight popular type ill inmate quote upset
* parent path : m/44'
* parent xpubKey : tpubDA4h4NTsxqEXATU9dPS22ZVuBHd2jVketkP8RNhBZ6fMhW9WuMhrjf37qNmfmLQZoFreLmHf9LsTnvW2eJYx1fkzo7vVxsf7bKVixz2FjGw
* target child path : m/44'/0 (non regular, just for test)

and I wrote some js code, and I assumed to fail, but succeeded.

```
const bitcoinjs = require('bitcoinjs-lib');

const xpubKey = 'tpubDA4h4NTsxqEXATU9dPS22ZVuBHd2jVk...';

const parentNode = bitcoinjs.bip32.fromBase58(xpubKey, bitcoinjs.networks.testnet);

////////
// I THOUGHT BELOW WILL FAIL!
//////// 

// trying to get m/44'/0
const derived = parentNode.derive(0);

// result was valid public key for m/44'/0
console.log(derived.publicKey);

```

In my thought, if I have a valid xpubKey(hardened or not), means that I have a valid chain code and public key for current node (means that I can derive children).

So what's meaning of

> Hardened public keys cannot derive any children?

FYI, I quoted that in [this video (20:24)](https://youtu.be/OVvue2dXkJo?t=1224).

**Tags:** bip32-hd-wallets


---

## 1 answers

### Answer by username_1 on 2019-12-28. Score: 2

Non-hardened parents effectively use the public key to derive their children, where hardened parents derive their children from the private key.

The derivation of a child private key from a non-hardened parent private key `k` uses the following hash function:

```
HMAC-SHA512(chainCode, point(k) || i)

```

We know that `K = point(k)`, where `K` is the parent public key. Thus, if we only know `K` and not necessarily `k`, we are still able to derive the child key by replacing `point(k)` with `K`, and follow the regular process.

With hardened private keys, the hashing is done differently:

```
HMAC-SHA512(chainCode, 0x00 || k || i)

```

Here you can see that there is no possible way that you could compute this hmac without knowing `k`. Just knowing the public key `K` will not help.

---

It looks as though you need to use the `deriveHardened` function in bitcoinjs rather than plain `derive`.

> **Comments:**
> **username_2**: The even shorter answer is that you cannot derive hardened public keys from xpubs, because hardening is specifically designed to make exactly that impossible.  

---

