I want to clarify this -- and keep in mind that I have only used online wallets. Are you saying the public key is used for spending bitcoins (I thought it was the private key)?
We are getting into some technical details here, but...
There aren't actually any addresses in the blockchain or in transactions. There is a 160 bit hash of the public key. The concept of an "address" is something that wallets and services use to to communicate with us humans. By entering an address we tell the wallet what type of script to create in the transaction output with the hash (P2PKH, P2SH, etc).
Then later when you want to spend that transaction output, the wallet uses the information that it knows (the private and public key) to provide an appropriate input script. With the type of address you're probably most familiar with seeing (the version 0 addresses that start with a "1") this would mean supplying a digital signature of the transaction (calculated using the private key and the Secp256k1 ECDSA curve) AND the public key.
Every node that verifies the transaction would then be checking on two things:
1. The provided public key hashes to the exact value that was provided in the output.
2. The signature provided can be validated using that given public key.
Frankly, I never saw any public keys or private keys.
The typical user never should. The purpose of wallet software is to manage all the technical details for you and make it easy to secure your private keys.
Apparently, coinbase keeps the customers wallet private keys secret -- so that coinbase can take advantage of their cold storage.
I know Coinbase likes to call their service a "wallet", but in reality that is a bit misleading.
Typically, with bitcoin, a wallet is a collection of one or more private keys (for example "paper wallets"). Most software wallets additionally include interfaces to provide you with:
- Bitcoin addresses that are associated with those private keys
- An easy way to build transactions using bitcoin addresses
- The sum of all the value you have control over
- Information about transactions that transfer control over value to private keys the wallet software knows about
- An easy way to secure your private keys with encryption and to create backups of them
- The ability to sign other messages with those private keys
The most important thing about a wallet though is that you have exclusive control over your private keys (typically stored in a file on your computer/phone/etc). Much like a physical leather wallet in your back pocket where you have exclusive control over the dollar bills you put into it.
What Coinbase provides is more like a bank account. You give your bitcoins to them (or have others give bitcoins to them on your behalf). In exchange, they give you a promise that they will send an equivalent amount of THEIR bitcoins wherever you ask whenever you ask. They keep track of your "balance" in their own database. If one Coinbase user sends to another Coinbase user, no actual bitcoins ever move (since Coinbase already has the bitcoins and private keys). Instead, they just reduce the "balance" in their database for one user and increase the "balance" in their database for the other user.
You have to decide for yourself if you trust Coinbase to ALWAYS be able live up to their promise to send THEIR bitcoins on your behalf. You are trusting them to secure the private keys properly (from both external and internal threats), to create adequate backups of those keys, and to say NO to any government entity that may ask them to turn over control.
That being said. The reason you never see your private keys with Coinbase is because you don't have any. Coinbase has private keys for THEIR bitcoins, and you have an entry in their database that keeps track or their promise to you.
Is a version 0 address the common type we see today?
Yes. The addresses that you see that start with a "1" are all "version 0 addresses" (also known as P2PKH, or Pay-to-public-key-hash)
You may also hear others call these "version 1" addresses since they are the first "address" type that was common in bitcoin AND they start with a "1". I typically call it a "version 0" address because the character "1" in base58 represents the "nothing" value (there is no zero character in base 58), and the first byte in the address is
literally the "version byte". Therefore the address
literally has a value of 00000000 in binary.
What is the version of the other common bitcoin address?
The other type of address is generally called "version 2" (also known as P2SH, or Pay-to-script-hash). This type of address starts with a "3". They are commonly used for multi-sig outputs.
This is the second address type that became common in bitcoin. Additionally in base58 (because of the lack of a zero) all of the other single digit values are represented by a character that is off by 1 position from what you are familiar with in other bases, so the value of 2 is represented by a character of "3".
There are a few other common output types that don't have a standard "address" representation (such as Pay-to-public-key AKA P2PK, and native multi-sig)
The additional reason I confused myself is because I noticed my address for receiving bitcoins would sometimes change for my online wallet.
While Coinbase will give you a new address to use to have bitcoins credited to your account, the old addresses don't stop working. Even after they've given you a new address, you can continue to receive bitcoins at your old addresses.
For privacy and slightly increased security it is generally advised that you only use each address (and therefore each public key) only once
This must explain why coinbase generates a new address on my wallet for every transaction.
Exactly.
Does my coinbase wallet account use several private keys? because coinbase generates a new address for every transaction.
Coinbase has thousands (millions?) of addresses and private keys. In their database they associate some of those with your account so that when they receive any transactions that are associated with those addresses they update the database entry. Then they typically immediately transfer that value to a more secure address in their "vault". Yes, for each address that they manage, they have a unique private key.
You lost me on that last statement. Why is only 1 public key known to be associated with a Bitcoin address, when technically there are many associated public keys?
It is extremely fast and easy for a computer to start with a public key and calculate the associated address. It is also extremely fast and easy for a computer to start with a private key and and calculate the associated public key.
Therefore, wallet software generates a random private key, then calculates the one associated public key, then calculates the ONLY compressed key P2PKH address that is associated with that public key. Eventually when the bitcoins received with that address are spent the wallet published that ONE known public key to the blockchain along with the signature. As such, the whole world knows that ONE public key is associated with THAT ONE address.
There is no known way to do the process backwards. If you ONLY have a P2PKH address (or the associated 160 bit hash value), there is NO KNOWN WAY to calculate ANY of the public keys that would have resulted in that value. As such, nobody ever knows any of the other public keys that could have resulted in the same address.