<p>Welcome to the Bitcoin world.</p>

<blockquote>
  <p>My first question is: When and How my private/public key was generated?</p>
</blockquote>

<p>Your public key is calculated by your private key.</p>

<p>Where your private key is a randomly chosen number, so let's suppose that now we choose k value as your private key, from this we can apply a unidirectional cryptographic function, ie from the private key I can ALWAYS get my public key but it is impossible to contrary (unless expensive brute force attacks, where the game is not worth the candle)
This hash function is an elliptic curve function, I leave you the reference to a <a href="https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc" rel="nofollow noreferrer">bitcoin book</a>.</p>

<p>So I have my private key K where I apply my asymmetric encryption algorithm and get the public key.</p>

<pre><code>P = hash_fun (K);
</code></pre>

<blockquote>
  <p>My second question is: I know this is not a good practice but if i only know my private/public key in clear format (not encrypted): Is there a way for me to "import" this public/private key into my bitcoin wallet. In other words, can i say if i know my public/private key, i know everything.</p>
</blockquote>

<p>Yes, the wallet is formed by the pair (private key, public key) many wallets keep the whole pair but it is possible to get the public key whenever you want, if you know the private key, but not vice versa.</p>

<p>So your private K key is your wallet, or rather what makes your wallet alive</p>

CC BY-SA 4.0
2019-08-23T14:47:50.460Z
Thanks a lot for your answer. Can you tell me what is the syntax or command that can import a private key into bitcoind ?
Bob5421
CC BY-SA 4.0
2019-08-23T15:33:18.333Z
this is a good [reference](https://en.bitcoin.it/wiki/How_to_import_private_keys) I have never done such a thing, but I once read this reference, that **users should never import (or export) private keys**
vincenzopalazzo
CC BY-SA 4.0
2019-08-23T11:50:56.340Z
2019-08-23T11:59:50.950Z
2019-08-23T11:59:50.950Z
vincenzopalazzo
<p>My goal is to understand the bitcoin internals.</p>

<p>Here is what i have done:</p>

<p>I have downloaded, maked and installed bitcoin sourcecode from github.</p>

<p>I have launched the bitcoind daemon. Everything seems to work because i can generate addresses with bitcoin-cli.</p>

<p>My first question is: When and How my private/public key was generated ?
I had nothing to do for that and i am wondering when this operation was done.</p>

<p>My second question is: I know this is not a good practice but if i only know my private/public key in clear format (not encrypted): Is there a way for me to "import" this public/private key into my bitcoin wallet.
In other words, can i say if i know my public/private key, i know everything.</p>

<p>Thanks</p>

<wallet>
Understand how wallet works
Bob5421
# Understand how wallet works

(Asked by: username_0 on 2019-08-23)

My goal is to understand the bitcoin internals.

Here is what i have done:

I have downloaded, maked and installed bitcoin sourcecode from github.

I have launched the bitcoind daemon. Everything seems to work because i can generate addresses with bitcoin-cli.

My first question is: When and How my private/public key was generated ?
I had nothing to do for that and i am wondering when this operation was done.

My second question is: I know this is not a good practice but if i only know my private/public key in clear format (not encrypted): Is there a way for me to "import" this public/private key into my bitcoin wallet.
In other words, can i say if i know my public/private key, i know everything.

Thanks

**Tags:** wallet


---

## 1 answers

### Answer by username_1 on 2019-08-23. Score: 1 | Accepted answer

Welcome to the Bitcoin world.

> My first question is: When and How my private/public key was generated?

Your public key is calculated by your private key.

Where your private key is a randomly chosen number, so let's suppose that now we choose k value as your private key, from this we can apply a unidirectional cryptographic function, ie from the private key I can ALWAYS get my public key but it is impossible to contrary (unless expensive brute force attacks, where the game is not worth the candle)
This hash function is an elliptic curve function, I leave you the reference to a [bitcoin book](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch04.asciidoc).

So I have my private key K where I apply my asymmetric encryption algorithm and get the public key.

```
P = hash_fun (K);

```

> My second question is: I know this is not a good practice but if i only know my private/public key in clear format (not encrypted): Is there a way for me to "import" this public/private key into my bitcoin wallet. In other words, can i say if i know my public/private key, i know everything.

Yes, the wallet is formed by the pair (private key, public key) many wallets keep the whole pair but it is possible to get the public key whenever you want, if you know the private key, but not vice versa.

So your private K key is your wallet, or rather what makes your wallet alive

> **Comments:**
> **username_0**: Thanks a lot for your answer. Can you tell me what is the syntax or command that can import a private key into bitcoind ?  
> **username_1**: this is a good [reference](https://en.bitcoin.it/wiki/How_to_import_private_keys) I have never done such a thing, but I once read this reference, that **users should never import (or export) private keys**  

---

