You can generate a bitcoin wallet in many different ways, using bitcoin core client or using online wallet services or getting it from hardware wallet manufacturers etc.
What does a bitcoin wallet contains ?
It contains two keys private key, public key and a public address. The private key is used for spending your coins(i.e. signing a transaction) whereas the public key is used in verifying a signed transaction.
As public key is long it is shortened to create a address in a way that it becomes more readable, concise and less error prone while transacting.
So, Address is what you publish in public to receive bitcoins.
Flow Diagram courtesy bitcoin wiki
How bitcoin wallet keys are generated ?
- Generate a random number of length 32 bytes which will be called your private key.(Random number must be truly random or should be generated from cryptographically strong pseudo random number generator)
- Apply ECDSA algorithm on private key derived from previous step to create a public key of length 65 bytes.
P2PKH address is derived from public key ?
- Public key is hashed with
- Hash derived from previous step is hashed again with
- Then, add bytes
00as prefix to the hash derived from previous step.
- Hash received from previous step is again hashed with
SHA256algorithm two times sequentially to take out first four bytes from result as
- Now these
checksumbytes are added as suffix to output of step 3.
- Lastly we encode resultant bytes using Base58 notation to get a Bitcoin Address.