Cypherium | How the Cypherium Virtual Machine (CVM) Advances Smart Contracts

Cypherium
Cypherium
Published in
5 min readAug 20, 2018

It seems that the general public — people who have done one or two Google searches — still think of blockchain as a highly efficient, intensely accurate kind of excel spreadsheet. But there are also many people outside of the crypto world who are beginning to understand the revolutionary potential of distributed ledger technologies as smart contract platforms. It is no longer just the enthusiasts: people in a wide range of business, law, and tech industries are explaining to their families, coworkers, and bosses, how blockchain can and will change their lives in practice.

Most of these conversations have cohered around the term smart contract. And for good reason: automated, self-executing contracts are not just easy to comprehend, but maybe more importantly, smart contracts are a conceptual key that unlocks the expansive, panoramic view of blockchain’s role in shaping the future. For example, once you understand that smart contracts can automate a simple gambling bet, it is only a few steps to imagining decentralized home insurance.

But a crucial part of this story, one that often goes overlooked, plays a huge role in determining what blockchains will be able to practically accomplish what smart contracts promise. Every blockchain since Ethereum operates as a smart contract platform. However, in addition to hosting the script, a successful 3rd generation blockchain needs to execute its contracts as well. This is one of the ways in which Cypherium distinguishes itself from Ethereum and its peers: the Cypherium Virtual Machine.

What is a virtual machine?

A virtual machine is a secure, trustless runtime environment that allows anyone to execute arbitrary code. Virtual machines play an integral role in the successful implementation of smart contracts, as they allow any network participant to access and run a smart contract’s code while securing the integrity of that contract. In other words, anyone can execute the contract, but no one can violate its design or change its intended outcomes. You can think of a virtual machine as a kind of simulated computer. Depending on the particular virtual machine, different kinds of hardware devices can access the simulation and effectively perform its operations.

Why is it useful for blockchain & smart contracts?

Any new distributed ledger technology should be able to uphold Bitcoin’s simple yet revolution standard: permissionless access to permanent data. But for smart contract platforms like Ethereum this becomes a bit trickier. In addition to ensuring that the transaction is valid, with the proper encoding and signatures, participating nodes on smart contract platforms also need to guarantee a fully determined outcome for the smart contract’s code, and that running one smart contract on the blockchain will not interfere with the terms of another.

So, as you can imagine, virtual machines allow network participants to guarantee the success of their smart contracts. In fact, virtual machines might be the single most important element in getting permissionless, trustless code to scale effectively. As on-chain contracts, applications, and enterprises continue their exponential growth, a line of faulty code might prove to have catastrophic potential.

The Ethereum Virtual Machine (EVM) is pretty much as good as it gets right now. EVM is a successful runtime environment that allows anyone to run its code arbitrarily. Crucially, it is isolated from the rest of the protocol’s main network. In order to be an effective testing environment, a virtual machine needs to be able to flag a failed contract without disrupting the functionality of the main net. The EVM remains an important part of Ethereum’s pioneering technology. However, even within the Ethereum community, many have identified the EVM’s vast room for improvement.

CVM vs. EVM

Cypherium makes a number of innovations towards the scalable implementation of a smart contract virtual machine. Notably, they include: Dalvik architecture, SafeMath, fixed-point representation, and 64-bit words. Now let’s go through those one by one.

First, Dalvik. The Ethereum Virtual Machine uses what’s known as stack-based architecture, which has the advantage of rigidity in such an open system, as only the data stored at the top of the stack is available for recall in the machine’s memory. However, the Cypherium Virtual Machine (CVM) uses Dalvik architecture, which is register-based, making the machine both faster and more openly available. The Dalvik is a Java Virtual Machine originally adopted by Google’s Android operating system. Using such lightweight architecture will enable CVM to operate on mobile devices. To demonstrate what I am talking about in detail, let me quote quickly from the white paper:

Here’s a simple arithmetic calculation performed by CVM:

INC %1 (Register 1 value +1, Reg1 = 1)

INC %2 (Register 2 value +1, Reg2 = 1)

INC %1 (Register 1 value +1, Reg1 = 2)

ADD %2 %1 %2 (Reg2 = Reg1 + Reg2 = 3)

This code calculates the mathematical expression 1 + 2, and the result is 3. The equivalent EVM code is:

PUSH4 1 (Push 1 on stack)

PUSH4 1 (Push 1 on stack)

MSTORE (Save data to memory)

POP (Remove data from stack)

PUSH4 1 (Push 1 on stack)

ADD (Addition operation)

MLOAD (Load data from memory)

ADD (Addition operation)

The Ethereum virtual machine takes twice as long to run this simple operation. The Dalvik architecture’s speed allows our CVM to run faster and more cheaply than EMV. Ultimately, CVM will be able to satisfy the requirements of enterprise applications, further addressing blockchain’s urgent scaling needs.

Second, SafeMath. Smart contract codes are vulnerable to overflow, or project past a numerical value outside its representable range. In lay terms, this means that programs have the capacity to contain traps, which might not be immediately apparent in the runtime environment. To prevent against this, Ethereum participants must individually check the code with the SafeMath, which checks for these traps whenever athematic are performed. The CVM does this automatically, taking the success of a contract out of occasionally erring human hands.

Third, fixed-point representation. Like with SafeMath checks, the nitty computer science here gets a little too gritty for our purposes. Essentially it comes down to this: EVM does not support fixed point representation, but CVM does. This is important because fixed-point representation is part of what enable low-cost embedded chip-technology in payment cards, making it a crucial part of modern business transactions. Again, EVM doesn’t have it; CVM does.

And finally, 64-bit words. The EVM takes as its basic data type the 256-bit word. Theoretically, this allows for powerful transactions, but practically this is not the case. To practically compute 256-bit arithmetic would require an incredible amount of computing power and electricity. (The network gas cost alone would rise to an unpayable amount.) Instead CVM uses 64-bit integers and arithmetic. As a result, the computing would be cheaper, and faster, and eminently doable for most CPUs, which use either 32-bit or 64-bit processors.

At Cypherium, we hope to show that blockchains can make the world faster, cheaper, and fairer all at the same time. The Cypherium Virtual Machine is a leap in this new direction.

--

--