The Basics Of A Bitcoin Public Key and Private Key

By 0xVince | Bitcoin Protocol | 27 May 2023

Most users are already familiar with a digital wallet. The wallet is what holds your keys to your cryptocurrency assets, like Bitcoin. Then you realize that these are important components of owning your Bitcoin.

They grant you control of your own money without a bank. It is empowering to have custody of your own Bitcoin, but that requires due diligence in responsibility. To further understand, let us take a look at the techniques behind it.

Public Key Cryptography

The foundation of cryptocurrency is rooted in public key cryptography. This is a system in which keys are generated, called the private key and public key. This is generated by the wallet software. The private key is created first, and is generated using ECDSA (Elliptic Curve Digital Signature Algorithm).

In Bitcoin, it appears in hexadecimal format and is 256-bits in length. That is 64 characters long and 32 bytes in size. The private key creates a digital signature used to verify the identity of a wallet’s owner (i.e. the user). From the private key a public key is also created.

The public key is also 256-bits long and was mathematically derived from the private key. The public key is used to generate a unique wallet public address. More than one address can be created, but for simplicity let us stick to the concept of one address. This is created from a hash of the public key, which is cryptographically generated using a complex mathematical formula.

Both private key and public key must be unique since there will be conflict on the network regarding who owns Bitcoin if two users have the same keys. They are just strings of numbers that act as a code to provide cryptographic security for the user’s Bitcoin.

It is called “public” since this is the technique used in open networks like Bitcoin. It is available for anyone to use as long as they have a wallet with keys. The purpose of a wallet is to store the keys, not Bitcoin. This is because Bitcoin is just a value that is stored on the blockchain. The private key is what authorizes access to Bitcoin via the wallet.

How Keys Work

The private key is the most important component, since without it you cannot create the public key and public address. The private key is used whenever the user wants to spend Bitcoin. When the user spends their Bitcoin, the private key must authorize the user first.

The wallet uses a mathematical formula that creates the private key, which is actually just a string of numbers and letters. A Bitcoin private key looks like the following (this is not a real private key, just an example):


Without the private key, a user cannot spend their Bitcoin. This is a security check to verify that the one spending the Bitcoin is the actual owner based on a digital signature. Once verified, the Bitcoin is unlocked and can be spent on a transaction.

The public key is the component used to create a Bitcoin address. This is like the address used to receive your e-mail or  delivery package. The public address is what tells an application’s wallet where to send the Bitcoin.

In creating the public address, the public key undergoes what is called a “double-hashing” process. First it is hashed using the SHA-256 algorithm followed by RIPEMD160 hashing. This results in a 160-bit hash of the original 256-bit public key. It is then encoded in Base58 to shorten the length to result in the public address.

A typical Bitcoin public address has the following format (example taken from BitcoinWiki, do not use):


The address is in a format called Legacy Bitcoin or Pay-to-Public-Key-Hash (P2PKH), which is shortened to 34 characters after Base58 encoding. This is what a user needs in order to receive Bitcoin.

Your Keys, Your Coins

Using public key cryptography is important for use on public networks like Bitcoin. Without keys, data could easily be compromised and there would be no security on the network. Having a private key secures your Bitcoin from other users and verifies your ownership. Think of it like your keys at home. You have a key to your car and to your house. If you don’t have the key, you cannot start your car or enter your house.

As long as you have your private key, you can access your Bitcoin. This is why it is important to understand when holding your own Bitcoin away from a digital exchange. On an exchange you are using a custodial wallet. Your private key is under the exchange and not in your possession. With a personal wallet that is not on an exchange, you have complete control.

You just have to make sure you keep your private key safe. Never reveal it to others and it is probably best to make a backup. It is recommended to store the backup offline inside a thumb drive. You can also use a hardware wallet which provides more security since it is offline and only connects online when accessing your Bitcoin.

You cannot replace your private key once it is lost. There can only be one unique private key. It is best to have a backup of it. A private key should not be shared with a third party or other user, since they can gain access to your Bitcoin. Third party should never have access to your private key. Give them your public address instead if they want to send you Bitcoin. As long as your keys are safe, your Bitcoin will always be in your hands.


Disclaimer: The content of this article is for reference or informational purposes only. This is not financial advice. Please do your own research always.

How do you rate this article?



Engineer and Developer

Bitcoin Protocol
Bitcoin Protocol

All about the Bitcoin protocol.

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.