scrypt - Memory-Hard Key Derivation
About 2 min read
scrypt is a memory-hard password hash function that resists parallel attacks by GPUs and ASICs by consuming large amounts of memory. It was designed by Colin Percival in 2009 for key derivation in the online backup service Tarsnap. Whereas bcrypt is CPU-bound, scrypt demands memory-bound computation, raising the cost of attacks. It is also used as the Proof of Work algorithm of the cryptocurrency Litecoin.
Historical Background
In the late 2000s, general-purpose computing on GPUs (GPGPU) spread rapidly, and brute-force attacks against CPU-bound hash functions like bcrypt became a realistic threat. To address this, Colin Percival designed scrypt around the idea that "if you force the consumption of large amounts of memory in addition to computation, you can reduce the advantage of GPU parallelism." It was adopted for Tarsnap's backup encryption in 2009 and published as the informational RFC 7914 in 2016. When Litecoin, which appeared in 2011, adopted scrypt, it also came into use in the cryptocurrency field.
How the ROMix Algorithm Works
The core of scrypt is an algorithm called ROMix. The processing is broadly divided into two phases.
Generate N pseudo-random blocks from an initial value and store them in a huge array. When N = 2^20 (about 1 million) and r = 8, it consumes about 1 GiB of memory. This array is referenced in the next phase.
Mix the values while referencing random positions in the array N times. Because each reference target depends on the immediately preceding computation result, it cannot be predicted in advance. Reducing memory forces recomputation, which raises the time cost.
This property, where "cutting memory increases the computation time," is the essence of scrypt's memory-hardness. When an attacker tries to save memory to increase parallelism, the computation time per instance grows, so the total attack cost is hard to bring down.
Comparison with Argon2 and bcrypt
| Property | bcrypt | scrypt | Argon2id |
|---|---|---|---|
| Year introduced | 1999 | 2009 | 2015 |
| Memory-hard | ✗ | ✓ | ✓ |
| Side-channel resistance | High | Low (data-dependent access) | High (Argon2id hybrid mode) |
| Parameter intuitiveness | Simple with a single cost | The relationship of N, r, p is complex | Memory, time, and parallelism are independent |
| OWASP recommendation rank | 3rd | 2nd | 1st |
| Adoption in cryptocurrencies | None | Litecoin, Dogecoin, etc. | Some mining-resistant designs |
Parameter Design (N, r, p)
scrypt has the following three parameters.
Doubling N doubles both memory usage and computation time. Because the interdependence of the parameters is complex, tuning is somewhat more difficult compared with algorithms like Argon2id that allow memory, time, and parallelism to be adjusted independently. The salt follows the same basic principles as other password hashing schemes.
Adoption in Litecoin
Litecoin, which appeared in 2011, adopted scrypt as its Proof of Work algorithm in place of Bitcoin's SHA-256. The aim at the time was to "prevent the oligopolization of mining by ASICs and allow ordinary PCs to participate in mining." However, scrypt-compatible ASICs appeared around 2014, and the original goal was not achieved. We explain cryptocurrency security in cryptocurrency wallet security.
Examples of Misconceptions
Some argue that "scrypt is old, so it should not be used," but when operated with appropriate parameters, it still provides sufficient security as of 2025. OWASP states that scrypt should be used when Argon2id is not available. For the fundamentals of cryptography, see the basics of encryption, and for the overall picture of password management, also refer to the secure password management guide.
Was this article helpful?
Related Terms
- Argon2 - Modern Password Hashing AlgorithmArgon2 won the 2015 Password Hashing Competition. Its memory-hard design resists GPU and ASIC parallel attacks, and OWASP recommends it as the top-priority algorithm for password storage.
- PBKDF2 - Password-Based Key DerivationPBKDF2 derives cryptographic keys from passwords and is standardized in NIST SP 800-132. Used in Wi-Fi WPA2, it lacks GPU resistance, so migration to Argon2 or bcrypt is recommended.
- bcrypt - Time-Tested Password Hashingbcrypt is a Blowfish-based password hashing function designed in 1999. It offers an adjustable cost factor and automatic salt generation, and OWASP says it should only be used for legacy systems without Argon2 or scrypt.
- Password Hashing - Irreversible Storage for CredentialsPassword hashing transforms passwords into irreversible digests for storage. Combined with salting and stretching, it eliminates plaintext risk and resists offline cracking after a breach.