Litecoin Scrypt Algorithm Explained

0
437
Image representing Scrypt algorithm article.

Litecoin Scrypt Algorithm Explained 

Last Updated: 18th December 2018

Scrypt is a hash function that was first used by the cryptocurrency, Litecoin, as an alternative to the more well-known SHA-256 hash function. Scrypt and SHA-256 are used as mining algorithms within the Litecoin and Bitcoin protocols respectively. Both operate within the proof-of-work consensus mechanism where a miner is required to find a nonce value (a variable selected by the miner), such that, when a candidate block header is hashed, the resulting output is equal to or lower than the given target. The target is a measure of how difficult it is for a miner to produce a valid block; the lower the target value, the more difficult it will be for a miner to generate a valid block. Conversely, the higher the target value, the easier it is for a miner to generate a valid block. The block generation time of Litecoin is 2.5 minutes, therefore, the target will automatically adjust in difficulty so that a successful block is produced by a miner every 2.5 minutes.

For example, if the nonce were to be variable “12345”, this would be placed in the block header to be hashed, such that:

Where x = hash output value,

x = Scrypt(Block header)

If the resulting hash output value, in this case ‘x', proves to be above the target, the miner must try again. The miner then changes the nonce to another variable, e.g. “90872”, and places this inside the block header. if the resulting hash output value proves to be below the target, the miner’s block is then relayed to Litecoin nodes on the network in order to be validated.

Scrypt & SHA-256

Both the Scrypt and SHA-256 hash functions are computationally intensive as they both require raw computational power in order to generate a large number of possible solutions for their respective functions. For example, according to BitInfoCharts, as of writing, the current hash rate on the Litecoin network is 146 TH/s. What this means is, there are 146 trillion hash computations being performed every second by miners on the Litecoin protocol. However, what differentiates the Scrypt function, from the SHA-256 function, is that it is also memory intensive. Scrypt is memory intensive because as well as requiring miners to generate numbers rapidly, these generated numbers are stored in the Random Access Memory (RAM) of the processor, which then needs to be accessed before submitting a result.

In terms of overall hashing power, Scrypt based protocols have a lower hash rate than SHA-256 based protocols. Currently, according to Blockchain.info, the Bitcoin protocol has a hash rate of roughly 45,000,000,000 TH/s – significantly more than that of the Litecoin.

Why use Scrypt?

The Scrypt hash function was initially implemented by the Litecoin development team to avoid what are known, Application-Specific Integrated Circuits (ASICs), from being able mine on the Litecoin network. When mining for cryptocurrencies, users typically have an option between: a CPU, GPU or ASIC miner.

ASICs are computationally superior to CPUs and GPUs, i.e. they are able to generate more hashes per second. Therefore, miners who use any other device other than an ASIC to mine for a cryptocurrency, are put at a disadvantage. However, the Scrypt mining algorithm was introduced to prevent ASIC mining from taking place because the algorithm is memory intensive; ASIC miners were initially not well-suited to mine on Scrypt-based protocols, and thus, miners who used CPUs and GPUs could remain competitive.

However, as time as gone on, the initial “ASIC-resistance” of the Scrypt mining algorithm has disappeared. Scrypt-capable ASICs have been developed that allow for efficient mining of any cryptocurrency that use the Scrypt algorithm. Consequently, CPUs and GPUs are no longer valid mining tools on the Litecoin network due to their inferior computational power, when compared to ASICs.