This has been a while coming. Like many others, after bumping into cryptonight, the memory intense hash function behind Monero, I’ve been trying to optimize it. As a first step to doing this, I started to rewrite it in full, and then immediately realized that involves quite a lot of fairly stock stuff that really isn’t time critical. And like (almost) everyone else, I thus dropped that and started messing with other aspects. But then, off and on, I did rewrite parts of it, until I decided to just gather it all up, fill in the left-out parts, and put it together. So here it is:
FAQ
What is this?
This is an implementation of cryptonights slow-hash in python. It has no dependencies, reimplementing AES, Keccak, Blake, JH, Groestl, and Skein in pure Python. It also comes with a small main() that runs an example case and checks it. It can be adjusted for before and after the upcoming Apr 2018 hard fork.
Why?
Mostly to have a single, self-contained implementation to base other things on.
Is it fast?
Goodness no. As mentioned, it runs everything in pure python. It’ll do a little less than two hashes a minute on a machine that typically does around 50-70 hashes per second using a typical implementation.
Can I mine with it?
As presented, no. It doesn’t implement a full daemon, nor a way to fetch work from pools. There isn’t much point, since it’s extremely slow. If you mean “am I allowed to mine with it?” then sure, feel free to, but there isn’t much point.
Can I base other implementation on it?
I don’t know, can you? (rimshot) Yes, certainly, that’s the point here. I don’t know how much easier to follow it ended up being, but by all means learn from it and use it to implement it in other ways.