<p>I suggest <a href="http://bcrypt.sourceforge.net/" rel="nofollow noreferrer">bcrypt</a>. It is not a cryptographic hash function per se, but it could replace SHA-256 and add some memory constraints that would make its implementation harder on GPUs.</p>

<p>Bcrypt uses blowfish to encrypt a string with a key derived from a password chosen by the user. So given a string and a target, finding a password that encrypts the string below the target works exactly like the Bitcoin lottery.<br>
As for the memory constraints, it is possible to implement bcrypt on a GPU, but it is much harder (probably impossible) to get the same kind of performance improvements we see with SHA. Here is an excerpt from a post on <a href="https://crypto.stackexchange.com/questions/400/why-cant-one-implement-bcrypt-in-cuda">crypto stackexchange</a> about implementing bcrypt with cuda:</p>

<blockquote>
  <p>Now bcrypt is a variant of the Blowfish key scheduling, which is
  defined over a table (a few kilobytes) which is constantly accessed
  and modified throughout the algorithm. Due to the size of the table,
  each core will have to store it in the GPU main RAM, and they will
  compete for usage of the memory bus. So bcrypt will run -- but not
  with full parallelism. At any time, most cores will be stalled,
  waiting for the memory bus to become free.</p>
</blockquote>

CC BY-SA 3.0
2011-09-13T02:29:27.513Z
2011-09-13T02:29:27.513Z
2017-04-13T12:48:25.933Z
nmat
<p>The choice of the SHA-256 algorithm for Bitcoin's proof of work has created what could be described as the most ideal application for botnets that one could possibly conceive of. Bot masters are looking for ways, essentially, to turn computation into cash. Bitcoin does that natively.</p>

<p>The huge risk is if the botnets take over the network. Given that botnets can comprise up to millions of machines (at their largest - most are much smaller than this), even with CPU mining a single botnet could potentially take over the network. For instance, assume a 2M strong botnet comprising Core2 Duo machines (5 MHash/s). This network would do 10 THash/s.</p>

<p>The only countermeasure to this is to have special mining gear that is more efficient than CPUs and GPUs, and not available on the average botted PC. This is why the community needs an ASIC-based mining solution.</p>

CC BY-SA 3.0
2011-09-14T00:05:54.500Z
Sure, if you assume someone makes the ASICs available to all rather than keeping them to themselves.
David Schwartz
CC BY-SA 3.0
2011-10-05T05:33:36.927Z
There is no 2 million strong botnet.  Anywhere.  Storm Trojan is the largest known botnet and it has 250K nodes.  The second largest botnet has a mere 30K nodes.  SHA-256 is the algorithm that is used and to say it is "ideal application" for botnets is silly.  The very fact that GPU can efficiently accelerate SHA-256 is what gives bitcoin a chance against botnets.  Since 1 high end GPU can equal 200+ CPU it gives the "valid nodes" a multiplier effect.  Even if your unrealistic example 10TH botnet wouldn't have sufficient capacity to break bitcoin.
DeathAndTaxes
CC BY-SA 3.0
2012-09-12T19:48:26.670Z
@DeathAndTaxes How do you know the size of various bot nets?
makerofthings7
CC BY-SA 3.0
2011-09-14T00:04:24.327Z
2012-11-13T22:08:51.080Z
2012-11-13T22:08:51.080Z
Ken Simpson
<p>The <a href="http://www.tarsnap.com/scrypt.html">scrypt key derivation function</a> was explicitly designed to be resistant to hardware optimization, with an explicit trade-off allowed between memory and cpu usage:</p>

<blockquote>
  <p>The scrypt key derivation function ... is designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt.</p>
</blockquote>

<p>This makes it better than SHA-256 or bcrypt if the intent is to give more of an advantage to CPUs.</p>

<p>Another option would be to include the same sort of variety of primitives that are provided for general purpose CPUs, e.g. a combination of floating point operations, access to large memories (perhaps including something that would use a large random access memory like a disk), etc.</p>

<p>But as Thilo point out, including some sort of anti-botnet feature might also be needed.  A CAPTCHA might also make it rather unpopular, but some sort of work load that would indeed be noticed by a regular computer user might make it hard to hide botnet activity.</p>

CC BY-SA 3.0
2011-10-09T07:06:25.400Z
Tenebrix is AFAIK the first crypto currency relying on CPU-friendly algorithms (specifically scrypt if I'm not mistaken). http://tenebrix.org/ Note there are some serious caveats with Tenebrix: https://bitcointalk.org/index.php?topic=47269.0
ripper234
CC BY-SA 3.0
2012-04-16T21:48:56.513Z
I think using a very large amount store would be interesting to explore. It would be very noticeable to a user, as "disk space left" is just about the only statistic they get. If that size is deduced from something difficult like the (high) primes it can be enlarged and shrunk as needed by the network. Interesting idea.
Lodewijk
CC BY-SA 3.0
2011-09-13T04:32:57.963Z
2011-09-13T04:32:57.963Z
nealmcb
<p>The mining algorithm for Bitcoins (and most alternative but similar currencies as well) is purely computation hard, but not decision hard or memory hard. This caused the unexpected effect that GPUs are insanely good at mining and CPUs are so bad at mining that there's almost no point in using them to mine.</p>

<p>This has had many effects, including the concentration of mining into specialized hardware. Suppose that I think that's bad and would prefer that commodity CPUs be optimal for mining and that mining on them be practical. Given the requirements of mining, particularly that it work like a lottery and that valid results be quickly verifiable, are there algorithms that could have been chosen that would have resulted in commodity CPUs being the optimal miners?</p>

<p>Are there algorithms that require lots of decisions and/or lots of memory that could serve as the mining algorithm on future crypto-currencies that would make CPU mining practical again and give everyone with a high-end CPU a reasonable chance at mining?</p>

CC BY-SA 3.0
2013-05-30T01:23:01.813Z
Year and a half after you originally asked this question, LiteCoin uses scrypt as a CPU-friendly algorithm, while PPCoin uses "proof-of-stake" to balance the electricity expenditures required for "proof-of-work". In retrospect, do you think any of them would've been a better BitCoin design than the original one? :)
Joe Pineda
CC BY-SA 3.0
2013-06-02T22:56:31.210Z
@JoePineda: No. I now think that an ASIC-optimized mining algorithm is much more secure than a CPU-optimized one. You can rent a supercomputer or retask a botnet to attack a currency whose PoW algorithm works best on an ASIC.
David Schwartz
CC BY-SA 3.0
2013-06-03T16:00:25.810Z
Thanks David, though I find it intriguing. If you can repurpose a botnet or a supercomputer's timeshare to attack an ASIC/GPU friendly crypto-currency, how does that make it more secure than a CPU-friendly crypto-currency? Besides, both a botnet and a supercomputer could be used to mine scrypt-based currencies as well, and be very efficient at that...
Joe Pineda
CC BY-SA 3.0
2013-06-03T19:26:41.227Z
You can't really repurpose a botnet or a supercomputer to attack an ASIC-friendly crypo-currency -- you pretty much have to invest in ASICS, and thus in the very crypto-currency you're attacking. That's why Bitcoin got it right.
David Schwartz
CC BY-SA 3.0
2011-09-13T01:13:15.887Z
Interesting idea. However, even if there was an algorithm that favored commodity hardware it would still not put mining back into the hands of the people because of bot-networks. Maybe there needs to be an additional requirement of human input, like a CAPTCHA.
Thilo
CC BY-SA 3.0
2011-09-13T09:36:35.750Z
@Thilo Can you imagine the tedium of endlessly answering CAPTCHA questions to keep a currency operational? <Shudder>
Gary
CC BY-SA 3.0
2011-09-13T16:21:19.403Z
I don't think a computer can easily verify a CAPTCHA it didn't generate, so that wouldn't work. Good point about botnets though, that's a serious problem.
David Schwartz
CC BY-SA 3.0
2011-10-03T21:28:03.153Z
What would be even better would be some sort of algorithm that didn't require upper end hardware of any sort, and used less electricity to run. I can't imagine how that could work though - even if you based chances of solving a block on something like the combo of the current time and your IP address, you'd still get an advantage by using lots of IP addresses (and it would also result in stacks of low value hardware participating, instead of a lesser amount of high value hardware). Finding some sort of activity to perform that benefits people at the same time would be the ultimate achievement.
Highly Irregular
<mining-theory><asic-resistance>
Are there algorithms that could have been chosen for mining that balance CPU/GPU?
David Schwartz
# Are there algorithms that could have been chosen for mining that balance CPU/GPU?

(Asked by: username_0 on 2011-09-13)

The mining algorithm for Bitcoins (and most alternative but similar currencies as well) is purely computation hard, but not decision hard or memory hard. This caused the unexpected effect that GPUs are insanely good at mining and CPUs are so bad at mining that there's almost no point in using them to mine.

This has had many effects, including the concentration of mining into specialized hardware. Suppose that I think that's bad and would prefer that commodity CPUs be optimal for mining and that mining on them be practical. Given the requirements of mining, particularly that it work like a lottery and that valid results be quickly verifiable, are there algorithms that could have been chosen that would have resulted in commodity CPUs being the optimal miners?

Are there algorithms that require lots of decisions and/or lots of memory that could serve as the mining algorithm on future crypto-currencies that would make CPU mining practical again and give everyone with a high-end CPU a reasonable chance at mining?

**Tags:** mining-theory, asic-resistance

> **Comments:**
> **username_2**: Interesting idea. However, even if there was an algorithm that favored commodity hardware it would still not put mining back into the hands of the people because of bot-networks. Maybe there needs to be an additional requirement of human input, like a CAPTCHA.  
> **username_3**: @username_2 Can you imagine the tedium of endlessly answering CAPTCHA questions to keep a currency operational? <Shudder>  
> **username_0**: I don't think a computer can easily verify a CAPTCHA it didn't generate, so that wouldn't work. Good point about botnets though, that's a serious problem.  
> **username_4**: What would be even better would be some sort of algorithm that didn't require upper end hardware of any sort, and used less electricity to run. I can't imagine how that could work though - even if you based chances of solving a block on something like the combo of the current time and your IP address, you'd still get an advantage by using lots of IP addresses (and it would also result in stacks of low value hardware participating, instead of a lesser amount of high value hardware). Finding some sort of activity to perform that benefits people at the same time would be the ultimate achievement.  
> **username_1**: Year and a half after you originally asked this question, LiteCoin uses scrypt as a CPU-friendly algorithm, while PPCoin uses "proof-of-stake" to balance the electricity expenditures required for "proof-of-work". In retrospect, do you think any of them would've been a better BitCoin design than the original one? :)  
> **username_0**: @username_1: No. I now think that an ASIC-optimized mining algorithm is much more secure than a CPU-optimized one. You can rent a supercomputer or retask a botnet to attack a currency whose PoW algorithm works best on an ASIC.  
> **username_1**: Thanks username_0, though I find it intriguing. If you can repurpose a botnet or a supercomputer's timeshare to attack an ASIC/GPU friendly crypto-currency, how does that make it more secure than a CPU-friendly crypto-currency? Besides, both a botnet and a supercomputer could be used to mine scrypt-based currencies as well, and be very efficient at that...  
> **username_0**: You can't really repurpose a botnet or a supercomputer to attack an ASIC-friendly crypo-currency -- you pretty much have to invest in ASICS, and thus in the very crypto-currency you're attacking. That's why Bitcoin got it right.  

---

## 3 answers

### Answer by username_9 on 2011-09-13. Score: 16 | Accepted answer

The [scrypt key derivation function](http://www.tarsnap.com/scrypt.html) was explicitly designed to be resistant to hardware optimization, with an explicit trade-off allowed between memory and cpu usage:

> The scrypt key derivation function ... is designed to be far more secure against hardware brute-force attacks than alternative functions such as PBKDF2 or bcrypt.

This makes it better than SHA-256 or bcrypt if the intent is to give more of an advantage to CPUs.

Another option would be to include the same sort of variety of primitives that are provided for general purpose CPUs, e.g. a combination of floating point operations, access to large memories (perhaps including something that would use a large random access memory like a disk), etc.

But as username_2 point out, including some sort of anti-botnet feature might also be needed. A CAPTCHA might also make it rather unpopular, but some sort of work load that would indeed be noticed by a regular computer user might make it hard to hide botnet activity.

> **Comments:**
> **username_10**: Tenebrix is AFAIK the first crypto currency relying on CPU-friendly algorithms (specifically scrypt if I'm not mistaken). http://tenebrix.org/ Note there are some serious caveats with Tenebrix: https://bitcointalk.org/index.php?topic=47269.0  
> **username_11**: I think using a very large amount store would be interesting to explore. It would be very noticeable to a user, as "disk space left" is just about the only statistic they get. If that size is deduced from something difficult like the (high) primes it can be enlarged and shrunk as needed by the network. Interesting idea.  

---

### Answer by username_5 on 2011-09-13. Score: 7

I suggest [bcrypt](http://bcrypt.sourceforge.net/). It is not a cryptographic hash function per se, but it could replace SHA-256 and add some memory constraints that would make its implementation harder on GPUs.

Bcrypt uses blowfish to encrypt a string with a key derived from a password chosen by the user. So given a string and a target, finding a password that encrypts the string below the target works exactly like the Bitcoin lottery.  
As for the memory constraints, it is possible to implement bcrypt on a GPU, but it is much harder (probably impossible) to get the same kind of performance improvements we see with SHA. Here is an excerpt from a post on [crypto stackexchange](https://crypto.stackexchange.com/questions/400/why-cant-one-implement-bcrypt-in-cuda) about implementing bcrypt with cuda:

> Now bcrypt is a variant of the Blowfish key scheduling, which is
> defined over a table (a few kilobytes) which is constantly accessed
> and modified throughout the algorithm. Due to the size of the table,
> each core will have to store it in the GPU main RAM, and they will
> compete for usage of the memory bus. So bcrypt will run -- but not
> with full parallelism. At any time, most cores will be stalled,
> waiting for the memory bus to become free.


---

### Answer by username_6 on 2011-09-14. Score: 3

The choice of the SHA-256 algorithm for Bitcoin's proof of work has created what could be described as the most ideal application for botnets that one could possibly conceive of. Bot masters are looking for ways, essentially, to turn computation into cash. Bitcoin does that natively.

The huge risk is if the botnets take over the network. Given that botnets can comprise up to millions of machines (at their largest - most are much smaller than this), even with CPU mining a single botnet could potentially take over the network. For instance, assume a 2M strong botnet comprising Core2 Duo machines (5 MHash/s). This network would do 10 THash/s.

The only countermeasure to this is to have special mining gear that is more efficient than CPUs and GPUs, and not available on the average botted PC. This is why the community needs an ASIC-based mining solution.

> **Comments:**
> **username_0**: Sure, if you assume someone makes the ASICs available to all rather than keeping them to themselves.  
> **username_7**: There is no 2 million strong botnet.  Anywhere.  Storm Trojan is the largest known botnet and it has 250K nodes.  The second largest botnet has a mere 30K nodes.  SHA-256 is the algorithm that is used and to say it is "ideal application" for botnets is silly.  The very fact that GPU can efficiently accelerate SHA-256 is what gives bitcoin a chance against botnets.  Since 1 high end GPU can equal 200+ CPU it gives the "valid nodes" a multiplier effect.  Even if your unrealistic example 10TH botnet wouldn't have sufficient capacity to break bitcoin.  
> **username_8**: @username_7 How do you know the size of various bot nets?  

---

