|This article needs additional citations for verification. (July 2012)|
In cryptography, scrypt is a password-based key derivation function created by Colin Percival, originally for the Tarsnap online backup service. The algorithm was specifically designed to make it costly to perform large-scale custom hardware attacks by requiring large amounts of memory. In 2012, the scrypt algorithm was published by IETF as an Internet Draft, intended to become an informational RFC, which has since expired. A simplified version of scrypt is used as a proof-of-work scheme by a number of cryptocurrencies, such as Litecoin and Dogecoin.
A password-based key derivation function (password-based KDF) is generally designed to be computationally intensive, so that it takes a relatively long time to compute (say on the order of several hundred milliseconds). Legitimate users only need to perform the function once per operation (e.g., authentication), and so the time required is negligible. However, a brute force attack would likely need to perform the operation billions of times, at which point the time requirements become significant and, ideally, prohibitive.
Previous password-based KDFs (such as the popular PBKDF2 from RSA Laboratories) have relatively low resource demands, meaning they do not require elaborate hardware or very much memory to perform. They are therefore easily and cheaply implemented in hardware (for instance on an ASIC or even an FPGA). This allows an attacker with sufficient resources to launch a large-scale parallel attack by building hundreds or even thousands of implementations of the algorithm in hardware and having each search a different subset of the key space. This divides the amount of time needed to complete a brute-force attack by the number of implementations available, very possibly bringing it down to a reasonable time frame.
The scrypt function is designed to hinder such attempts by raising the resource demands of the algorithm. Specifically, the algorithm is designed to use a large amount of memory compared to other password-based KDFs, making the size and the cost of a hardware implementation much more expensive, and therefore limiting the amount of parallelism an attacker can use (for a given amount of financial resources).
The large memory requirements of scrypt come from a large vector of pseudorandom bit strings that are generated as part of the algorithm. Once the vector is generated, the elements of it are accessed in a pseudo-random order and combined to produce the derived key. A straightforward implementation would need to keep the entire vector in random-access memory so that it can be accessed as needed.
Because the elements of the vector are generated algorithmically, each element could be generated on the fly as needed, only storing one element in memory at a time and therefore cutting the memory requirements significantly. However, the generation of each element is intended to be computationally expensive, and the elements are expected to be accessed many times throughout the execution of the function. Thus there is a significant trade-off in speed in order to get rid of the large memory requirements.
This sort of time–memory trade-off often exists in computer algorithms: you can increase speed at the cost of using more memory, or decrease memory requirements at the cost of performing more operations and taking longer. The idea behind scrypt is to deliberately make this trade-off costly in either direction. Thus an attacker could use an implementation that doesn't require many resources (and can therefore be massively parallelized with limited expense) but runs very slowly, or use an implementation that runs more quickly but has very large memory requirements and is therefore more expensive to parallelize.
Mining of cryptocurrencies that use scrypt as a proof-of-work function is often performed on graphics processing units (GPUs). This has led to shortages in this hardware. ASIC hardware designed specifically for scrypt mining are being developed.
Proof-of-work in cyptocurrency operations
Scrypt has been popularly adopted in cryptocurrency operations since Litecoin started the trend. Using scrypt instead of SHA-256 in hashing requires a larger RAM capacity, this renders most ASIC applications useless. Currently, there are some ASIC development for scrypt mining, though the gap between commercially available GPU and ASIC cards aren't nearly as large as SHA-256.
Implementations, wrappers, and distributions
- cryptsharp (C#)
- scrypt (Go)
- scrypt (Java)
- scrypt (Java, non-static)
- scrypt (NodeJS)
- php-scrypt (PHP wrapper)
- scrypt (Ruby)
- scrypt (Debian package)
- Crypt::Scrypt (Perl)
- Crypt::ScryptKDF (Perl)
- Key derivation function
- crypt, password storage and verification scheme
- PBKDF2, a widely used standard password-based key derivation function
- bcrypt, key derivation function using Blowfish
- Time-memory tradeoff
- "scrypt page on the Tarsnap website". Retrieved 21 January 2014.
- C. Percival, S. Josefsson (2012-09-17). The scrypt Password-Based Key Derivation Function. IETF.
- Alec Liu. "Beyond Bitcoin: A Guide to the Most Promising Cryptocurrencies".
- Roman Guelfi-Gibbs. Litecoin Scrypt Mining Configurations for Radeon 7950. Amazon Digital Services.
- Joel Hruska (10 December 2013). "Massive surge in Litecoin mining leads to graphics card shortage". ExtremeTech.
- Danny Bradbury (23 October 2013). "Scrypt-based miners and the new cryptocurrency arms race". CoinDesk.
- Jesús Cripto (22 November 2013). "Alpha Technologies to Offer Scrypt Mining ASICs". CryptoCoins News.