<p><code>CKeyStore</code> is a class for storing keys. It provides the functions for storing and retrieving keys.</p>

<p><code>CKeyPool</code> is a class for a key that is in the keypool. It is specifically a database object for storing a public key and its location inside of the keypool.</p>

<p><code>CKeyStore</code> and <code>CKeyPool</code> are two different things and are largely unrelated.</p>

<p>The keypool is the set of keys that are unused. It is separate from <code>CKeyStore</code> and has an entirely different purpose. <code>CKeyPool</code> objects are specific to a <code>CWallet</code> which is a subclass of <code>CKeyStore</code>.</p>

CC BY-SA 4.0
2018-09-24T13:43:07.040Z
Thanks. If the keypool store only store public keys, where is the related private keys located and how the pair related?
yrm23
CC BY-SA 4.0
2018-09-24T13:53:40.990Z
If refill keypool, where the new private keys go?
yrm23
CC BY-SA 4.0
2018-09-24T14:05:11.700Z
The private keys, along with their public keys, are stored in the keystore. When new keys are generated, they private keys and their public keys are added to the keystore. At the same time, public keys are added to the keypool. There are other information that is stored to.
Ava Chow
CC BY-SA 4.0
2018-09-24T14:13:13.477Z
One more thing, I am not sure, when new keys are generated, the public keys are added to both keystore and keypool, or just added to the keystore's keypool only?
yrm23
CC BY-SA 4.0
2018-09-24T15:17:11.753Z
A keystore does not have a keypool. The public keys are added to many different places, including the keystore and the keypool. Public keys are used as identifiers for many things, so they end up being duplicated in many different places.
Ava Chow
CC BY-SA 4.0
2018-09-24T13:26:30.267Z
2018-09-24T13:26:30.267Z
Ava Chow
<p>In the source, there are ckeypool and skeystore. I wonder what is the relationship of them and why need both.  </p>

<transactions><wallet><private-key>
What is the relationship of ckeypool and ckeystore?
yrm23
# What is the relationship of ckeypool and ckeystore?

(Asked by: username_0 on 2018-09-24)

In the source, there are ckeypool and skeystore. I wonder what is the relationship of them and why need both.

**Tags:** transactions, wallet, private-key


---

## 1 answers

### Answer by username_1 on 2018-09-24. Score: 1

`CKeyStore` is a class for storing keys. It provides the functions for storing and retrieving keys.

`CKeyPool` is a class for a key that is in the keypool. It is specifically a database object for storing a public key and its location inside of the keypool.

`CKeyStore` and `CKeyPool` are two different things and are largely unrelated.

The keypool is the set of keys that are unused. It is separate from `CKeyStore` and has an entirely different purpose. `CKeyPool` objects are specific to a `CWallet` which is a subclass of `CKeyStore`.

> **Comments:**
> **username_0**: Thanks. If the keypool store only store public keys, where is the related private keys located and how the pair related?  
> **username_0**: If refill keypool, where the new private keys go?  
> **username_1**: The private keys, along with their public keys, are stored in the keystore. When new keys are generated, they private keys and their public keys are added to the keystore. At the same time, public keys are added to the keypool. There are other information that is stored to.  
> **username_0**: One more thing, I am not sure, when new keys are generated, the public keys are added to both keystore and keypool, or just added to the keystore's keypool only?  
> **username_1**: A keystore does not have a keypool. The public keys are added to many different places, including the keystore and the keypool. Public keys are used as identifiers for many things, so they end up being duplicated in many different places.  

---

