Solving ENIGMA

In this post I’m going to walk you through how I solved the Hashflower’s ENIGMA puzzle. I want to outline my thought process and also provide a partial tutorial for others who may be unfamiliar with some of the tooling I used such as Etherscan, Opensea or IPFS.

What are Hashflowers?

In a Discord server a few weeks ago I came across some music from the Hashflower’s NFT project. This piqued my interest because the song’s melodies are based on the first 7 block hashes on the Ethereum blockchain.

Composer Elliot Cole wrote a computer program to transcribe blockhashes into beautiful melodies that he can warp and manipulate in real-time using a self-made software instrument.

The music is beautiful. It’s wistful, lush and atmospheric with the piano taking center stage and being affected by reverbs, delays and loopers. It’s pretty cool to know that the genesis of these tracks are Ethereum blockhashes.

What’s the Puzzle?

Elliot based most of the collection on the first 7 blocks of the Ethereum chain but he also included a fun puzzle for listeners to figure out. An 8th melody - the ENIGMA melody - was generated from an unknown hash value.

From Elliot’s medium post.

“All 100 pieces’ melodic DNA are drawn from the 7 genesis blocks of the Ethereum chain. An 8th category, ENIGMA, present a puzzle to the listener — if anyone decodes the correct value from the music, they are invited to contact me for a prize.”

Creating a Hashflower

To solve the puzzle we first need to understand how a Hashflower’s melody is created. Once we understand that, we can work backwards and use an ENIGMA melody to decode the hidden blockhash.

Here’s a quick summary of how a melody is generated.

  • A blockhash is selected (in our case 1 of the first 7 ETH blockhashes). A blockhash is a 64 character long hex value which is basically a “reference number for a block in the blockchain.” Here’s a wonderful deeper explanation if you’re curious.

  • The hex values of the blockhash are mapped to pitch space. A hex character can be 1 of 16 values (10 digits + 6 letters). Hex to pitch space is mapped linearly from 0 - F. With 0 being the lowest pitch and F the highest.

hex to pitch space
hex to pitch space
  • The Pitch Space values are mapped to diatonic space using musical scales to make them sound pretty and pleasing to the ear.

  • Now you have a melody derived from a block hash! If you have the programming chops, be like Elliot and program your own software instrument to manipulate the melody in real time.

Elliot’s medium post lays out the above process in great detail.  He even includes an example key graph for mapping hex values to the Ionian scale.  Very useful for our purpose of cracking ENIGMA’s code.

Now we know how the melodies are generated.  To solve the puzzle we need to go in the other direction - start with an ENIGMA melody and work backwards to map the musical notation to hex values. Lucky for us, hash values are highly unique so we only need the first 7 values or so to find a likely match.

Setting up the puzzle

The first problem is finding a suitable melody to deconstruct.  Elliot used loopers, delays, reverbs and other FX to mangle these melodies into the beautiful music you hear in each Hashflower.  That means the notes can at times sound muddled which makes them hard to transcribe.  So picking the clearest recording was necessary.

We also need to be aware of the scale we’re choosing.  Since Elliot provided us with a handy graph for the Ionian scale - let’s find an ENIGMA that uses it.

https://miro.medium.com/max/1400/1\*xfXtwc4F8wTab0aWZceaoQ.png
https://miro.medium.com/max/1400/1\*xfXtwc4F8wTab0aWZceaoQ.png

To do this, we go on the NFT marketplace OpenSea where we can browse through all the Hashflowers and sort them by rarity traits. Let’s search for all ENIGMA melodies that use the ionian scale.

I chose ENIGMA 089 because the opening piano notes are played slow and clear.  It would probably help to download the file so we can work with it.

How do we get the file?

Since storing lots of data on Ethereum is expensive, most NFT projects host their metadata and files using a decentralized file storage host such as IPFS.  Hashflowers does this as well. So we need to find the IPFS link to download our file.

OpenSea doesn’t provide a link to the IPFS so we must go to the contract and pull it from there.  Go to the details tab on OpenSea, copy the token id number and click the contract address.

This is the contract for scorpio.world - the art collective that helped release Hashflowers.  We need to query the contract to get the IPFS metadata link.

  • Click Contract

  • Go to Read Contract

  • scroll down to 21. tokenURI and enter our tokenId 152

  • Then query and follow the IPFS link: Hashflower 089

Examining the metadata

The IPFS link brings us to a page that hosts the metadata for this particular Hashflower. A link for the mp4 is included in the metadata so we can download the file.

Here’s the metadata for Hashflower 89:

{"name":"Hashflower 089","melody":"Mystery","description":"Hashflowers are generative music compositions created by Elliot Cole based on melodies drawn from the 7 genesis Ethereum block hashes, with art by Maxwell Arkin.  Blending the algorithmic, natural, and the handmade, these unique pieces invite you to get lost in dreamlike sonic forests of hashy meditation & contemplation. Attributes: the Ethereum block the melody is derived from, the musical scale it is rendered in, and whether or not the piece is a Ghost.","image":"ipfs://Qmd5x2gDjmMuCDrvsyGh9AkbwKZsnoejEVfrSvgu47mfEu/BLOCK_ENIGMA_089_IONIAN.mp4","external_url":"https://communifty.mypinata.cloud/ipfs/QmZqUfh88DPvZ5uzNkB2zkRv4oM1B3XR4tgfeVPnjW5vLM/BLOCK_ENIGMA_089_IONIAN.mp4","attributes":[{"trait_type":"Hashflowers","value":"All Hashflowers"},{"trait_type":"Hashflowers","value":"Scale: Ionian"},{"trait_type":"Hashflowers","value":"Block: Enigma (Scorpian Grasses)"}]}

You’ll notice that the melody key is marked as Mystery.

Here’s what the metadata for a normal Hashflower looks like:

{"name":"Hashflower 038","melody":"[F4, G4, Ab5, Eb6, G6, Bb4, Ab5, G4, Bb5, F6, C4, G6, Bb4, F4, G4, Bb4, Bb5, G4, C5, G5, Ab4, Eb4, Bb5, C6, Bb5, F4, G5, Bb5, C5, F4, Bb4, C4, Ab4, F4, Eb5, F5, F6, C6, Bb4, Bb5, G5, C6, Eb6, G6, Ab5, F4, Eb5, Eb5, Bb5, G5, G5, F4, Bb5, Ab5, Ab4, Ab5, Eb5, Ab5, G4, C6, Eb6, G4, Ab5, F4 ]","description":"Hashflowers are generative music compositions created by Elliot Cole based on melodies drawn from the 7 genesis Ethereum block hashes, with art by Maxwell Arkin.  Blending the algorithmic, natural, and the handmade, these unique pieces invite you to get lost in dreamlike sonic forests of hashy meditation & contemplation. Attributes: the Ethereum block the melody is derived from, the musical scale it is rendered in, and whether or not the piece is a Ghost.","image":"ipfs://Qmd5x2gDjmMuCDrvsyGh9AkbwKZsnoejEVfrSvgu47mfEu/BLOCK_4_038_HEX_AEOLIAN.mp4","external_url":"https://communifty.mypinata.cloud/ipfs/QmZqUfh88DPvZ5uzNkB2zkRv4oM1B3XR4tgfeVPnjW5vLM/BLOCK_4_038_HEX_AEOLIAN.mp4","attributes":[{"trait_type":"Hashflowers","value":"All Hashflowers"},{"trait_type":"Hashflowers","value":"Scale: Hex Aeolian"},{"trait_type":"Hashflowers","value":"Block: 4 (Peonies)"}]}

You can see that the metadata for a typical Hashflower includes the notes used in the melody.  Of course our ENIGMA doesn’t include the notes since it would make solving the puzzle too easy.

So now that we have the file and a general plan lets work on transcribing the melody.

Transcribing the Melody

We could transcribe these notes by ear but let’s make it easier.  Open up Ableton or another DAW and import the mp4.  Then right click the audio file and convert the melody to midi.  Ableton isn’t very accurate with MIDI transcription when there’s a lot happening in an audio file but this will give us a solid foundation to work from.

Hashflowers to MIDI transcription
Hashflowers to MIDI transcription

We can loop small sections of the track while moving the midi notes around until they sound correct. Since our note selection is restricted to the Ionian scale this goes pretty quickly. Once we finish transcribing the first 10 notes we can use our midi track as a reference to figure out the hex values. First we need to build a key...

Building a key

We need to draw a key to map the notes of the Ionian scale to their respective hex values. There are 7 notes in the Ionian scale - from the lowest C to highest B.  So we start with note low C = hex 0.

Note to Hex value

C = 0
D = 1
E = 2
F# = 3
G = 4
A = 5
B6
Then we go up an octave and repeat the notes
C = 7
D = 8
E = 9
F# = A
G = B
A = C
B = D
C = E
D = F

Now we start matching and come up with the beginning of a blockhash.  Blockhashes are prefixed with 0x which identifies them as a hex value.  After much trial and error matching notes we get the following.

0x932BB924A170795….

Since the other Hashflower’s melodies are derived from a blockhash lets assume that’s what we are looking for.

Hash Searching

Now we have the first 15 characters of a blockhash. We could transcribe the rest of the song to give us a full hash value but that would take a long time. It would be much simpler to find a blockhash that starts with those values and then spot check it against our midi clip.

How can we search for a partial blockhash?

We have a few options.

First, we can try to search Etherscan. Unfortunately for us Etherscan doesn’t have the functionality to search for partial blockhashes. Neither do any of the other providers I tried. ❌

We can sync up an ETH node and query it for our hex value. But syncing a node takes a long time and I’m not certain you can query a node using a partial value. So that one is out. ❌

We can use Google’s open Ethereum dataset to craft an SQL query and search for our blockhash. This seemed promising but was actually a pain to do. The searches were either too slow or too restrictive to be useful. ❌

Find an open dataset that contains blockhashes and search that. Here is an open dataset on Kaggle that contains the blockhash info we need. Bless this man for making this dataset. Let’s download it and do our search. ✅

Enigma

Open up the dataset in a text editor and ctrl-f to search for our hash value. Uh oh, that’s strange. There are no results found past the first 6 digits. Hmmm… doubts start to creep in.

Could the puzzle be deeper than we expected?  Why is it named ENIGMA?  Do we need to jump on wikipedia and read about the enigma machine to solve this?  The term Scorpian Grasses is used in the metadata.  Scorpion Grass is commonly known as forget-me-nots.  What do you not want to forget in crypto?  Your private key.  Ugh, are we going to have to decode more than this song to find a private key?

Maybe it’s not a block hash we’re searching for after all?

Solution

We could be missing something obvious. Let’s go back in to Ableton and check that our notes are correct. Sure enough there are 2 mistaken notes in our 15 note sequence - their hex values are off because they were incorrectly transcribed as an octave lower. Let’s fix that.

The correct values are:

0xD82BB924A170795….

Searching for a blockhash with these values yields no results. So it’s probably not a blockhash but it could be a regular address. Let’s try etherscan again.

Typing in these values on etherscan will autofill the search bar with the correct address!

0xD82BB924a1707950903e2C0a619824024e254cD1

This is the contract address for DAOfi - a precursor organization to Scorpio.world who are the ones that helped release Hashflowers. If we compare the hex values of the DAOfi contract address with our transcribed melody they match up exactly . It was an address we were looking for and not a blockhash.

🎉 We solved the puzzle 🍻

But why use the DAOfi contract address for a melody? Elliot says,

“The first person in web3 to take an interest in my art was Andrew Lee. I will forever be grateful for his support in helping to launch this project. I made the Enigma pieces as a kind of tribute, weaving the contract address for his gallery token - which at the time was called DaoFi - into its melody."

But wait, there’s more

After solving the puzzle I got in contact with Elliot and he graciously gifted me a Hashflower.

While I was working on this write up I watched a video that Elliot included in his medium post and noticed something odd. At 0:44 there’s a shot of Elliot sharing his code.

post image

It’s a quick shot but if you pause the video you can see that it includes the 7 blockhashes and 1 contract address used to generate the Hashflower melodies. That would’ve saved us a lot of time!

Next time we solve a puzzle let’s examine all the material beforehand.