On Thursday morning, a closely watched Bitcoin wallet address known as 1FLAMEN6 had a surprise transaction that drained the account of its five bitcoins, worth nearly $50,000 at the time. This Bitcoin wallet belonged to a crypto artist who goes by @coin_artist on Twitter, but she wasn’t despairing about the lost bitcoins—in fact, she was ecstatic.

The 1FLAMEN6 wallet was attached to a puzzle designed by @coin_artist and fellow crypto artist Rob Myers in 2015. The puzzle centered on a painting created by @coin_artist called “TORCHED H34R7S.” It was the final piece of a series of minor puzzles that had to be solved before the painting could be accessed for a shot at discovering the private key to the 1FLAMEN6 Bitcoin wallet. When @coin_artist saw someone had swiped the bitcoins from the wallet on Thursday morning, she knew the puzzle had finally been solved—almost three years after she created it.

@coin_artist told me that she hadn’t originally expected the puzzle to take so long to solve. After it was announced on the popular Bitcointalk forum, an obsessive community soon formed that was dedicated to solving the puzzle. Yet when no one was able to crack the code after months of effort, @coin_artist said interest in the project began to wane.

“People had largely given up prior to the bull run,” @coin_artist told me on Telegram. “I think Bitcoin’s price rejuvenated interest in 2017.”

According to Isaac*, the 30-year old programmer who actually solved the puzzle, he hadn’t even heard of the puzzle until a little over a month ago. (Isaac’s name has been changed to protect his anonymity. As he told me on Telegram, “it’s not safe to have Bitcoin in my country.”) He told me he originally found the puzzle because he and his wife enjoy solving riddles and he was deliberately looking for puzzles related to cryptocurrencies.

Read More: We Spoke to the PhD Student Who Found a Bitcoin Hidden in Some DNA

Isaac detailed his process of solving the puzzle to me in a chat, and his solution was corroborated by @coin_artist. He shared screenshots of his conversations with other puzzle players, and to prove that he was in fact in control of the coins, Isaac also signed a message to the wallet address using the phrase that was placed before the start of the Bitcoin wallet private key coded into the painting.

That phrase was “B34u7y, truth, and rarity.”

Like almost everything in the “TORCHED H34R7S” painting, the phrase is loaded with meaning. According to @coin_artist, it’s a reference to William Shakespeare’s famous poem, “The Phoenix and the Turtle.” The poem itself is something of a mystery and has been the subject of rampant speculation about who Shakespeare was referring to when he spoke of the Turtle and the Phoenix. Moreover a turtledove and phoenix feature prominently in @coin_artist’s painting.

It also had emotional ties to @coin_artist’s personal life.

Including this nod to Shakespeare in the painting “was important to me because events flipped my life upside down and I created this piece at rock bottom,” @coin_artist said. “The painting was also created during the toughest part of the bear market and those original bitcoins I loaded into that address were half of everything I had to my name. It was essentially a prayer that things would get better.”

The original painting of “TORCHED H34R7S” framed in @coin_artist’s home. Image: @coin_artist

HOW THE PUZZLE WORKED

Although the painting was done by @coin_artist, she worked closely with Myers to encode the key into the artwork. Retrieving the private key to the Bitcoin wallet required puzzle players to combine and extract two pieces of data from the painting: the data hidden in the flames flanking its edges, and the data hidden in the ribbons tied around the key in the bottom right corner.

The six ribbons tied around the key in the painting correspond to a six-bit cipher that acts as a literal key to the rest of the puzzle. There are two types of ribbons tied around the key—short ribbons and long ribbons— and each type corresponds to a bit value. Short ribbons are a 0 and long ribbons are 1, which means that the cipher hidden in the key has a value of 011010.

“I remember @coin_artist showed me some of the discussion about the puzzle and people were really interested in the chessboard,” Myers told me in a Telegram chat. “They were looking for a binary pattern. People seemed to be very interested in everything except the key, and it was literally a key.”

Next, it was time for @coin_artist and Myers to encode the private key to the bitcoin wallet in the flames. They started with the private key to the Bitcoin wallet, which was encoded in a Wallet Import Format, a 52-character string consisting of numbers and letters coded in base-58. (Base-58 is a way to render binary code as text which includes the numbers 1-9, and all of the upper and lower case alphabet, except ambiguous looking letters like “I”, or “O”, which could be misinterpreted as a 1 or a 0.)

After each character in the private key had been translated into its binary equivalent, @coin_artist and Myers added other data to the binary string, including the phrase “b34u7y, truth, and rarity” at the beginning to signal to the person working on the puzzle that they had found the Bitcoin key. The total string consisted of 76 total characters rendered as 608 bits. This binary string was then divided up into 6-bit chunks.

"People seemed to be very interested in everything except the key, and it was literally a key.”

Each of these 6-bit chunks was then subjected to a XOR operation (short for “exclusive or”). This operation basically takes two inputs in binary and compares the values of the bits in the string and then produces a new string based on the comparison of the bits. If the input bits match (say each of the strings start with a 1), then the output is 0. If the input bits don’t match (say if one string started with a 1 and the other with a 0), then the output is a 1. So for example, if two inputs are 0110 and 0101, the output would be 0011.

In the case of the puzzle, the input bits consisted of the six-bit cipher derived from the ribbons on the key paired with each of the 6-bit chunks from the 608-bit string encoded in the flames. After the XOR operation was applied to the entire string, the new string was then divided into 4-bit chunks, each of which represented a single flame in the photo.

Each bit in the 4-bit chunks represented a characteristic of the flame and each characteristic group could be represented as a bit: short (0) or tall (1) / red (0) or yellow (1) border /narrow (0) or wide (1) / purple (0) or green (1) interior—in that order. So, for example, a 4-bit chunk with the value 0110 would be a short (0), yellow border (1), wide (1), purple interior (0) flame in the painting. Once each flame’s four-bit value has been determined, these values are lined up as one big string. The flames are “read” starting in the inner left inside of the painting’s border going clockwise. Then the outer flames are read in a counterclockwise direction.

The red arrow shows the 6-bit cipher, coded in the red ribbons around the key. The flames around the border contain the key to the bitcoin wallet. Image: @coin_artist

After this flame pattern was coded, all that remained was for @coin_artist to translate the binary string into a visual flame pattern, which she described as a painstaking process.

“I was certain there was a mistake, even after checking the flames a million times,” she said.

HOW THE PUZZLE WAS SOLVED

According to Isaac, his first approach to solving the puzzle was to search for symbols from Alice in Wonderland because some aspects of the puzzle reminded him of Lewis Carroll's famous story. (The puzzles that preceded the SCORCHED H34R7S painting included frequent references to Alice in Wonderland, such as a poem about chasing a white rabbit.) So, Isaac began by printing out the drawing and looking for symbols by placing the painting against a mirror and even went so far as to write a bit of code that would allow him to virtually manipulate mirror images of the drawing.

“It was really funny, but didn’t help at all,” Isaac told me. “So I focused on the flames, which looked like code.”

After a few failed attempts to interpret the flames as code, Isaac sought out @coin_artist’s original post on Bitcointalk and began reading about possible hints and solutions that others had found. There, he noticed a cryptic post from a user named Trin who was also in a Telegram group dedicated to solving the puzzle that Isaac belonged to. So he struck up a conversation with Trin, who shared some of his insights into the puzzle.

How to read the information encoded in the flames. Image: @coin_artist

When I spoke to Trin, short for Trinitas, on Telegram, he said his big breakthrough occurred after @coin_artist released a high-resolution tiff image of the puzzle in December. At that point, he realized the flames were each a 4-bit string. The question was what to do with this information. Trinitas had a hunch about a XOR operation using the 6-bit cypher from the key being involved, but he was stuck on decoding the flames.

Using Trinitas’ clues, Isaac wrote a small program in Java to allow him to XOR the 6-bit cypher and the binary string included in the flames. According to Trinitas, after he offered his clues to Isaac, he solved the puzzle within 20 minutes.

Isaac’s prize is actually larger than $50,000, since the bitcoins in the 1FLAMEN6 wallet were purchased back in 2014. This means that he can also lay claim to five bitcoins on the major Bitcoin forks that have happened since then, such as Bitcoin Cash. This was something Isaac himself had forgotten until he was reminded to claim those other bitcoins by the puzzle community. As a thank you for his insight that led to the puzzle’s solution, Isaac sent Trinitas half of a bitcoin and told me he plans on HODLing the rest.

As for @coin_artist, she said she’s still making cryptoart, but is getting out of puzzles. Her most recent project is a collaboration with the creators of the video game Neon District. The prize for discovering an easter egg hidden in the game is 15 ether, which are worth about $15,000.