damn, i still don't understand the meaning of having public and private key.
could someone explain it with simple sentences?
Private key of A = A can spend the coins
Public key of A = you can get the address and send coins to A.
If you will a public key is (are many) padlock(s), they allow you to lock the coins for someone else without having the key.
The key to unlock the coins is the private key. There can be several copies of the same private key but thats not wise. Thats why its so important to take care of your wallet. It has your private keys.
so for example i buying pizza, and i pay them using private key?
and if i'm the seller i give them my public key?
Unfortunately, some people use the words "public key" to mean "bitcoin address".
A public key is NOT a bitcoin address (even though many confused people will tell you that it is).
You typically will never see and never know your public key. The public key is used by the bitcoin protocol to verify digital signatures.
If you are buying a pizza, you will use bitcoin wallet software to create a bitcoin transaction that "sends the bitcoins to the pizza seller".
The bitcoin software will handle all the technical details for you.
If you want to know about those technical details:
The bitcoin wallet software will choose enough unspent outputs that you have received in the past so that the sum of the value is more than the amount you are "sending to the pizza seller". These will all be listed in the transaction as "inputs".
Then the bitcoin wallet software will create a new output that assigns the desired value to the pizza merchant's bitcoin address, and a second output that assigns any extra amount from the sum of the inputs to an address in the bitcoin wallet.
The protocol requires digital signatures for each of those inputs proving that you have authorization to spend them. The wallet uses the private keys to compute ECDSA digital signatures. This is the mechanism that prevents other people from spending, or stealing your bitcoins. Since they don't know your private keys, they are unable to generate the proper digital signatures, and the rest of the network just ignores any transaction that anyone else tries to create that would spend your bitcoins. Of course, if a hacker can gain access to your private keys, then they can load them into wallet software of their own, and spend your bitcoins.
There is a mathematical relaitionship between the private key and the bitcoins address, but if only works in one direction. If you know the private key, then you can compute the bitcoin address. If you know the bitcoin address, it is impossible to compute the private key. This means it is safe to give your bitcoin address to people (so they can send you bitcoins), since they can't figure out your private key.
The digital signature is also mathematically computed. The particular mathematical relationship means that a signature can be verified without the private key as long as you have the public key. Bitcoin includes the public key with the signature. That way the entire network can verify the signature with the public key, and then can make sure that hashing the public key results in the correct bitcoin address.