Overview
After a few dark nights of the soul, I was able to work through how the encryption/decryption can work off-chain. It still has some flaws, but I think it's a good step to handle something not natively done on Ethereum.
The quick version: it will handle the pressing of content in a wrapper process command line interface (CLI). This will coordinate creating content on the block via a Solidity contract, the contract will emit an event that goes into its transaction log, the CLI process will listen for this event, read the logs and encrypt the data along with it's unique path to each item on the blockchain and produce a final hash representation of all this work. The final hash produced will be the unique fingerprint of the entire content and when it's time to decrypt, the final hash will be used with the sender's private key and it will be able to trace through the block paths to reconstruct the original content in order.
The main flaws in this implementation are:
- Actual The sender's private key must be passed around to decrypt. In the Additional Accomplishments section below, I've outlined a potential workaround for this. To sum it up, a Meta-Agreement Layer should be built to grant access, and its private key should be used to decrypt, not the Creator's private key.
- Potential If the Ethereum network is moving slowly, the delay may cause the off-chain solution to hang or never complete. I'm not sure how to test this, but it's a bridge that will be built when the chasm is discovered.
- Actual If the final hash is lost, the content is lost.
A quick comparison of synthetic gas fees:
┌─────────┬──────────────────────────────────────┬──────────────┬───────────┬───────────┐
│ (index) │ Operation │ Gas price │ Gas fee │ In USD │
├─────────┼──────────────────────────────────────┼──────────────┼───────────┼───────────┤
│ 0 │ 'novel hashing of "Hello, world!"' │ '1016994671' │ '1143597' │ '$2.6248' │
In the above, prior to any attempt at encryption you can see the fees associated with pressing the phrase "Hello, world!", assuming none of the characters or pairs of hashes exist, cost about $2.62.
│ 0 │ 'novel hashing of "Hello, world!"' │ '1017446225' │ '4705166' │ '$10.7920' │
Above is from my dummy encryption encryption venture last week, where I roughed out where encryption may go in the flow of the contract, but did it all on-chain. Naturally, it's much more expensive due to the computing required by the sender. You can see it's over 4 times as costly to press the same "Hello, world!" phrase, assuming none of the characters or pairs of hashes exist.
│ 0 │ 'novel hashing of "Hello, world!"' │ '1017446225' │ '1713408' │ '$3.8680' │
Finally, in my off-chain encryption implementation, the fees return to much closer to what they were initially. As you can see, it costs about a dollar more in USD costs, which is due to the extra event emitting happening in the contract in comparison to the first example, however a ton of computing is done off-chain so it saves the sender a good amount of money.
Last Week
What I Said I'd Do
- Finish and merge in the refactoring of the HashRegistry contract to handle encrypted content ticket
- Come up with an off-chain encryption solution and document it in a ticket #34
Iceboxed Priorities
- Build out a method for retrieving the DecxDAG hash from the contract via an API endpoint and viewing the original string (3 weeks week ago)
- Deploy the built contracts to a testnet (from 4 weeks ago)
- Plan how the API will work, what endpoints and methods it will have, and which tools I should use to implement it (from 4 weeks ago)
Additional Accomplishments
- Built out off-chain encryption solution (dEKS) and put it up for PR #37
- Documented how dEKS works
- Wrote a WIP ticket to idenfify access layer for decryption #36
Next Week
- Get #37 merged
- Begin work on building out the CLI #35. Additionally, this will encompass many of my iceboxed priorities.
Blockers
None.
Reflections on Process
I'm putting in more time to this than the 3 hours this class suggests. I'm definitely starting to feel the burn of it. It still feels very exciting and there's tons of unique things to think about and problems to solve, but I do wonder what will happen to my motivation if I get stuck in a big task for over a week and I can't figure it out. This project beckons me on a deeper level, but I wonder how I will feel about it at semester's end.