---
title: "Key Stretching — definition | Nuri Glossary"
description: "Deliberately expensive hashing to make brute-force guessing of a passphrase impractical."
lang: "en"
type: "glossary-term"
canonical: "https://nuri.com/glossary/key-stretching"
---

# Key Stretching

Deliberately expensive hashing to make brute-force guessing of a passphrase impractical.

## Basically

Key stretching makes a weak password or passphrase harder to crack. It repeats slow calculations so that every guessed password takes more work.

## Key Takeaways

- Key stretching turns low-entropy inputs such as passwords into high-strength cryptographic keys by making derivation deliberately slow and computationally expensive, which defends against brute-force attacks.
- Bitcoin uses key stretching in BIP-39: when generating a wallet, your seed phrase goes through 2,048 rounds of PBKDF2-HMAC-SHA512 to produce the master seed that derives all your keys.
- The four major key stretching algorithms are PBKDF2, bcrypt, scrypt, and Argon2, each with different trade-offs between CPU cost, memory hardness, and resistance to hardware-accelerated attacks.

## What Is Key Stretching?

Key stretching takes a weak or low-entropy input, such as a password or passphrase, and turns it into a longer, stronger cryptographic key through a computationally expensive function. The idea is simple: if deriving a key takes 100 milliseconds instead of 1 microsecond, an attacker trying billions of password guesses becomes 100,000 times slower.
People often choose passwords with far less randomness, or entropy, than cryptographic systems require. A typical 8-character password might have around 40 bits of entropy, while a secure private key needs 128 or 256 bits. Key stretching bridges this gap without adding entropy by making each guess so expensive that brute-forcing the limited keyspace becomes impractical.
Bitcoin wallets use key stretching during wallet generation. The BIP-39 standard uses PBKDF2 to convert a mnemonic phrase into the master seed behind an entire HD wallet hierarchy.

## How It Works

Key stretching functions repeatedly apply a hash function or cipher to the input, feeding each round's output into the next. This sequential computation has no shortcut. An attacker must perform every round to verify a single password guess.
The general process follows these steps. Each password guess must pass through every round before it produces a derived key.
The salt prevents precomputed attacks using rainbow tables, so two users with the same password but different salts get entirely different derived keys. The iteration count is the main tuning control: higher counts mean more security but slower derivation.

## BIP-39 Seed Derivation

The most prominent use of key stretching in Bitcoin is BIP-39 mnemonic seed generation. A wallet uses the following PBKDF2 configuration when it converts your 12- or 24-word seed phrase into a master seed:
The mnemonic sentence serves as the password input, and the string "mnemonic" joined with the optional passphrase serves as the salt. Both are normalised to UTF-8 NFKD before derivation. The resulting 512-bit output becomes the master seed used by BIP-32 to derive the entire wallet key hierarchy.
The 2,048 iteration count balances added resistance to brute-force attacks on the mnemonic against acceptable wallet loading times on mobile devices. Each attacker guess requires 2,048 HMAC-SHA512 operations. These operations multiply the cost of an exhaustive search.

## Key Stretching Algorithms

Four algorithms dominate key stretching, each designed for different threat models as hardware has evolved. They are PBKDF2, bcrypt, scrypt, and Argon2.

## PBKDF2

PBKDF2 (Password-Based Key Derivation Function 2), defined in RFC 8018, is the oldest widely used key stretching algorithm. It applies a pseudorandom function, usually HMAC-SHA1 or HMAC-SHA512, for a configurable number of iterations. PBKDF2 is CPU-bound only and needs minimal memory, which makes it vulnerable to GPU and ASIC-based attacks that run many instances in parallel.
PBKDF2 remains widely deployed despite this limitation. BIP-39 uses PBKDF2-HMAC-SHA512 with 2,048 iterations. The WPA2 Wi-Fi protocol uses PBKDF2-HMAC-SHA1 with 4,096 iterations.

## bcrypt

bcrypt was designed in 1999 by Niels Provos and David Mazières and is based on the Blowfish cipher. It uses a logarithmic cost factor, typically 10 to 14 for 2^n rounds, and 4 KB of memory during computation. Built-in salt handling and a fixed output format made bcrypt the default choice for web application password storage for over a decade, but its modest memory requirement offers limited protection against modern GPU attacks.

## scrypt

scrypt was created in 2009 by Colin Percival and introduced memory-hard key derivation. It needs large amounts of RAM during computation, making parallel attacks on GPUs and ASICs much more expensive because these devices have abundant compute cores but limited per-core memory. scrypt has three parameters: N (CPU/memory cost), r (block size), and p (parallelisation factor), and the Litecoin cryptocurrency uses scrypt as its proof-of-work function.

## Argon2

Argon2 was designed by Alex Biryukov, Daniel Dinu, and Dmitry Khovratovich and won the Password Hashing Competition in 2015. It represents the current state of the art and comes in three variants:
Argon2 has three parameters: memory cost in kibibytes, time cost as an iteration count, and parallelism degree as a number of threads. OWASP recommends Argon2id with a minimum of 19 MiB of memory, 2 iterations, and 1 degree of parallelism as a baseline configuration.

## Why It Matters for Bitcoin

Key stretching adds a quiet layer of security to Bitcoin wallets. It protects you every time you create or restore a wallet from a seed phrase.
A 12-word BIP-39 mnemonic encodes 128 bits of entropy, giving 2^128 possibilities and making direct brute force infeasible. The 2,048 rounds of PBKDF2 provide an additional safety margin. If an attacker finds a partial mnemonic or targets mnemonics with lower effective entropy because of implementation bugs or constrained word lists, key stretching multiplies the cost of each guess by 2,048x.
The optional BIP-39 passphrase, sometimes called the "25th word", benefits even more from key stretching because user-chosen strings can have low entropy. A passphrase like "bitcoin" would be trivially guessable without key stretching. PBKDF2 rounds make dictionary attacks against weak passphrases much more expensive, though they cannot fully compensate for a truly weak passphrase.
Wallet developers building on Bitcoin infrastructure need to understand key stretching to make informed choices about key derivation parameters and security trade-offs. Solutions like Spark abstract much of this complexity, but the underlying cryptographic primitives remain foundational to self-custody security.

## Wallet Seed Generation

The primary cryptocurrency use case converts BIP-39 mnemonics into master seeds. Every HD wallet that supports BIP-39 recovery phrases uses PBKDF2 key stretching during wallet creation and restoration. This includes hardware wallets, mobile wallets, and desktop software.

## Encrypted Wallet Files

Wallet software that stores keys in encrypted files uses key stretching to derive the encryption key from your password. Bitcoin Core, for example, encrypts its wallet database with a key derived from your passphrase. Without key stretching, a weak password would leave the encrypted file open to rapid offline cracking.

## Password-Protected Backups

Any system that encrypts sensitive data with a user-chosen password benefits from key stretching. Examples include encrypted channel backups, password-protected key exports, and encrypted seed phrase storage solutions.

## Server-Side Authentication

Cryptocurrency exchanges and custodial services use key stretching algorithms, typically bcrypt or Argon2id, to hash user passwords for account authentication. If a database is breached, the key-stretched hashes resist offline cracking far better than plain SHA-256 hashes.

## Security vs. User Experience

More iterations mean stronger security but slower key derivation. BIP-39's 2,048 PBKDF2 rounds add roughly 50 to 200 milliseconds on modern hardware, which is noticeable but acceptable for a one-time wallet loading operation. Password-checking systems that run key stretching on every login must balance security against the delay users notice.
Resource-constrained devices such as older smartphones or hardware wallets can take several seconds even for 2,048 rounds of PBKDF2. Memory-hard algorithms like scrypt and Argon2 add to this challenge because they need significant RAM allocations that may exceed the available memory on embedded devices.

## PBKDF2 Limitations

PBKDF2 is CPU-bound and uses negligible memory, making it vulnerable to massively parallel attacks, and modern GPUs can compute billions of PBKDF2-HMAC-SHA512 operations per second. Argon2id is generally preferred for new applications because its memory hardness makes GPU and ASIC attacks orders of magnitude more expensive. BIP-39's use of PBKDF2 reflects the standard's age from 2013, so its security relies primarily on the high entropy of the mnemonic itself rather than on key stretching alone.

## Parameter Selection

Key stretching parameters must account for future hardware capabilities. Parameters that are secure today may become insufficient as GPUs and ASICs improve, so applications should regularly reassess iteration counts and consider moving to memory-hard algorithms. A common guideline targets roughly 100 milliseconds of computation on current hardware for interactive logins and up to 1 second for high-value key derivation operations.

## Not a Substitute for Entropy

Key stretching slows attackers but cannot compensate for truly weak inputs. A 4-digit PIN has only ~13 bits of entropy, so even millions of PBKDF2 rounds cannot stop modern hardware exhausting the entire keyspace in seconds. Key stretching works best when the input already has moderate entropy of 40+ bits and stretching makes exhaustive search impractical within a useful timeframe; for cryptographic applications, pair it with adequately random inputs like full-length BIP-39 mnemonics.
The research article on Bitcoin wallet recovery methods gives a deeper look at how mnemonic phrases and key derivation fit into Bitcoin wallet architecture. You can read it for more detail on wallet recovery.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. You should always do your own research before using any protocol or technology.
Part of the [Nuri glossary](https://nuri.com/glossary), which defines 1876 Bitcoin, Lightning, wallet, stablecoin and payment terms.
