{'fraction_non_alphanumeric': 0.01996116504854369, 'fraction_numerical': 0.013592233009708738, 'mean_word_length': 4.555771305285869, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Scrypt Mining with ASICs

Cryptocurrencies have garnered a lot of attention by governments and internet enthusiasts over the past three years. These currencies are celebrated for their security and speedy transactions in a modern era of digital commerce. Bitcoin was the first of these currencies to gain a large advantage over subsequent iterations. Bitcoin was first conceived by Satoshi Nakamoto who mentioned the concept of a cryptocurrency in his paper titled Bitcoin. It featured new concepts such as proof of work and transactions which utilized hash based encryption. One particular alternative cryptocurrency is known as Litecoin. Backed by a memory intensive algorithm known as Scrypt, many cryptocurrency enthusiasts have decided to celebrate this particular coin. Scrypt expands on Bitcoin's proof of work algorithm by adding the amount of work it takes to commit a transaction within the Litecoin network. Scrypt forces more work on the device that is being used to perform the algorithm by making frequent memory requests. This makes it difficult to create specialized hardware to create new coins and to commit transactions due to the nature of memory intensive applications.


Introduction
Crypto-currencies have garnered a lot of attention by governments and internet enthusiasts over the past three years. These currencies are celebrated for their security and speedy transactions in a modern era of digital commerce. Bitcoin was the first of these currencies to gain a large advantage over subsequent iterations. Bitcoin was first conceived by Satoshi Nakamoto who mentioned the concept of a crypto-currency in his paper titled Bitcoin. It featured new concepts such as proof of work and transactions which utilized hash-based encryption.
One particular alternative crypto-currency is known as Litecoin. Backed by a memory-intensive algorithm known as Scrypt, many crypto-currency enthusiasts have decided to celebrate this particular coin. Scrypt expands on Bitcoin's proof of work algorithm by adding the amount of work it takes to commit a transaction within the Litecoin network. Scrypt forces more work on the device that is being used to perform the algorithm by making frequent memory requests. This makes it difficult to create specialized hardware to create new coins and to commit transactions due to the nature of memory intensive applications.
Creating specialized hardware is very important for the overall health of a crypto-currency. It allows for investors and third parties to help grow the currency into a valuable form of exchange. Because Bitcoin's proof of work algorithm is not as intensive, it was much easier to create an ASIC (Application Specific Integrated Circuit) to help mine those coins faster. Third parties were able to invest in Bitcoin's growth and it is now the most valuable crypto-currency in existence today. Due to the nature of Litecoin, however, the ASIC development has not been as fast. Many people have requests ASICs be made for Scrypt, but there has not been any development until now.
As part of this research project, different solutions and strategies for developing a Litecoin ASIC were explored. The research began with finding and compiling Litecoin source code. Determining which portion of the Scrypt algorithm was the most intensive was important for determining how best to optimize the circuit. Compiling the source code using different optimization strategies was useful for determining what portion of the code would be able to be sped up or perhaps designated a special portion of the circuit.
The most expensive part of the algorithm is the memory-hard salsa20. In order to reduce the overall impact that this portion of the Scrypt algorithm had on the overall runtime, different memory solutions to be implemented into a cache were explored. By utilizing the proximity and speed of a cache for this particular circuit, the overall speed of the algorithm would be drastically increased. Different memory technologies, such as SRAM, STT-RAM, MRAM, PCRAM, and even DRAM were explored as potential candidates. Due to the experimental nature of some of these options, SRAM was found to be the fastest candidate.
The final portion of the research was to design and benchmark a schematic of the ASIC in Verilog code. There were some significant benefits to producing the ASIC, including reduced cost for production over current alternatives. The cost of production and potential next steps were explored in order to generate an idea of what it would take to actually produce a real ASIC. It was important to take into consideration the time to create an ASIC given the rapidly changing market of crypto-currencies as well and the upcoming competition in the ASIC market.

Background
Crypto-currencies are a cross between a fiat currency and a commodity. They use cryptography to ensure safe and secure transaction between parties 1 . Crypto-currencies have garnered much attention over the past four years due to their revolutionary method of how currency can be exchanged and used digitally, bypassing centralized government and financial institutions. The inception of these currencies began with a paper written by Satoshi Nakamoto who wrote "Bitcoin: A Peer-to-Peer Electronic Cash System". He suggested a new system that allowed online payments to be sent directly from one party to another without a need for a financial institution (Nakamoto,1).

Satoshi Nakamoto's Peer to Peer Coin
By replacing online electronic transactions with crypto-currencies, people would not have to be as concerned about their online information being publicly available. Each transaction required chain of digital signatures by way of public and private keys. The public key could be well known as a destination for coins, but the private key is necessary to be a source of coins. Each transaction would be protected by a proof of work, or hashing algorithm that would prove that the transaction is valid. The only way a user could submit their exchange would be by performing the hashing algorithm on their end of the computer. Each cryptocurrency was to have its own blockchain, a public ledger, of all transactions that have occurred on the network so far. Fraud cannot occur in such a system. The hashing algorithm that is primarily used by Bitcoin is known as SHA-256. This algorithm, in 2009, was originally quite secure and had not been easily cracked. SHA-256 is a very popular hashing algorithm for many crypto-currencies. Collisions in the Bitcoin block chain would cause an overlap of transaction data. But because of hashing, the odds of having a collision in the blockchain are minimal. The odds of a collision 1 2 128 . These odds, multiplied by the approximate 52500 transactions that happen per year for Bitcoin, are minimal enough that a collision will likely never occur.
Bitcoin's popularity as a currency has been due to many exchanges and users that have grown to support and mine in the network. The open source nature of the coin allowed users to design versatile program such as CPUMiner and CGMiner which could both be used to mine these coins. Various alternate currencies were created in response to this excitement. These included Namecoin and Litecoin. Litecoin in particular was created with a different proof of work algorithm known as Scrypt.

Scrypt and How it Improves Bitcoin's Proof of Work
Litecoin was the first Crypto-currency to popularize the idea of Scrypt as an alternative to SHA-256 based coins. Bitcoin ASICs made it difficult for new, Sha-256 based Alt Coins to gain popularity because their difficulty was going up so fast that large communities of people were not able to get large quantities of the currency via solo mining. Scrypt Cryptocurrencies, however, do not have large support via ASICs yet. Scrypt Alt Coins are typically mined solely by GPU miners. These alternative Cryptocurrencies have a market cap much smaller than that of Bitcoin 2 . Many attribute this lack of value to the lack of investment in Scrypt coins and lack of ASICs. The current lack of ASICs for Scrypt Cryptocurrencies are due to the nature of Scrypt and how it creates a larger computational problem than solely Sha-256.

What is Scrypt?
Scrypt was suggested by Colin Percival as a memory-hard algorithm to help create a system for password-key derivation. In his paper from May 2009, he describes a new methodology for hashing values that is not easily brute-forced. Key derivation functions are functions that will generate a derived key from a password. This key can be generated dynamically every time a password is entered, and tested with the original derived key to determine if the keys are a match. This is superior to storing a single password because it does not expose the actual password to potential thieves (Percival,2).
In order to break key derivation functions, a hacker might attempt to find user passwords by hacking into a server and pulling all database info about all users. For most key derivation functions, the only feasible option is to test all possible passwords until the correct value is found, otherwise known as a "brute force" attack 3 . The rate at which a hacker can test passwords is linearly related to the length of time it takes to derive a key to test if the password is correct. This way, if the designer of the algorithm can make the algorithm twice as long, it will take twice as long to crack the password. Originally, Sha-256 was a very good candidate for such functionality, but soon after it was popularized many computer architects were able to determine how to make ASICs to solve SHA-256 passwords quickly.
In order to combat this potential flaw in key derivation functions, the concept of "memory-hard" algorithms was invented. A memory hard algorithm will need to access random-access-memory, or RAM, frequently as part of its runtime. Typically, these queries can add significant amount of time to the overall runtime of a circuit. A typical access time to DRAM (Dynamic RAM) will take 60ns 4 . If a key derivation function needs to make 1000 accesses to DRAM per password, this could mean an additional 60µs per password. This time is small for one particular password, but a brute-force attack that tests for combinations of English words would need an additional 3.9 days 5 to compute. This estimate does not include time spent on the algorithm, just purely from a memory access perspective.
There are multiple memory-hard algorithms that could be used for Scrypt, but Percival recommended the use of ROMix in particular because it is a sequentially, memory-hard algorithm (Percival,7). ROMix acts as if it is randomly accessing memory and does so in a sequential way. The algorithm for ROMix is difficult to parallelize. This is good because a sequential algorithm will take longer to perform than one that can have all its individual parts performed simultaneously.

Why Litecoin Creators Chose Scrypt
Scrypt is a memory-hard function. Colin Percival argued heavily that creating an ASIC for Scrypt would be expensive and unrealistic. The Scrypt algorithm works as a proof-of-work scheme similar to how Sha-256 worked for Bitcoin. The main difference is that Scrypt prevents ASICs and GPU mining, which were very effective for mining Bitcoin, from having any efficient power over Scrypt. In April 2014, Litecoin reached a market cap of $270 million and achieved a network strength of 100GH/s. This equates to 100 TH/s for Bitcoin due to the intensity that Scrypt imposes on the hardware mining it 6 .
Because Scrypt is inherently more difficult to perform computationally, many Alt Coins have adopted it as the proof-of-work scheme. Dogecoin, a coin popularized by many social networking sites, has been one such Crypto-currency that has gained a lot of momentum in only six months 7 . Many people argue that these coins would not be popular if Scrypt were easily mined. This view does not take into account that ASICs are what helped Bitcoin rise to its current popularity and allowed it to gain a much higher market cap value. Without ASICs, these coins will not flourish to their full potential.

Developing a Scrypt ASIC
The first steps taken towards the development of the Scrypt ASIC were to find and compile the mining program responsible for performing Scrypt. This program was then benchmarked and the time spent in each portion of the program was calculated. It was quickly apparent that this particular algorithm was memory-hard. Looking for good alternatives to traditional hardware was important. In particular, exploring a cache dedicated to storing the Litecoin block header was key. Different memory alternatives were then analyzed to see which would be the most appropriate for this particular application. Finally, a sample circuit designs was created using Verilog and then benchmarked further to see how expensive the design would be.

Scrypt in Theory
Developing a Scrypt ASIC is not an easy task, however. As Percival noted in his paper, the algorithm is designed to be memory-intensive. However, since the time of his writing, the cost to implement certain circuits has gone down enough that developing a Litecoin ASIC may prove to be cost effective. In particular, the cost of developing the memory can be reduced once the designer is aware that there only needs to be 128KB of memory per processor. Because Scrypt is not easily parallelizable, it is not necessary to have multiple cores, but instead have one core driving a 128KB cache. Scrypt begins with a basic key derivation function, Sha-256. This value is 128 kB long. This is the only amount of space that the algorithm needs to complete. Each Salsa iteration requires a total of 34 cycles. One cycle to read in 128 bytes of the overall hashed value. The inside loop (see Appendix A) has two halves, each with four sections that can be done in parallel. This means one iteration of inner loop will take 8 cycles, and each loop has 4 iterations, so a total of 32 extra cycles. And then an additional cycle for the final loop.

Scrypt Call-Flow
In both iterations, there are 2048 calls to salsa because each loop makes two calls. The second iteration also has to access the cache to get the new values so that it can continue. Theoretically, this overall process could take 139264 cycles to complete one iteration of Scrypt plus whatever latency would be required for accessing memory. If one cycle in this circuit took 1 ns, that could mean a potential hash rate of 7 KH/s. This is ignoring potential speedup from additional parallelization and potential extra speedup from a faster clock cycle.

Scrypt on a CPU
Scrypt runs very differently depending on the hardware that is performing the computation. The trials performed primarily ran the program on a processor. The program was run on a computer that had Ubuntu installed and was also compiled for the computer 8 . The code was also compiled using a variety of different optimization strategies. In particular: msse2, msse4, O4, and O3 compiler flags were used to analyze the particular performance improvements that could be observed on standard commercial hardware. By far the fastest optimization strategy was MSSE4 which had a 35% improvement on total runtime over no compiler optimization 9 .
Due to the limitation of the testing environment, there was no way to run the program without the OS's (in this case Ubuntu's) normal programs taking up CPU clock cycles. Increasing performance using MSSE4 meant that the program was being optimized for use of all four available cores on the computer 10 . The memory hard portion of the program, in this case the Salsa20 Core function, was taking the most processing time. The code is as follows: The code uses variable placeholder for values in memory so that the code can be easily parallelized. Each section of four functions can be run in parallel together as there are no interdependencies on the code. If the proper parallelization flags are set during compile time, the program has at least a four time speedup. This portion of the algorithm takes approximately 60% of the runtime for the entire Scrypt runtime.
38% of the runtime is devoted to memory access. The Salsa20 algorithm begins with 32 reads and 16 writes from memory where it reads 16 memory locations of the two parameters passed to the function: Each memory location is read and xor'd with the corresponding location in the second parameter of the function. These values are then written back to the B array and also stored locally in variables defined at runtime. A similar write-back sequence is performed at the end of the salsa 20 function: The final resulting values that were computed in the central algorithmic portion of the salsa 20 function are then stored into the corresponding location in the B array. This features another 16 reads and 16 writes, as each value is incremented by the values stored locally. Altogether there are 48 reads and 32 writes for the salsa20 function. If this time that it takes for the computer to write-back this data can be reduced, it will speed up the program significantly.

Memory Considerations
Deciding on which memory technology to use to implement the Scrypt ASIC is important. There are multiple flavors of memory that could be used. The most important piece to note is that cache memory is much faster than RAM. The typical DRAM speed is approximately 60 ns, whereas SRAM can achieve access times of 0.75 ns (See Appendix B). After analyzing the Scrypt function, the data showed where the majority of the time was spent computationally 11 . In order to reduce the overall time for the ASIC to perform the task of mining, it is necessary to analyze the most common case for the algorithm and minimize the time spent. In particular, optimizing the program with compiler flags such as msse4 and O4 both helped optimize the speed and decreased the amount of time the program took by approximately 1 second (See Appendix D). There are many memory structures that could potentially increase the overall speed of the ASIC, such as STT-RAM, PC-RAM, and MRAM.

SRAM
Static random access memory (SRAM) is a type of semiconductor memory that uses a latch based circuit to store information in the form of bits. SRAM is a volatile storage, or it does not maintain the data across cycling of power for a given memory cell. SRAM is not very power intensive, as it only needs a few microwatts when running to maintain power. SRAM is a good candidate for cache because it maintains value when not accessed for relatively long periods of time and its very quick. After analyzing output from Cacti 6.0, 11 The CPU miner program was run on a computer that was connected to a Litecoin testnet. This Litecoin testnet provided a sample block header with relatively low difficulty (<1). The program then reported the number of hashes as well as how long it spent in each function. Overall the program ran 4104 hash for one block.

MRAM
MRAM is a memory technology that has existed since the 1990s and has a higher density from flash RAM and DRAM. MRAM relies on magnetic fields to maintain the value held by a given memory cell. It is nonvolatile, so it lasts for long periods of time without losing data. MRAM has inferior read and write speeds to SRAM, which makes it a poor candidate for this ASIC. (Tamai) STT-RAM Spin-transfer torque RAM (STT-RAM) is a form of RAM that combines the speed of SRAM with the permanence of flash memory. It relies a magnetic tunnel junction, or a way to transmit magnetic fields, to modify a state using a spin-polarized current. In other words, the value in the STT-RAM is held constant until it receives a magnetic signal changing the state. This can be useful for maintaining values held in memory for long periods of time. However, this technology is not quite as fast as SRAM. STT-RAM has a write latency of 10.61ns, twenty times longer than that of SRAM. This would not make a good candidate for speeding up the runtime of the ASIC as it would be much more expensive and slower than using pre-existing technology. (Penn State)

PC-RAM
A type of non-volatile random-access memory. Similar to STT-RAM, it does not expire quickly. It relies on a complex 3D lattice system to produce long lasting data. However, its latency varies between 10-100ns for both reading and writing data. Due to its inconsistency and lack of real implementation, it would be a poor choice for implementation. (Xie)

Preliminary Designs and Estimates
After performing minor modifications to an online source code 12 for an FPGA Scrypt miner, I was able to determine the number of logical gates and time delay of the overall circuit. There are 13,446 logical gates on the chip, where 12,613 of them are combinational function and 6,567 are logic registers. These logical registers have a total of 1,048,576 memory bits to store for one operation. This is 131,072 bytes, or roughly a 128KB cache.
To analyze the timing of the circuit, I found the worst case timing path for one operation to find the worst case operation time. In this case the worst case path was 95.762 ns. This timing could allow for at least one hash to occur, resulting in an overall timing of 10,526,315 H/s. This speed is much higher than the best graphics cards currently, which only clock in at 1 MH/s 13 .
Given the sheer number of logical circuits, however, the overall cost of this ASIC would be very high. According to Multi-Project Circuits, the cost per mm 2 of producing an ASIC would be approximately 3500 Euro for a 130nm chip. Given that there are 6,567 SRAM cache registers which each would be 5.007 m 2 /bit 14 , this would result in approximately 32883.6 m 2 for the cache alone. The combinational circuit would likely feature an average size of 5 2 , for a total approximate circuit area of 227483.6 2 or 0.22748mm 2 . This chip would initially be about 796.18 Euro to produce, or 1087.26 USD.

Figure 4 it will take approximately 60 days to break even assuming no fluctuations in the most profitable coin's value
This chip would be able to produce 10 MH/s. At the currently most profitable Scrypt coins 15 , this would result in $18.50 of revenue per day, not including power costs. This would take $60 to break even at current valuations of the most profitable coins. If their value were to increase, the number of days would fall as a result. These costs do not take into account the amount of money it would take to pay a team of people to produce the ASIC. This only takes into account potential fabrication facilities' rates of producing one ASIC. These costs will likely go down as the cost of producing 130nm chips declines over the coming years.

How a Scrypt ASIC will better the Alt Coin Economy
By providing an ASIC for Scrypt Cryptocurrencies, there will be a resurgence of following in these Alt Coins that will be akin to that of Bitcoin. People will purchase the ASICs which will help produce more ASICs and also allow for additional investment in the Crypto-currency itself. By offering faster coin production and higher investment rates, the overall market cap will increase, thus increasing the probability that the coin will expand in intrinsic value. It is possible, that with the number of Scrypt Alt Coins in existence, that the overall market cap for all Scrypt coins will be greater than that of Bitcoin.

CPU Mining and GPU Mining Fall Short
CPU Mining, as noted earlier, is very slow compared to many alternatives. The runtime for the earlier program was roughly 4.1KH/s and a more modern processor would be able to produce hashes at 95KH/s. The same program running on a much more powerful GPU, such as an AMD R9 290X would show speeds of approximately 804 KH/s 18 . These speeds pale in comparison to the theoretical 10MH/s that the ASIC design is capable of providing. This is roughly a 1000 times increase over CPU and a 10 times increase over GPU miners, keeping into consideration possible fluctuations in hashing rates.
Not only is the effective hashrate of consideration, but the cost of energy for each of these designs is important as well. A CPU and GPU needs to be housed within a computer enclosure that is capable of providing energy and instructions to both in order to run the program. The Core-i7-4770 runs at 84W and the AMD R9 290X runs at approximately 300W. These would incur additional costs above their entry cost in the form of electricity bills. This particular ASIC will only use 300W to perform its computation 19 . The power advantage over these alternatives is apparent, given that it would take ~84,000W for a cluster of CPUs to reach comparable performance and 3000W for a cluster of GPUs to reach similar performance to the ASIC.

Conclusion
Research in the development of ASICs is a time consuming process. Steps taken towards this goal included compiling and benchmarking Scrypt code, analyzing various components involved with the ASIC including memory, and analyzing costs associated with development of the ASIC. Litecoin ASIC development will also require further research in the best fabrication facilities and development of a functioning prototype. This prototype would likely be made using an FPGA circuit.
The next steps in developing the ASIC would be to first start pitching the idea to VCs to not only raise awareness about the issue but also to raise funds to get a team together to start designing the ASIC. Ultimately the current design will likely be redone so that it is more efficient and relies on the experience of a team that has built an ASIC before. As soon as these steps are complete, determining the best foundry to fabricate the ASIC or potentially get a prototype would be key to making sure that the ASIC is fully functional.