The engineering team at Enigma has been extremely hard at work for most of this fall developing the new, exciting and upcoming release of the Enigma Protocol, code-named Discovery. We started off from our developer release (dated June 30th, 2018): a self-contained dockerized network that leverages Intel’s Software Guard Extensions (SGX) as our implementation of choice for Trusted Execution Environments (TEEs) that provides guarantees of strong correctness and privacy for computations across the Enigma network.

The biggest milestone of that initial release was the introduction for the first time of secret contracts, as well as the computation engine that makes them possible. Secret contracts are similar to smart contracts in that they are self-executing contracts that exist across a distributed, decentralized network that enable the development of decentralized applications (dApps). The key difference that the data itself (inputs and outputs to the contract) is concealed from the nodes that execute the computations. This enables dApp developers to include sensitive data in their smart contracts, without moving off-chain to centralized (and less secure) systems.

The initial release of our network provided a sandboxed environment for developers interested in getting a head start developing dApps with the ability to run general-purpose private computations not found elsewhere in the entire blockchain ecosystem. Some early examples of secret contracts built on top of Enigma include the Millionaires’ Problem and Secret Voting. But this initial release also came with several limitations, which we are currently addressing in our upcoming Discovery release.

On EVM and WASM

Standing on the shoulders of giants, we based the first implementation of our secret contract execution engine off Ethereum and its virtual machine, the Ethereum Virtual Machine (EVM). We were bound to using smart-contract-specific programing language solidity for coding secret contracts, and with that came well-known limitations around the complexity of operations the Enigma protocol can execute. Of these limitations, the most apparent one is the inefficiency associated with the EVM, which was designed with security but not scalability in mind. The EVM is a somewhat simplistic instantiation of a Virtual Machine (VM), that lacks many required optimizations and features. The word size is fixed at 256-bit, making it incompatible with current hardware that is designed for 32/64-bit operations. As a result, the EVM is orders of magnitude slower even when running its code locally, compared to compiled, or even interpreted code running on modern VMs. In addition, the EVM, being built solely for Ethereum, cannot utilize common libraries that exist outside of the world of blockchains, nor can it natively interact with web services and external data sources (for which it needs Oracles).

We are now ready to move past those limitations. We have opted for a more generic and capable implementation using WebAssembly (or WASM for short). WebAssembly is a specification for a stack-based Virtual Machine designed to be efficient and fast (executing at native speed taking advantage of common hardware capabilities available on a wide range of platforms) and safe (providing a memory-safe, sandboxed execution environment). Rather than reinventing the wheel, we adapted the Parity WASM interpreter (wasmi for short). For a good argument on why to move the execution engine from EVM to WASM, see this excellent article from Parity.

Given the many benefits WebAssembly presents, it is no wonder that many projects in the space, including Ethereum as it moves to its 2.0 release, are choosing it as their de-facto VM. In addition to validating our choice, having a common VM shared across projects that is also supported by large organizations outside the decentralized web movement (such as Mozilla) could greatly increase future interoperability between Enigma and other solutions in the stack. Furthermore, given the focus of the Enigma protocol on privacy, security is paramount, and WebAssembly presents security benefits alongside a significant performance boost.

WebAssembly also allows a host of common languages that are supported and compile down to WASM bytecode (e.g., C++, Rust, Typescript). For our current implementation, we focused on Rust as the language of choice for secret contracts, as it provides unparalleled safety. Rust is considered a much safer programming language than C for example (in terms of being type-safe, memory-safe and exception-safe) by design as you will never endure a dangling pointer, buffer overflow or any other kind of undefined behavior. Arguing for the safety and efficiency of the Rust language and their breakout features while avoiding garbage collection quickly falls out of the scope of this document; if you are interested, Meet Safe and Unsafe.

Enigma, Ethereum, and State

In the upcoming Discovery release, the Enigma protocol no longer uses the EVM as its execution engine, but still relies on Ethereum as its consensus layer. Our developer release back in June also relied on Ethereum to serve as the peer-to-peer layer. Messages (e.g., inputs for computations) that were needed to be broadcasted to the Enigma network were stored inside of an Ethereum transaction payload. This was greatly limiting given the current scalability issues of Ethereum, and quite costly in terms of gas. To support more scalable, efficient execution, as well as more intricate features such as stateful secret contracts that live and breathe in the Enigma network (and don’t rely on Ethereum), we had to design from the ground up a peer-to-peer protocol for Enigma. This took a lot of work — both in terms of design and implementation (which largely uses libp2p as a foundation), which we will describe at more length in the future.

In a nutshell, the peer-to-peer network is composed by a multitude of interconnected nodes that can communicate directly to one another to exchange information. The information that nodes exchange relates to computation tasks, their encrypted inputs and outputs, and the encrypted state, but they do not maintain a distributed ledger, and thus do not constitute a blockchain yet. However, in the future, the peer-to-peer layer will also serve as a critical building block to Enigma’s becoming chain-agnostic and chain-independent (i.e., running its own blockchain).

Currently, Enigma relies on Ethereum, its hashpower and its tamper-resistance as its trustworthy consensus mechanism. Like in our first release, we deploy a smart contract on Ethereum that keeps a record of the active worker nodes in the network, the computation tasks that get queued for processing, and equally important, the results of these computations, in the form of hashes and proofs.

One of the early trade-offs we had to make in our previous release was to give up the ability to maintain a state in between computations, resulting in stateless secret contracts. And of course that was not a limitation introduced because of our choice to use the EVM, but because of the complexities associated with holding a state (let alone an encrypted one) in the Enigma network. Thus, for the sake of simplicity — and recognizing that our choice of a secret contract engine could change in the future — we pushed that feature to a future release. Now, in Discovery, Enigma will offer stateful secret contracts in WASM. By moving both the storage and the peer-to-peer functions from Ethereum directly to the Enigma network, holding state is made possible.

In summary, the last few months saw a lot of major architectural changes to the Enigma network. Most importantly, these included a complete redesign of the execution engine (WASM), the peer-to-peer layer and the storage layer. While previously all of these relied on Ethereum on one way or another, they are now all embedded directly into the Enigma network. This allows us to introduce many new cool features, helps us scale significantly better, and prepares us better for future network upgrades. We’ve been so excited about these critical improvements into our platform that we’ve been proactively presenting them across the world. We’ve received great feedback :)

Discovery Release Features

In summary, we are getting closer and closer to the Discovery release of the Enigma protocol that includes the following features.

Stateful (Encrypted) Secret Contracts: Secret contracts are capable of maintaining a state, allowing to persist encrypted data between private computations or different tasks. Stateful contracts enable many more use cases than stateless computations.

Secret contracts are capable of maintaining a state, allowing to persist encrypted data between private computations or different tasks. Stateful contracts enable many more use cases than stateless computations. Secret Contracts are decoupled from Smart Contracts: The Enigma network only relies on Ethereum as the consensus layer, but is otherwise decoupled from the requirements and limitations of Ethereum. This means that secret contracts can have their own runtime and programming language (Rust, instead of Solidity).

The Enigma network only relies on Ethereum as the consensus layer, but is otherwise decoupled from the requirements and limitations of Ethereum. This means that secret contracts can have their own runtime and programming language (Rust, instead of Solidity). Private Outputs: In addition to private inputs, the network supports storage of computation outputs by storing the contract state encrypted on chain and sending results encrypted directly to the dApp user.

In addition to private inputs, the network supports storage of computation outputs by storing the contract state encrypted on chain and sending results encrypted directly to the dApp user. Economic Incentives: Each node receives a financial reward for participating in the network. Nodes are randomly selected to work in any computation by lottery weighted by the amount of ENG tokens they stake.

Each node receives a financial reward for participating in the network. Nodes are randomly selected to work in any computation by lottery weighted by the amount of ENG tokens they stake. Ethereum integration: Secret Contracts may call arbitrary functions of any other smart contract deployed on Ethereum.

Secret Contracts may call arbitrary functions of any other smart contract deployed on Ethereum. Peer-to-peer and storage layers: Completely redesigned from scratch, these functions are now an integral part of the Enigma network and no longer rely on Ethereum.

We are currently working to finalize the first fully working implementation of the Discovery release, aiming for a release on Ethereum testnet in the first quarter of 2019. Please stay tuned for more details.

Want to build something with Enigma? Check out our documentation to get started — or, if you’re a project or enterprise, submit your interest here.

Want some ideas on what to build? You can read through our Solutions blog or look at our launch partners — or you can walk through our tutorials.

Want to run a Secret Node with Enigma? Learn more in our recent blog post — and join our community Secret Node Telegram to stay up to date.