• Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vamp-IR is a proof-system-agnostic language for writing arithmetic circuits

Vamp-IR

Vamp-IR is a language for arithmetic circuits. The Vamp-IR compiler can transform an arithmetic circuit into a form that is compatible with any proving system backend.

Docs

Vamp-IR book (WIP)

Trying Vamp-IR

Installation

git clone [email protected]:anoma/vamp-ir
cd vamp-ir
cargo build

Hello World!

We will build a circuit in Vamp-IR that checks if a pair $(x, y)$ is a point on a circle of a certain radius, $R$, which is given publicly.

In a file pyth.pir :

// declare R to be public
pub R;

// define the Pythagorean relation we are checking
def pyth a b c = {
  a^2 + b^2 = c^2
};

// appends constraint x^2 + y^2 = R^2 to the circuit
pyth x y R;

Compile

Compile source pyth.pir to a circuit that can be used in Halo2 and serialize it to the file pyth.halo2.

vamp-ir halo2 compile -s pyth.pir -o pyth.halo2

Create a proof

Suppose the target radius $R$ is $25$, and we come up with $(x, y) = (15, 20)$. We can use vamp-ir to create a Halo2 proof using these inputs.

First create a file pyth.inputs in JSON format which contains our solution.

{
  "x": "15",
  "y": "20",
  "R": "25"
}

Then run the Halo2 prover using our compiled circuit and our inputs, outputting a Halo2 proof to pyth.proof.

vamp-ir halo2 prove -c pyth.halo2 -i pyth.inputs -o pyth.proof

Verify the proof

Run the Halo2 verifier using the compiled circuit and the proof.

vamp-ir halo2 verify -c pyth.halo2 -p pyth.proof

Benchmarks

These benchmarks are performed on a Lenovo ThinkPad X1 Carbon Gen 9 with 8.0 GiB RAM and an 11th Gen Intel® Core™ i5-1135G7 @ 2.40GHz × 8 unless stated otherwise

Halo2 backend

SHA256 1 block message

Compile Prove Verify
Vamp-IR 172.05 s 26.72 s 0.61 s
Halo2 // 161.05 s 1.06 s

SHA256 2 block message

Compile Prove Verify
Vamp-IR 353.76 s 46.91 s 1.09 s
Halo2 // 160.03 s 1.05 s

SHA256 4 block message

Compile Prove Verify
Vamp-IR 729.47 s Memory Failiure X
Halo2 // 160.36 s 1.03 s

We re-run the with a device that has 128GB of RAM and these are the results:

Compile Prove Verify
Vamp-IR 60 s 81.983 s 0.6 s

ZK-garage plonk backend

Blake2s

Compile Prove Verify
Vamp-IR 76.30 s 57.59 s 0.22 s
ZK-Garage // 32.48 s 0.10 s

Blake2s using only fan-in 2 gates

To have a more fair comparison between Vamp-IR and ZK-Garage, we can use only fan-in 2 gates in the Blake2s circuit. This is because the current version of Vamp-IR does not uses fan-in 3 gates, as the ZK-Garage backend does, which in a speed-up.

Compile Prove Verify
Vamp-IR 76.30 s 57.59 s 0.22 s
ZK-Garage // 360.48 s 0.81 s

The version of Blake2 used for the latter benchmark can be found here: https://github.com/heliaxdev/ark-plonk/blob/blake2s/examples/blake2s_circuit_fain2.rs

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

More Repositories

1

namada

Rust implementation of Namada, a Proof-of-Stake L1 for interchain asset-agnostic privacy
Rust
2,394
star
2

juvix

A language for intent-centric and declarative decentralised applications
Haskell
447
star
3

anoma-archive

Reference implementation of the Anoma protocols in Rust.
Rust
426
star
4

namada-testnets

Testnet configurations and coordination for the Namada network.
327
star
5

namada-trusted-setup-claimer

Sign arbitrary messages with keys obtained from Namada's trusted setup
Rust
320
star
6

taiga

A framework for generalized shielded state transitions
Rust
134
star
7

zkp-compiler-shootout

Evaluating & benchmarking ZKP compilation strategies.
Rust
118
star
8

masp

The multi-asset shielded pool (MASP) provides a unified privacy set for all assets on Namada.
Rust
88
star
9

ferveo

An implementation of a DKG protocol for front-running protection on Anoma.
Rust
78
star
10

namada-interface

TypeScript
77
star
11

whitepaper

TeX
59
star
12

namada-docs

MDX
48
star
13

namada-shielded-expedition

Python
42
star
14

typhon

Formalization of Typhon protocol
TLA
28
star
15

geb

A Categorical View of Computation
Idris
28
star
16

research

Early-stage research related to the Anoma protocols.
Idris
23
star
17

specs

Specifications for the Anoma protocols.
TeX
23
star
18

alucard

A common lisp DSL for writing zero knowledge circuits
Common Lisp
18
star
19

namada-indexer

Namada indexer to be used in conjunction with the namada interface
Rust
16
star
20

ethereum-bridge

A generalized fully trustless Ethereum bridge for sovereign chains.
Solidity
12
star
21

minijuvix

Haskell
11
star
22

juvix-stdlib

The Juvix standard library
Makefile
9
star
23

VampIR-Book

A book which can act as an introduction and documentation for VampIR
CSS
9
star
24

masp-mpc

MASP MPC code
Rust
8
star
25

namada-mainnet-genesis

Python
7
star
26

namada-sdk-starter

Rust
6
star
27

juvix-nightly-builds

6
star
28

abstract-resource-machine-simulator

Makefile
6
star
29

anoma-alpha

An intent-centric, privacy-preserving protocol for decentralized counterparty discovery, solving, and multi-chain atomic settlement.
Rust
6
star
30

juvix-e2e-demo

Juvix compiler stack - Integration demo
Dockerfile
6
star
31

exhibit_plonkup

Rust
5
star
32

devtool

Rust
4
star
33

anoma-blog

Jupyter Notebook
4
star
34

verify-beacon

Rust
3
star
35

vscode-juvix

VSCode extension for Juvix
TypeScript
3
star
36

dev-utils

Shell
3
star
37

namada-whitepaper

Namada whitepaper
3
star
38

juvix-docs

Juvix Official Documentation
Makefile
3
star
39

devchain-container

Shell
2
star
40

intents-snippets

A repo to put code snippets related to intent research
Agda
2
star
41

Isabelle-HPaxos

A formalization of HPaxos in Isabelle
Isabelle
2
star
42

typhon-sml

Typhon reference implementation in Standard ML
Standard ML
2
star
43

namada-genesis

Python
2
star
44

namada-masp-indexer

The Namada Masp Indexer reference implementation.
Rust
2
star
45

anoma-wasm-multitoken

Validity predicate and transactions for a variable supply multitoken account
Rust
2
star
46

wasm-workspace

Rust
2
star
47

namada-shielded-airdrop

Rust
2
star
48

anoma-blog-writing-guide

Comprehensive guide to writing blogposts for the anoma blog.
2
star
49

juvix-quickcheck

Property-based testing for Juvix
Makefile
2
star
50

plonkup-hash

A collection of hash gadgets written for Plonkup
Rust
1
star
51

juvix-mode

The Juvix Emacs mode
Emacs Lisp
1
star
52

vscode-vampir

1
star
53

anoma-app-lib

A library for intent-centric application development.
1
star
54

juvix-test

A testing framework for Juvix
Shell
1
star
55

juvix-anoma-test

A library for testing Anoma applications
1
star
56

juvix-containers

Immutable container types for Juvix
Makefile
1
star
57

highlightjs-juvix

Juvix language grammars for highlightjs (low maintenance)
JavaScript
1
star
58

art-template

Anoma Research Topics Template
TeX
1
star
59

juvix-anoma-stdlib

A Juvix library for writing Anoma applications
Makefile
1
star
60

namada-light-sdk-starter

Namada light sdk starter kit
Dockerfile
1
star
61

ART-2023-Gureev-Cubides-Geb-Pipeline

TeX
1
star