Bitcoin Institute

BlackEye

one week of speedups that Satoshi thanked by name

People

A dark navy illustration shows the name BlackEye at the top left. A tilted frame on the left holds four colored tiles, with the tags "UNALIGNED DATA" and "CRYPTO++ 5.6.0" below it. A thick band runs from it over a chip in the center marked "SHA-256" and reaches four tiles lined up in a straight frame on the right. Below the chip is the tag "SSE2 ASSEMBLY." At the lower right are a sheet of lined paper and the tag "SOURCE SHARED."

On July 26, 2010, a BitcoinTalk user called BlackEye made a request of Olipro, who was handing out faster builds of Bitcoin. The builds came without source code, and BlackEye wanted to be able to check the changes and compile them independently. The reply came a minute later: anyone who did not trust the builds was free not to use them. BlackEye answered that there was no need to be hostile.

BlackEye (BitcoinTalk post, July 26, 2010, 12:38:27 PM UTC)

I think this goes against the spirit of open source. Modified binary only releases don’t help progress the software and create an unnecessary dependency on an individual to provide those binaries.

BlackEye had earned the right to say so. Within six days of joining the forum, BlackEye had produced faster builds and shared them with the modified source. The next day Satoshi Nakamoto took the work from one of those builds into the official source.

2010Registers and posts forthe first time (July 20)Reports a faster buildcompiled from source(July 21)Wires in the Crypto++SHA-256 (July 25)Asks Olipro for sourcecode (July 26)Satoshi adds the codeto SVN (July 27)Named in the 0.3.6announcement (July29)2012Last post (April 7)

Answering Satoshi’s call (July 20–22)

On July 18 Satoshi had written that faster SHA-256 code would be very welcome. The code Bitcoin used was more than two years old, and it was the only SHA-256 implementation Satoshi had tried. Generating bitcoins means running the SHA-256 hash function over and over, so a faster hash yields more coins from the same machine.

BlackEye registered on the evening of July 20 and, twelve minutes after registering, wrote a first post in the thread where Satoshi had asked. The post suggested the implementation in a library called PolarSSL, which had been 1.5 times as fast as Bitcoin’s code in a simple test. In an edit a little over an hour later, BlackEye took the claim back. The source showed that Bitcoin computed two hashes and counted them as one, so PolarSSL was probably not faster after all.

The next day BlackEye stopped testing and compiled Bitcoin itself. BlackEye adapted the PolarSSL functions and verified that they produced the same hashes as the original code. By July 22 the build was available for download, together with the modified source. That build used a newer version of the database library, which changed the data format and made it impossible to go back to the standard client. When another user objected, BlackEye posted a rebuild against the same library version as the official release before the day was over.

The Crypto++ assembly code (July 25–27)

On July 25 BlackEye released a third build.

BlackEye (BitcoinTalk post, July 25, 2010, 10:12:23 PM UTC)

I was able to integrate the SHA256 functionality from Crypto++ 5.6.0 into Bitcoin. This is the fastest SHA256 yet using the SSE2 assembly code.

Crypto++ was the cryptography library Bitcoin had used from the start. Its newer version included a fast SHA-256 written with the processor’s SSE2 instructions, but it did not work when simply dropped in. The code assumed that its data sat at aligned positions in memory, and Bitcoin was passing it unaligned data. BlackEye got it running by swapping in an instruction that can read unaligned data.

BlackEye’s request to Olipro for source code came the following day. Olipro replied with links to the Crypto++ library and to the SHA-256 code he had used. A day later BlackEye explained, with a link to the earlier post, that the code would run once the instructions that required aligned input were changed, or once the data was aligned.

On the evening of July 27 Satoshi posted, quoting BlackEye, that part of Crypto++ 5.6.0 was now in SVN. Satoshi had chosen to align the data instead of changing the instruction.

Satoshi Nakamoto (BitcoinTalk post, July 27, 2010, 6:27:30 PM UTC)

I aligned the data fields and it worked. The ASM SHA-256 is about 48% faster. The combined speedup is about 2.5x faster than version 0.3.3.

Two hours later BlackEye replied that the files taken from Crypto++ could be cut from the eleven Satoshi had kept to five at most.

A name in the announcements

Two days later, on July 29, Satoshi released version 0.3.6. Its list of changes includes “Crypto++ ASM SHA-256 thanks to BlackEye.” In a notice on August 3, Satoshi gave the credit again.

Satoshi Nakamoto (BitcoinTalk post, August 03, 2010, 11:40:18 PM UTC)

Also, don’t forget, we recently added 2.4x faster generating thanks to tcatm’s mid-state caching optimisation and BlackEye’s help getting ASM SHA-256 working.

The code stayed in Bitcoin until version 0.5 removed it in November 2011.

BlackEye wrote 14 posts in the eight days up to July 27, and only three after that. In January 2011 BlackEye asked the operator of a betting game how players could verify that it was fair. A one-line post followed in July, and on April 7, 2012, BlackEye reported a crash in version 0.6.0 with the log attached. The BitcoinTalk profile counts 17 posts and gives June 23, 2018 as the last active date. Of the 17, 13 are on this site.

Primary sources

18 entries / 2 threads