You probably know that the heart of your computer or smartphone, the part where the "magic" happens, is the CPU. But did you ever wonder what that microchip is really doing if you look "deep down" through all the layers of the graphical user interface, the programs and the apps, even the operating system itself?
The lowest level that is still normally accessible software is called machine code. It consists of instructions where each single one is doing something very simple like adding two numbers or checking whether one number is bigger than the other. A modern CPU executes many millions of instructions per second which then together do something useful. They are encoded on the level of bytes; if your typical Intel or AMD CPU sees a byte e.g. with a value of 64, it will take that as an order to increment a number by 1.
Not all CPUs exist as physical chips that power real devices. People have invented "virtual" CPUs with own instruction sets for various reasons, and then went on to implement them in software running on a "real" CPU.
One place where you can see that in action is the Monero cryptocurrency. The system is called RandomX, and whoever wants to earn some Monero by "mining" has to execute programs in the corresponding instruction set as fast as possible, using a virtual RandomX CPU, in the hope that the output of a program run satisfies some condition that is necessary to win the reward for a block.
RandomX knows about 30 instructions. Typically several byte values encode the same instruction; e.g. 0 to 15 all mean a particular variant of addition for a RandomX CPU. Overall every possible byte value from 0 up to 255 is mapped to an instruction.
The reason why it makes sense for Monero to use such an elaborated scheme for mining and go as far as implementing some fancy fantasy CPU can't be explained with a few sentences, but the fundamental goal is easy to state: Nobody shall be able to build machines that mine Monero 1,000 times faster and get an unfair advantage that way.
Monero miners were not happy. A few weeks ago a new version of the Monero software had gone into service in a so-called hardfork which included some changes in the RandomX instruction set, and since then people reported frequent random crashes of their machines when they ran mining software. It was all very mysterious because it wasn't that software itself that crashed, but other programs running at the same time, and sometimes even the operating system itself.
Of course it should be altogether impossible that a normal program brings the OS down and forces you to restart the computer, and normally it was, but with those RandomX miners it was somehow different. People with the necessary debugging experience said after analyzing the problem that sooner or later random bytes anywhere in the main memory of the computer changed, seemingly without the mining software being involved in any way, which obviously sounded quite crazy. That mystery had started to make waves even beyond cryptocurrency circles.
My personal involvment in all this started when Matt contacted me for a private chat over IRC. He was one of the Monero devs working on the RandomX code and had implemented the instruction set change.
<matt> I feel really bad about our software crashing people's computers left and right. And think about the bad image that Monero will get. That needs to stop. Maybe you can help
<rbrunner> How so? I don't know much about RandomX, or about debugging random computer crashes
<matt> Maybe. But you are a fan of "thinking outside the box", and maybe exactly that is needed here. Can I tell you a secret?
<rbrunner> I love secrets :)
<matt> We told the world that we changed RandomX to discourage people developing dedicated fast hardware for it, just to be on the safe side
<rbrunner> Yes, and that makes sense, doesn't it? Keep up a credible threat of financial loss because hardware may become obsolete through our changes
<matt> Right. But it's a lie
<rbrunner> And the truth is the secret you want to tell me?
<matt> Somebody donated a big amount into the general dev fund to get a new instruction implemented according to their spec
<rbrunner> "Somebody"? Do you know who it is?
<matt> Nope. Anonymous
<rbrunner> And you don't know why either I guess?
<matt> No, motivation is completely unclear
<rbrunner> Crazy. I also want my own private RandomX instruction! Nobody saw any problem with this?
<matt> Why? RandomX is called RandomX because basically it calculates random values. Now it calculates some different but still random values.
<rbrunner> If Monero miners now help to find the values of physical constants needed to build better atomic bombs? Still no problem?
<matt> Well, even if, how would you get those values out of the miners and collect them?
<rbrunner> Hmmm. Seems you are right. Still strange. At least the donation was worth it?
<matt> You bet.
I now had two deep mysteries on my hands, the random crashes and the formula, and no idea whatsoever whether they were somehow connected, and if yes how. But anyway, I started to dig.
The new RandomX instruction calculated subsequent terms described by said formula, something like those endless series in the style of 1/1 + 1/2 + 1/4 + 1/8 + 1/16 + ..., but of course more complicated and elaborate. Where did this come from, and what did it mean?
By lucky coincidence I had read a story about a man from India called Srinivasa Ramanujan a while ago. In the late 1800's and the early 1900's he had filled several notebooks with extraordinary mathematical formulas that later turned out to be correct, opened entire new areas of mathematical work and inspired a vast amount of further research. To this day it was unclear how this largely self-taught man had derived all this, and some of his formulas really looked like out of this world.
I browsed through some of his works on various websites, and was lucky again: I soon found "our" formula, it really was from Srinivasa.
What now? I decided I needed somebody who could tell me more about the man and his discoveries. After some googling I stumbled over a site called mathemagicals.com mentioning him and filled with some pretty wild-looking stuff, but I thought why not talk with somebody maybe a little crazy about two crazy problems, and arranged a video call with the site's author, a guy named Curt.
I asked him what somebody could possibly get out of having terms of such a formula calculated over and over again, without mentioning Monero or revealing which formula exactly. It became an interesting conversation.
"Did you ever ask yourself whether numbers exist?" Curt asked me.
"What do you mean? Whether numbers are not only human mathematical inventions, but really exist somewhere, somehow?"
Curt nodded. "Yes. I have a theory that our universe contains a not yet discovered fifth dimension, a mathematical one, where numbers exist and are every bit as real as matter in the known dimensions. How else would so many things be so full of math, like all those laws of physics?"
I was really curious where the hell this would lead. "And in that extra dimension the number 3 lives, say as a green triangle, next to the 5, which is blue?"
"Something like that." Curt smiled. "I believe whole numbers exist there in almost infinite instances. Not only one 3, but many many of them. Almost like atoms, or elementary particles. They are the building blocks of more complicated things, and even beings."
"Well, yes, some sort of conscious beings. I call them numerators" Curt declared proudly.
It took me half a minute or so to digest this before I could continue: "Alright, interesting theory. But how would you prove it, how could we know about those numerators? You think we can talk to them somehow?"
"They seem to talk to us, sometimes. Take Srinivasa. Do you know what he said about the source of his astonishing mathematical insights?"
"Yeah, he claimed that the goddess of his family revealed them to him. How was it called again?"
I started to understand. "You claim that this was such a numerator from the mathematical dimension, talking to him?"
"Exactly, one especially eager to contact us" Curt confirmed, and continued: "You know, the story you told me, about calculating one of Srinivasa's formulas over and over again, sounds to me as if somebody tries to get the attention of Namagiri Thayar and then establish contact with that being."
"You mean like summoning a ghost?"
"I see. But what could that be good for?"
He started to get excited. "Do you have any idea what it would be to talk with such a deeply mathematical, almost god-like being? How many yet unknown and therefore very valuable truths about math you could learn?"
That was an interesting thought, and so I almost forgot to ask an important question: "But what about those computer crashes? Do you have a theory there as well?"
I waited patiently while Curt mulled the question over. Finally he said: "Well ... maybe the numerator tries to interact with the computers, and that's the unfortunate result?"
A few days later I had another IRC chat with Matt. I decided to keep quiet about my findings for the time being, just in case.
<matt> Our problems with Monero mining will soon be over.
<rbrunner> They will? How come?
<matt> We decided to replace that mysteriously problematic new RandomX instruction by one that just innocently multiplies by 3
<rbrunner> And there are no more crashes with that?
<matt> No. And as much as I would like to learn the secret behind all this, I also voted for the proposal. We must restore order
<rbrunner> So there will be another hardfork soon to implement the change?
<matt> Yes, as soon as reasonably possible. Testnet will already switch tomorrow.
Tomorrow Monero mainnet would fork to a modified-again version of RandomX, and about a million computers scattered over the whole planet would suddenly stop to calculate terms from Srinivasa's formula. If this constituted a signal of any kind it would suddenly vanish. Despite feeling a bit silly about it I decided to take the last good chance and attempt to test Curt's theory myself.
I made the 3 computers in my household run a modified RandomX miner at full speed that I had doctored to execute that "magic" instruction 100% of the time, not only with an average chance of 7/256, in an attempt to maximize the signal, so to say. I went to bed, trying to visualize the formula and think about Srinivasa as long as I could until sleep finally came.
And then I had a dream.
I saw modulo operations on big numbers happening, and despite not knowing much about the subject it was clear to me that I was watching elliptic curve cryptography in action. A bit later I saw how terms of the formula I knew so well now were calculated. And then, like a flash out of the clear blue sky, a sudden insight hit me:
There was something in there that was called isomorphism in math. You could take the task of breaking ECC based encryption, the so far pretty much impossible task of deriving private keys from public keys, and sort of translate it to another mathematical domain where the needed calculations were so many magnitudes fewer and faster as to make the job almost trivial.
And the formula had to do with that other domain. Certainly the unknown person donating for having it included in RandomX had already some suspicions about that fact but was still missing important pieces of the puzzle.
With the prospect of getting to know how to break ECC and then undoubtedly become famous, or rich, or both, I got so excited that I woke up before the dream could progress to the final crucial details.
And the hardfork would happen in a few hours now.
<matt> Did you hear? It seems somebody solved the mystery of the crashes
<rbrunner> Somehow I highly doubt that, but do tell
<matt> Do you remember the "row hammer" exploit from a few years back?
<rbrunner> Something with trashing bits in memory?
<matt> Yes. It turned out that with carefully selected memory access patterns you can stress modern DRAM chips so much that they produce random bit value flips every now and then, and if you are lucky you can poke holes into memory protection that way
<rbrunner> Splendid. And the connection to our RandomX troubles?
<matt> Somebody found out that a miner executing our ill-fated new instruction fetches memory in a way that leads to effects similar to row hammer
<rbrunner> That sounds pretty improbable, if you ask me
<matt> Yeah, to be frank I thought so as well. But still better than other theories that seriously claim that witchcraft is involved somehow, lol
<rbrunner> Or extra dimensions
<rbrunner> Nothing :)