Stateless VM

The base layer implements a fork of ZkVM, which is part of a new blockchain architecture Slingshot, being developed by Oleg Andreev and others.

Base layer does not use Spacesuit, Musig and other libraries that are part of the project Slingshot, but only implement 14 specific opcodes from ZkVM relevant to implementing Twilight. Other ZkVM opcodes are specific to Cloak protocol, and their non-inclusion does not affect the expressiveness of programs on the base layer.

ZkVM forked opcodes

Opcode

Stack

Stack Instructions

.push()

østringø → string

.drop()

stack itemøstack \ item → ø

.dup:k()

x[k] … x[0] dup:k → x[k] ... x[0] x[k]

.roll:k()

x[k] x[k-1] ... x[0] roll:k → x[k-1] ... x[0] x[k]

CS instructions

.r#const()

scalar → expr

.var()

point → r1cs "variable"

.expr()

var → expr

.neg()

expr1 → expr2 (negates weight in expr1)

.add()

expr1 expr2 → expr3

.mul()

expr1 expr2 → expr3

.eq()

expr1 expr2 → constraint

.range()

adds 64 bit range proof for expr to CS

.and()

c1 c2→ c3

.verify()

c1 → ø

For detailed spec, check ZkVM transaction specifications. Some opcodes have been renamed in the recent PR.

Last updated