<p>You can have your answer by considering why chaincode exists? </p>

<p>It exists to add entropy. If you read <a href="https://bitcoin.stackexchange.com/a/41598/35931">this answer</a> you will find out that if any of your child-private-key leaks, chaincode can enable private key discovery of keys <strong>up</strong> the tree, including the master.</p>

<p>So it is part of a secret and hence a secret most definitely.</p>

CC BY-SA 3.0
2018-02-20T22:13:37.710Z
2018-02-20T22:13:37.710Z
skang404
<p>The idea is that you shouldn't reveal the extended public key (and thus the chaincode) unless you want people to be able to know all of your addresses and potentially recover the extended private key. It should be considered semi-secret; more secret than just the public key itself, but less secret than the private key.</p>

<p>Knowing the extended public key allows someone to know what all of your addresses are, so you lose security. But it does not allow them to know the private keys except in certain circumstances. Because of the extended private key could be derived from the extended public key, you shouldn't give out the extended public key. </p>

<p>However there are few use cases where others do need to know the extended public key, and if you avoid the insecure case, it is safe and secure to reveal the extended public key. You just need to be extra careful in the future to avoid revealing a child key.</p>

CC BY-SA 4.0
2022-02-02T11:04:56.457Z
"it does not allow them to know the private keys except in certain circumstances"
 what circumstances?
Antoni
CC BY-SA 4.0
2022-02-02T16:04:22.780Z
@Antoni If keys were derived from an xpub using unhardened derivation, and a child private key is known along with the parent xpub, the parent xprv can be derived. Doing this requires knowledge of the chaincode, but that is available in the xpub.
Ava Chow
CC BY-SA 3.0
2018-02-20T22:02:22.203Z
2018-02-20T22:02:22.203Z
Ava Chow
<p>I'm confused by a statement in <a href="https://bitcoin.org/en/developer-guide#hardened-keys" rel="nofollow noreferrer">https://bitcoin.org/en/developer-guide#hardened-keys</a></p>

<blockquote>
  <p>"For this reason, the chain code part of an extended public key should
  be better secured than standard public keys"</p>
</blockquote>

<p>I'm confused because I thought the chain code was an intrinsic and easily deciphered part of an extended public key.  For example the top answer here explains how to derive the chain code from any extended public key:</p>

<p><a href="https://bitcoin.stackexchange.com/questions/62533/key-derivation-in-hd-wallets-using-the-extended-private-key-vs-hardened-derivati?rq=1">Key derivation in HD wallets using the extended private key vs hardened derivation</a></p>

<p>So how exactly is one supposed to obey the advice from bitcoin.org to "secure" this chain code when it's openly exposed in the public key itself?  Does a "hardened" public key not likewise expose its chain code?</p>

<blockchain>
is the chain code considered secret?
Magnus
# is the chain code considered secret?

(Asked by: username_0 on 2018-02-20)

I'm confused by a statement in <https://bitcoin.org/en/developer-guide#hardened-keys>

> "For this reason, the chain code part of an extended public key should
> be better secured than standard public keys"

I'm confused because I thought the chain code was an intrinsic and easily deciphered part of an extended public key. For example the top answer here explains how to derive the chain code from any extended public key:

[Key derivation in HD wallets using the extended private key vs hardened derivation](https://bitcoin.stackexchange.com/questions/62533/key-derivation-in-hd-wallets-using-the-extended-private-key-vs-hardened-derivati?rq=1)

So how exactly is one supposed to obey the advice from bitcoin.org to "secure" this chain code when it's openly exposed in the public key itself? Does a "hardened" public key not likewise expose its chain code?

**Tags:** blockchain


---

## 2 answers

### Answer by username_2 on 2018-02-20. Score: 4 | Accepted answer

The idea is that you shouldn't reveal the extended public key (and thus the chaincode) unless you want people to be able to know all of your addresses and potentially recover the extended private key. It should be considered semi-secret; more secret than just the public key itself, but less secret than the private key.

Knowing the extended public key allows someone to know what all of your addresses are, so you lose security. But it does not allow them to know the private keys except in certain circumstances. Because of the extended private key could be derived from the extended public key, you shouldn't give out the extended public key.

However there are few use cases where others do need to know the extended public key, and if you avoid the insecure case, it is safe and secure to reveal the extended public key. You just need to be extra careful in the future to avoid revealing a child key.

> **Comments:**
> **username_3**: "it does not allow them to know the private keys except in certain circumstances"  what circumstances?  
> **username_2**: @username_3 If keys were derived from an xpub using unhardened derivation, and a child private key is known along with the parent xpub, the parent xprv can be derived. Doing this requires knowledge of the chaincode, but that is available in the xpub.  

---

### Answer by username_1 on 2018-02-20. Score: 3

You can have your answer by considering why chaincode exists?

It exists to add entropy. If you read [this answer](https://bitcoin.stackexchange.com/a/41598/35931) you will find out that if any of your child-private-key leaks, chaincode can enable private key discovery of keys **up** the tree, including the master.

So it is part of a secret and hence a secret most definitely.


---

