Wallets — Bitcoin (2024)

Bitcoin wallets at their core are a collection of private keys. These collections are stored digitally in a file, or can even be physically stored on pieces of paper.

Private Key Formats

Private keys are what are used to unlock satoshis from a particular address. In Bitcoin, a private key in standard format is simply a 256-bit number, between the values:

0x01 and 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4140, representing nearly the entire range of 2256-1 values. The range is governed by the secp256k1 ECDSA encryption standard used by Bitcoin.

Wallet Import Format (WIF)

In order to make copying of private keys less prone to error, Wallet Import Format may be utilized. WIF uses base58Check encoding on a private key, greatly decreasing the chance of copying error, much like standard Bitcoin addresses.

  1. Take a private key.

  2. Add a 0x80 byte in front of it for mainnet addresses or 0xef for testnet addresses.

  3. Append a 0x01 byte after it if it should be used with compressed public keys (described in a later subsection). Nothing is appended if it is used with uncompressed public keys.

  4. Perform a SHA-256 hash on the extended key.

  5. Perform a SHA-256 hash on result of SHA-256 hash.

  6. Take the first four bytes of the second SHA-256 hash; this is the checksum.

  7. Add the four checksum bytes from point 5 at the end of the extended key from point 2.

  8. Convert the result from a byte string into a Base58 string using Base58Check encoding.

The process is easily reversible, using the Base58 decoding function, and removing the padding.

Mini Private Key Format

Mini private key format is a method for encoding a private key in under 30 characters, enabling keys to be embedded in a small physical space, such as physical bitcoin tokens, and more damage-resistant QR codes.

  1. The first character of mini keys is ‘S’.

  2. In order to determine if a mini private key is well-formatted, a question mark is added to the private key.

  3. The SHA256 hash is calculated. If the first byte produced is a `00’, it is well-formatted. This key restriction acts as a typo-checking mechanism. A user brute forces the process using random numbers until a well-formatted mini private key is produced.

  4. In order to derive the full private key, the user simply takes a single SHA256 hash of the original mini private key. This process is one-way: it is intractable to compute the mini private key format from the derived key.

Many implementations disallow the character ‘1’ in the mini private key due to its visual similarity to ‘l’.

Resource: A common tool to create and redeem these keys is the Casascius Bitcoin Address Utility.

Public Key Formats

Bitcoin ECDSA public keys represent a point on a particular Elliptic Curve (EC) defined in secp256k1. In their traditional uncompressed form, public keys contain an identification byte, a 32-byte X coordinate, and a 32-byte Y coordinate. The extremely simplified illustration below shows such a point on the elliptic curve used by Bitcoin, y2=x3+7, over a field of contiguous numbers.

Wallets — Bitcoin (1)

Point On ECDSA Curve

(Secp256k1 actually modulos coordinates by a large prime, which produces a field of non-contiguous integers and a significantly less clear plot, although the principles are the same.)

An almost 50% reduction in public key size can be realized without changing any fundamentals by dropping the Y coordinate. This is possible because only two points along the curve share any particular X coordinate, so the 32-byte Y coordinate can be replaced with a single bit indicating whether the point is on what appears in the illustration as the “top” side or the “bottom” side.

No data is lost by creating these compressed public keys—only a small amount of CPU is necessary to reconstruct the Y coordinate and access the uncompressed public key. Both uncompressed and compressed public keys are described in official secp256k1 documentation and supported by default in the widely-used OpenSSL library.

Because they’re easy to use, and because they reduce almost by half the block chain space used to store public keys for every spent output, compressed public keys are the default in Bitcoin Core and are the recommended default for all Bitcoin software.

However, Bitcoin Core prior to 0.6 used uncompressed keys. This creates a few complications, as the hashed form of an uncompressed key is different than the hashed form of a compressed key, so the same key works with two different P2PKH addresses. This also means that the key must be submitted in the correct format in the signature script so it matches the hash in the previous output’s pubkey script.

For this reason, Bitcoin Core uses several different identifier bytes to help programs identify how keys should be used:

  • Private keys meant to be used with compressed public keys have 0x01 appended to them before being Base-58 encoded. (See the private key encoding section above.)

  • Uncompressed public keys start with 0x04; compressed public keys begin with 0x03 or 0x02 depending on whether they’re greater or less than the midpoint of the curve. These prefix bytes are all used in official secp256k1 documentation.

Hierarchical Deterministic Key Creation

The hierarchical deterministic key creation and transfer protocol (HD protocol) greatly simplifies wallet backups, eliminates the need for repeated communication between multiple programs using the same wallet, permits creation of child accounts which can operate independently, gives each parent account the ability to monitor or control its children even if the child account is compromised, and divides each account into full-access and restricted-access parts so untrusted users or programs can be allowed to receive or monitor payments without being able to spend them.

The HD protocol takes advantage of the ECDSA public key creation function, “point()”, which takes a large integer (the private key) and turns it into a graph point (the public key):

point(private_key) == public_key

Because of the way “point()” works, it’s possible to create a child public key by combining an existing (parent) public key with another public key created from any integer (i) value. This child public key is the same public key which would be created by the “point()” function if you added the i value to the original (parent) private key and then found the remainder of that sum divided by a global constant used by all Bitcoin software (p):

point( (parent_private_key + i) % p ) == parent_public_key + point(i)

This means that two or more independent programs which agree on a sequence of integers can create a series of unique child key pairs from a single parent key pair without any further communication. Moreover, the program which distributes new public keys for receiving payment can do so without any access to the private keys, allowing the public key distribution program to run on a possibly-insecure platform such as a public web server.

Child public keys can also create their own child public keys (grandchild public keys) by repeating the child key derivation operations:

point( (child_private_key + i) % p ) == child_public_key + point(i)

Whether creating child public keys or further-descended public keys, a predictable sequence of integer values would be no better than using a single public key for all transactions, as anyone who knew one child public key could find all of the other child public keys created from the same parent public key. Instead, a random seed can be used to deterministically generate the sequence of integer values so that the relationship between the child public keys is invisible to anyone without that seed.

The HD protocol uses a single root seed to create a hierarchy of child, grandchild, and other descended keys with unlinkable deterministically-generated integer values. Each child key also gets a deterministically-generated seed from its parent, called a chain code, so the compromising of one chain code doesn’t necessarily compromise the integer sequence for the whole hierarchy, allowing the master chain code to continue being useful even if, for example, a web-based public key distribution program gets hacked.

Wallets — Bitcoin (2)

Overview Of Hierarchical Deterministic Key Derivation

As illustrated above, HD key derivation takes four inputs:

In the normal form shown in the above illustration, the parent chain code, the parent public key, and the index number are fed into a one-way cryptographic hash (HMAC-SHA512) to produce 512 bits of deterministically-generated-but-seemingly-random data. The seemingly-random 256 bits on the righthand side of the hash output are used as a new child chain code. The seemingly-random 256 bits on the lefthand side of the hash output are used as the integer value to be combined with either the parent private key or parent public key to, respectively, create either a child private key or child public key:

child_private_key == (parent_private_key + lefthand_hash_output) % Gchild_public_key == point( (parent_private_key + lefthand_hash_output) % G )child_public_key == point(child_private_key) == parent_public_key + point(lefthand_hash_output)

Specifying different index numbers will create different unlinkable child keys from the same parent keys. Repeating the procedure for the child keys using the child chain code will create unlinkable grandchild keys.

Because creating child keys requires both a key and a chain code, the key and chain code together are called the extended key. An extended private key and its corresponding extended public key have the same chain code. The (top-level parent) master private key and master chain code are derived from random data, as illustrated below.

Wallets — Bitcoin (3)

Creating A Root Extended Key Pair

A root seed is created from either 128 bits, 256 bits, or 512 bits of random data. This root seed of as little as 128 bits is the only data the user needs to backup in order to derive every key created by a particular wallet program using particular settings.

Wallets — Bitcoin (4) Warning: As of this writing, HD wallet programs are not expected to be fully compatible, so users must only use the same HD wallet program with the same HD-related settings for a particular root seed.

The root seed is hashed to create 512 bits of seemingly-random data, from which the master private key and master chain code are created (together, the master extended private key). The master public key is derived from the master private key using “point()”, which, together with the master chain code, is the master extended public key. The master extended keys are functionally equivalent to other extended keys; it is only their location at the top of the hierarchy which makes them special.

Hardened Keys

Hardened extended keys fix a potential problem with normal extended keys. If an attacker gets a normal parent chain code and parent public key, he can brute-force all chain codes deriving from it. If the attacker also obtains a child, grandchild, or further-descended private key, he can use the chain code to generate all of the extended private keys descending from that private key, as shown in the grandchild and great-grandchild generations of the illustration below.

Wallets — Bitcoin (5)

Cross-Generational Key Compromise

Perhaps worse, the attacker can reverse the normal child private key derivation formula and subtract a parent chain code from a child private key to recover the parent private key, as shown in the child and parent generations of the illustration above. This means an attacker who acquires an extended public key and any private key descended from it can recover that public key’s private key and all keys descended from it.

For this reason, the chain code part of an extended public key should be better secured than standard public keys and users should be advised against exporting even non-extended private keys to possibly-untrustworthy environments.

This can be fixed, with some tradeoffs, by replacing the normal key derivation formula with a hardened key derivation formula.

The normal key derivation formula, described in the section above, combines together the index number, the parent chain code, and the parent public key to create the child chain code and the integer value which is combined with the parent private key to create the child private key.

Wallets — Bitcoin (6)

Creating Child Public Keys From An Extended Private Key

The hardened formula, illustrated above, combines together the index number, the parent chain code, and the parent private key to create the data used to generate the child chain code and child private key. This formula makes it impossible to create child public keys without knowing the parent private key. In other words, parent extended public keys can’t create hardened child public keys.

Because of that, a hardened extended private key is much less useful than a normal extended private key—however, hardened extended private keys create a firewall through which multi-level key derivation compromises cannot happen. Because hardened child extended public keys cannot generate grandchild chain codes on their own, the compromise of a parent extended public key cannot be combined with the compromise of a grandchild private key to create great-grandchild extended private keys.

The HD protocol uses different index numbers to indicate whether a normal or hardened key should be generated. Index numbers from 0x00 to 0x7fffffff (0 to 231-1) will generate a normal key; index numbers from 0x80000000 to 0xffffffff will generate a hardened key. To make descriptions easy, many developers use the prime symbol to indicate hardened keys, so the first normal key (0x00) is 0 and the first hardened key (0x80000000) is 0´.

(Bitcoin developers typically use the ASCII apostrophe rather than the unicode prime symbol, a convention we will henceforth follow.)

This compact description is further combined with slashes prefixed by m or M to indicate hierarchy and key type, with m being a private key and M being a public key. For example, m/0’/0/122’ refers to the 123rd hardened private child (by index number) of the first normal child (by index) of the first hardened child (by index) of the master private key. The following hierarchy illustrates prime notation and hardened key firewalls.

Wallets — Bitcoin (7)

Example HD Wallet Tree Using Prime Notation

Wallets following the BIP32 HD protocol only create hardened children of the master private key (m) to prevent a compromised child key from compromising the master key. As there are no normal children for the master keys, the master public key is not used in HD wallets. All other keys can have normal children, so the corresponding extended public keys may be used instead.

The HD protocol also describes a serialization format for extended public keys and extended private keys. For details, please see the wallet section in the developer reference or BIP32 for the full HD protocol specification.

Storing Root Seeds

Root seeds in the HD protocol are 128, 256, or 512 bits of random data which must be backed up precisely. To make it more convenient to use non-digital backup methods, such as memorization or hand-copying, BIP39 defines a method for creating a 512-bit root seed from a pseudo-sentence (mnemonic) of common natural-language words which was itself created from 128 to 256 bits of entropy and optionally protected by a password.

The number of words generated correlates to the amount of entropy used:

Entropy Bits

Words

128

12

160

15

192

18

224

21

256

24

The passphrase can be of any length. It is simply appended to the mnemonic pseudo-sentence, and then both the mnemonic and password are hashed 2,048 times using HMAC-SHA512, resulting in a seemingly-random 512-bit seed. Because any input to the hash function creates a seemingly-random 512-bit seed, there is no fundamental way to prove the user entered the correct password, possibly allowing the user to protect a seed even when under duress.

For implementation details, please see BIP39.

Loose-Key Wallets

Loose-Key wallets, also called “Just a Bunch Of Keys (JBOK)”, are a deprecated form of wallet that originated from the Bitcoin Core client wallet. The Bitcoin Core client wallet would create 100 private key/public key pairs automatically via a Pseudo-Random-Number Generator (PRNG) for later use.

These unused private keys are stored in a virtual “key pool”, with new keys being generated whenever a previously-generated key was used, ensuring the pool maintained 100 unused keys. (If the wallet is encrypted, new keys are only generated while the wallet is unlocked.)

This created considerable difficulty in backing up one’s keys, considering backups have to be run manually to save the newly-generated private keys. If a new key pair set is generated, used, and then lost prior to a backup, the stored satoshis are likely lost forever. Many older-style mobile wallets followed a similar format, but only generated a new private key upon user demand.

This wallet type is being actively phased out and discouraged from being used due to the backup hassle.

Wallets — Bitcoin (2024)

FAQs

Which Bitcoin wallet is best? ›

Best Bitcoin Wallets
  • Exodus: Best Overall.
  • BitBox02: Best for Bitcoin-Only Storage.
  • Electrum: Best for Desktop.
  • BlueWallet: Best for Mobile.
  • Crypto.com Wallet: Best DeFi Wallet.
  • Coinbase Wallet: Best for Beginners.
Aug 28, 2024

Is there a free Bitcoin wallet? ›

Create a Bitcoin wallet in seconds with the free-to-use Bitcoin.com Wallet app.

What is the safest and most secure Bitcoin wallet? ›

Summary. Ledger is one of the most popular and reliable hardware wallets on the market. It offers the highest level of security, supports multiple cryptocurrencies, and has a user-friendly interface. However, Ledger is a relatively expensive wallet, and you need to connect it to a computer or smartphone for use.

What is the best online wallet to store Bitcoin? ›

  • Zengo Wallet: 4.8 out of 5 stars.
  • Crypto.com DeFi Wallet: 4.8 out of 5 stars.
  • Guarda: 4.6 out of 5 stars.
  • Exodus: 4.5 out of 5 stars.
  • Coinbase Wallet: 4.4 out of 5 stars.
  • Trust Wallet: 4.3 out of 5 stars.
  • MetaMask: 4.0 out of 5 stars.
  • Ledger: 5.0 out of 5 stars.
Jun 13, 2024

Is Bitcoin wallet safe? ›

Bitcoin Storage

The public key is used to encrypt information and is your wallet address, and the private key allows you to decrypt the information, or access your bitcoin. This is the key you're storing and safeguarding. Your bitcoin ownership is safely recorded, stored, validated, and encrypted on the blockchain.

Where is the best place to keep Bitcoin? ›

The answer to the question “what is the safest way to store crypto” is a self-custody cold storage wallet. As covered earlier, options include hardware wallets and paper wallets. But that's not to say that holding 100% of funds in cold storage is right for everyone.

Why can't I withdraw money from Coinbase Wallet? ›

Funds on hold

When you use a linked bank account (ACH) to buy crypto or add cash to your account balance, the funds are placed on hold and won't be immediately available to send or cash out. Think of this like depositing a check to your bank account and having to wait for it to clear before you can remove the funds.

What is the easiest safest crypto wallet? ›

For beginners, the top user-friendly wallets are Bitget wallet, and Coinbase Wallet. These options offer strong security features, a user-friendly interface, and good customer support. If you're looking for cold storage, consider Ledger or Trezor Wallet.

Which crypto wallet can withdraw to a bank account? ›

To transfer crypto to a bank account, you can use centralized crypto wallets to sell crypto for fiat money and withdraw them to your bank account. Some popular crypto wallets that enable this functionality are Coinbase, Binance, Crypto.com, Kraken, and swissmoney.

What is the safest hardware wallet bitcoin? ›

Crypto securitymade easy. Securely store, manage, and protect your coins with Trezor hardware wallets, app & backup solutions.

What is the best platform to keep bitcoin? ›

Best Crypto Exchanges and Apps for September 2024
  • Best for Low Fees and Best for Experienced Traders: Kraken.
  • Best for Beginners: Coinbase.
  • Best Mobile App: Crypto.com.
  • Best For Security: Gemini.
  • Best for Altcoins: BitMart.
  • Best for Bitcoin: Cash App.
  • Best Decentralized Exchange: Bisq.

Which BTC wallet has the lowest fees? ›

Transaction Fees: Trezor wallet has low fees for Bitcoin transactions, with the option to set custom fees based on your preferences. Security: Trezor is a hardware wallet known for its top-notch security features, including PIN protection and passphrase encryption.

What is the safest hardware wallet Bitcoin? ›

Crypto securitymade easy. Securely store, manage, and protect your coins with Trezor hardware wallets, app & backup solutions.

Which Bitcoin platform is best? ›

Best Crypto Exchanges and Apps for September 2024
  • Best for Low Fees and Best for Experienced Traders: Kraken.
  • Best for Beginners: Coinbase.
  • Best Mobile App: Crypto.com.
  • Best For Security: Gemini.
  • Best for Altcoins: BitMart.
  • Best for Bitcoin: Cash App.
  • Best Decentralized Exchange: Bisq.

Top Articles
Americans Consume Much More than They Invest
Lightning Address - Bitcoin Address | Leather
Woodward Avenue (M-1) - Automotive Heritage Trail - National Scenic Byway Foundation
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Forozdz
Weeminuche Smoke Signal
Here are all the MTV VMA winners, even the awards they announced during the ads
Es.cvs.com/Otchs/Devoted
Nordstrom Rack Glendale Photos
Nm Remote Access
Gw2 Legendary Amulet
GAY (and stinky) DOGS [scat] by Entomb
Swimgs Yung Wong Travels Sophie Koch Hits 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Springs Cow Dog Pig Hollywood Studios Beach House Flying Fun Hot Air Balloons, Riding Lessons And Bikes Pack Both Up Away The Alpha Baa Baa Twinkle
Cube Combination Wiki Roblox
Savage X Fenty Wiki
Large storage units
Jessica Renee Johnson Update 2023
Missing 2023 Showtimes Near Landmark Cinemas Peoria
Cincinnati Bearcats roll to 66-13 win over Eastern Kentucky in season-opener
Signs Of a Troubled TIPM
272482061
Crossword Nexus Solver
Mzinchaleft
Roof Top Snipers Unblocked
Craigslist Mt Pleasant Sc
Craigslist Missoula Atv
Blue Rain Lubbock
John Chiv Words Worth
Munis Self Service Brockton
Danielle Ranslow Obituary
O'reilly's In Mathis Texas
Maisons près d'une ville - Štanga - Location de vacances à proximité d'une ville - Štanga | Résultats 201
Paradise Point Animal Hospital With Veterinarians On-The-Go
Autopsy, Grave Rating, and Corpse Guide in Graveyard Keeper
Goodwill Houston Select Stores Photos
Tenant Vs. Occupant: Is There Really A Difference Between Them?
Are you ready for some football? Zag Alum Justin Lange Forges Career in NFL
Streameast.xy2
Telugu Moviez Wap Org
Wrigley Rooftops Promo Code
Uvalde Topic
More News, Rumors and Opinions Tuesday PM 7-9-2024 — Dinar Recaps
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
Silive Obituary
Former Employees
Brauche Hilfe bei AzBilliards - Billard-Aktuell.de
Craigslist Binghamton Cars And Trucks By Owner
Stosh's Kolaches Photos
Dyi Urban Dictionary
Windy Bee Favor
Unpleasant Realities Nyt
Lake County Fl Trash Pickup Schedule
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated:

Views: 6499

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.