thanks everybody who will respond. I go straight to the points. I'm just learning, so please correct or enlighten me:
You should read The Whitepaper and browse the wiki to learn the basics of bitcoin before acquiring any significant amount.
I will try to explain in simple terms how the system works:
The backbone of bitcoin is the blockchain, it is a series of blocks of data, each one is tacked on to the previous one in a way that ensures no block can be changed without changing all the following blocks. To create a block, it is necessary to solve a very difficult cryptographic puzzle, there is no known faster way to solve it than brute force (this is what miners do), and the solution is invalidated by any change in the block. This makes it very difficult to fork the chain and overcome the end most miners are building.
Those blocks of data contain transactions, each transaction must be valid for the block to be accepted by the network.
Each transaction has inputs and outputs, inputs are links to previous transactions, and outputs link to future transactions, in particular, each input must link to an output of a previous transaction, and each output must link to at most one input.
Each input and output has a value associated with it, denominated in
BTC, in almost every transaction, the sum of the outputs cannot exceed the sum of the inputs, the only exception to that is the coinbase transaction of each block, the other rule, is that in each block, the total of the outputs must not exceed the total of the inputs plus the block reward, which itself halves every 210000 blocks.
The rules state previously enforce a conservation law on bitcoin (prevents anyone from freely creating coins), but a currency also needs authentication (prevents anyone from spending coins they do not own), and this is where addresses and keys come in.
When coins are sent to you, the output includes an address, the public part of a keypair that you created with a wallet program.
When you send coins, you are creating a transaction with an input that links to the output of a previous transaction sent to you.
For the transaction to be valid, you must digitally sign it with the private key that corresponds to the address specified in the output.
You need the private key to create this signature, but it can be verified by checking it against the address that corresponds to the key.
Once you broadcast this transaction, the nodes relay it to miners, and they include it in a block, setting it in stone and allowing its outputs to be spent.
1) a bitcoin consist of a public and private key. Public key (usually starting with 1) is an address, safe to distribute to receive payments etc ... (if you don't mind privacy). Private key (starting with 5) is what makes the bitcoin (so to speak), and need to be kept secret. If I have bitcoins e.g., on coinbase.com and I want to store them safely e.g. on my laptop or or a piece of paper, how do I do that? Can I see my private key (or keys) and handwrite it on a piece of paper? (I know it's a silly idea, because of typo and mistakes, but just talking hypothetically).
Instructions on paper wallet (wait until someone else confirms them before using them, in general, do not do anything with valuable simply because one anonymous stranger told you to):
https://bitcointalk.org/index.php?topic=1559277.msg17075677#msg17075677Yes, you can write it if you want.
2) I read about hardware wallets, which generate private keys offline. How can a wallet generate a private key? Isn't the private key the bitcoin itself?. What am I missing here?
Bitcoins are not actually contained within a wallet, a bitcoin is not actually a file, a bitcoin is just the unit in which the value of outputs is measured in.
The private keys just give you the ability to spend it, kind of like your bank PIN.
3) 21 million bitcoins will be generated till the end of time. Does that mean 21 million of private keys or what?
No, the total of the values of unspent outputs will tend to 21000000
BTC, there can be fewer or more outputs.
4) how long is a private key? I presume very much to avoid brute force possibility of guessing the right one, but could in principle be e.g. long 5 characters?
256 bits, it is actually a point on an elliptic curve.
5) I have 0.1 bitcoin (which has a private key), and then I get paid 0.02 bitcoin (another private key). Thus I end up having 0.12 bitcoin on my wallet. What's their private key? Or private keys are just code to authorise transactions? Please help me understand this point.
You would have two outputs with seperate private keys.
6) I know bitcoin mining is almost impossible nowadays, if not part of mining pool, or with huge computational resources. But let's keep it simple, and assume we are still back in 2009. I run a mining program on my laptop and generate 100 bitcoins. Can that be done offline, or need to be online to inform the public ledger? Those 100 bitcoins are 100 secret keys? How do I transfer them in a wallet?
You have to be online to mine, when you mine, you provide an address that the coins would be on.
Since in 2009 each block had 50
BTC, you would have two outputs, whether you reuse the same address is up to you.
7) is there a program that run on mac OSX to generate some alternative cryptocurrency (obviously with a value less than a mosquito) and learn how the system works?
You can get some testnet coins at a faucet (testnet is like bitcoin, exept it is meant for experimenting and the coins are nearly worthless).