0

I am learning about BitCoin private keys and trying to figure out what the best way to use them are. I get their purpose and that they need a strong password, etc. But what I don't understand in particular is how they relate to transactions and wallets.

I just ran bitcoin-cli importprivkey <key> (which has been running for like 5 minutes, who knows how long this will take, and I am brand new). I am actually not sure what the point is for adding the key to the wallet. Does it somehow relate to transactions? Why do I need to add a private key to my wallet? Can/should I add more than one to a wallet? Or, oh! I think I remember, the wallet key is just for storing your private keys. But why don't I just store it myself in a different way? What advantage does having it stored in a wallet offer?

Then the second part of the question is, what key I should be signing my transactions with, and how. Can I say "wallet, give me a key by name" or something?

Final part of the question is, how many keys I should have. Should I just have 1 key for everything? 2 just to switch it up every now and then? 10 or 100 or 1000? A new key for every transaction? I don't know, what is the ideal here? Is it best to use some keys for one thing, and others for another?

  • 2
    Based on the questions you’ve asked recently, I suggest you don’t try to build systems that handle other peoples money. – Anonymous Oct 28 '19 at 14:34
1

But what I don't understand in particular is how they relate to transactions and wallets.

This requires a long answer. Here's a nice intro which should answer this.

I am actually not sure what the point is for adding the key to the wallet. Does it somehow relate to transactions? Why do I need to add a private key to my wallet?

If you read the above intro to cryptography in Bitcoin, this question is almost fully answered. You need a private key because that's the secret half you use to sign transactions. Otherwise people could spend your Bitcoins.

Can/should I add more than one to a wallet? Or, oh! I think I remember, the wallet key is just for storing your private keys. But why don't I just store it myself in a different way? What advantage does having it stored in a wallet offer?

Yes you should create many. In fact, one private key for each transaction is ideal. You can store these keys anywhere you want, but a wallet program will do many nice things for you. The wallet keeps track of how much Bitcoin you have, it gives you an easy way to sign TX's and send them to the network, it groups all your received transactions and allows you to combine their amounts to form new transactions and so on. A profesionally developed wallet will also normally employ good security practices. But nothing's stopping you from rolling your own key store.

Then the second part of the question is, what key I should be signing my transactions with, and how. Can I say "wallet, give me a key by name" or something?

Bitcoin Core and other wallets offer a database management system to manage your keys for you. Yes you can usually give them mnemonic names or start typing a prefix and the wallet software suggests the rest. You should sign your TX's with a key you've never used before. That's the general rule.

Final part of the question is, how many keys I should have.

One key per transaction. Never reuse keys.

| improve this answer | |
1

I get their purpose and that they need a strong password, etc. But what I don't understand in particular is how they relate to transactions and wallets.

The purpose of the private key is to decrypt. An example in asymmetric cryptography a.k.a. public key cryptography, you have a shared(public) key, and the private key that can decrypt some scrambled data, let's say a message. A public key cannot reverse solve for a private key, but a private key can derive the public key. The only way to decrypt the message is by having the private key. Bitcoin is similar, one type of bitcoin transaction is Pay-to-Public-Key-Hash (P2PKH). Value/data locked inside these types of addresses require the spender to provide the public key and a cryptographic signature (hash) using the private key to that public key. The signature proves that the spender has the private key without the spender ever having to reveal the private key.

| improve this answer | |
  • This is technically correct, but mostly unrelated to bitcoin - Bitcoin does not use any encryption/decryption at a protocol level – Raghav Sood Oct 29 '19 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.