<p>No they are not stored, the child keys are calculated from the master when needed as they are deterministic, not random. </p>

<p>Here are some references:    </p>

<p><a href="https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch04.html#_deterministic_seeded_wallets" rel="nofollow noreferrer">https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch04.html#_deterministic_seeded_wallets</a></p>

<p><a href="https://learnmeabitcoin.com/guide/hd-wallets" rel="nofollow noreferrer">https://learnmeabitcoin.com/guide/hd-wallets</a></p>

CC BY-SA 4.0
2020-06-02T18:09:05.803Z
2020-06-02T18:09:05.803Z
m1xolyd1an
<p>So Bitcoin uses an HD wallet and thanks to that it can store keys in a hierarchy. But how exactly and in what format are they stored? Is each private and public key stored as a separate file? Are they stored in textual or binary format? Does Bitcoin use a database to store them?</p>

<p>The only resource I found is the source code of Bitcoin Core but are there any books or sites where I can find explanations about this?</p>

CC BY-SA 4.0
2020-06-02T14:10:22.057Z
I don't know if it really gives the detail you want but there is [Mastering Bitcoin](https://www.oreilly.com/library/view/mastering-bitcoin-2nd/9781491954379/) by Andreas M. Antonopoulos. This has chapters on bitcoin-core and on HD wallets. I suspect all the keys are in wallet.data and that a variant of Berkeley-DB key-value pair "database" format is used.
RedGrittyBrick
<wallet><storage>
How exactly are public/private keys stored?
Aschente
# How exactly are public/private keys stored?

(Asked by: username_0 on 2020-06-02)

So Bitcoin uses an HD wallet and thanks to that it can store keys in a hierarchy. But how exactly and in what format are they stored? Is each private and public key stored as a separate file? Are they stored in textual or binary format? Does Bitcoin use a database to store them?

The only resource I found is the source code of Bitcoin Core but are there any books or sites where I can find explanations about this?

**Tags:** wallet, storage

> **Comments:**
> **username_1**: I don't know if it really gives the detail you want but there is [Mastering Bitcoin](https://www.oreilly.com/library/view/mastering-bitcoin-2nd/9781491954379/) by Andreas M. Antonopoulos. This has chapters on bitcoin-core and on HD wallets. I suspect all the keys are in wallet.data and that a variant of Berkeley-DB key-value pair "database" format is used.  

---

## 1 answers

### Answer by username_2 on 2020-06-02. Score: 1

No they are not stored, the child keys are calculated from the master when needed as they are deterministic, not random.

Here are some references:

<https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch04.html#_deterministic_seeded_wallets>

<https://learnmeabitcoin.com/guide/hd-wallets>


---

