17 stable releases

new 1.3.3 Feb 22, 2021
1.3.2 Oct 21, 2020
1.1.4 Aug 19, 2020
1.1.3 Jul 26, 2020
1.0.2 May 10, 2019

#34 in Cryptography

Download history 88/week @ 2020-11-07 29/week @ 2020-11-14 75/week @ 2020-11-21 29/week @ 2020-11-28 63/week @ 2020-12-05 21/week @ 2020-12-12 24/week @ 2020-12-19 23/week @ 2020-12-26 43/week @ 2021-01-02 59/week @ 2021-01-09 31/week @ 2021-01-16 53/week @ 2021-01-23 23/week @ 2021-01-30 67/week @ 2021-02-06 49/week @ 2021-02-13 74/week @ 2021-02-20

171 downloads per month
Used in 5 crates

MIT license


zkInterface, a standard tool for zero-knowledge interoperability

zkInterface is a standard tool for zero-knowledge interoperability between different ZK DSLs, gadget libraries, and proving systems. The zkInterface project was born in the ZKProof community.

See a live demo.

See the specification and the serialization format.

See the Rust implementation: docs

Integration instructions:


alt text

zkInterface is specification and associated tools for enabling interoperability between implementations of general-purpose zero-knowledge proof systems. It aims to facilitate interoperability between zero knowledge proof implementations, at the level of the low-constraint systems that represent the statements to be proven. Such constraint systems are generated by frontends (e.g., by compilation from higher-level specifications), and are consumed by cryptographic backends which generate and verify the proofs. The goal is to enable decoupling of frontends from backends, allowing application writers to choose the frontend most convenient for their functional and development needs and combine it with the backend that best matches their performance and security needs.

The standard specifies the protocol for communicating constraint systems, for communicating variable assignments (for production of proofs), and for constructing constraint systems out of smaller building blocks (gadgets). These are specified using language-agnostic calling conventions and formats, to enable interoperability between different authors, frameworks and languages.

A simple special case is monolithic representation of a whole constraint system and its variable assignments. However, there are a need for more richer and more nuanced forms of interoperability:

  • Precisely-specified statement semantics, variable representation and variable mapping
  • Witness reduction, from high-level witnesses to variable assignments
  • Gadgets interoperability, allowing components of constraint systems to be packaged in reusable and interoperable form
  • Procedural interoperability, allowing execution of complex code to facilitate the above

Current Status



Circuit Type Export Circuits Import Circuits
ZoKrates R1CS Yes No
Libsnark R1CS Yes No
Mir r1cs R1CS Yes No
Bellman R1CS Yes Yes


Proving System
Bellman Groth16
Dalek Bulletproofs
Libsnark BCTV14a

See also the WebAssembly modules used to build the live demo.

See the ecosystem/ folder for a collection of instructions to install and connect multiple systems.

Repository content

zkInterface.pdf The interface specification
zkinterface.fbs The gadget interface definition using FlatBuffers
examples/ An example circuit in binary and JSON
rust/ Cargo package zkinterface
rust/src/zkinterface_generated.rs Generated Rust code
rust/src/reading.rs Rust helpers to read messages
rust/src/writing.rs Rust helpers to write messages
rust/src/cpp_gadget.rs Rust helpers to interact with C++
rust/src/examples.rs Example messages for a simple test circuit
rust/src/gadget_call.rs Example gadget call in Rust
cpp/zkinterface_generated.h Generated C++ code
cpp/gadget_example.cpp Example gadget in C++
js/ NPM package zkinterface
js/zkinterface_generated.js Generated JavaScript code
build.rs Generate Rust and C++ code from zkinterface.fbs, and compile the C++ example
cpp/libsnark_integration.hpp Libsnark support
cpp/libsnark_example.cpp Libsnark gadget example


In the rust directory, run unit tests:

cargo test

The following commands will generate and print a file containing the messages Circuit, R1CSConstraints, and Witness for a toy circuit in rust/src/examples.rs:

cargo run example  > example.zkif
cargo run explain  < example.zkif

Generated code

Generated C++ and Rust code is included.

For other languages, install the FlatBuffers code generator (flatc). One way is to compile it with the following:

git clone https://github.com/google/flatbuffers.git
cd flatbuffers
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release

Then run: flatc --LANGUAGE zkinterface.fbs

How to contribute

  • In a frontend, implement a feature to export the circuits or gadgets to zkInterface format.
  • In a proving system, support loading circuits from zkInterface buffers or files.

See the implementation guide section in the spec above for more details, and check out the existing implementations below.


The zkInterface specification document providers further context on the above, and defines the communication protocol and calling convention between frontends and backends:

  • The logical content of messages being exchange.
  • The serialization format of the messages (which is based on FlatBuffers and may be used in-memory, saved or streamed).
  • A protocol for building a constraint system from gadget composition.
  • Technical recommendations for implementation.

Integration examples

Dalek Bulletproofs


git clone https://github.com/QED-it/bulletproofs.git
cd bulletproofs
cargo install --features yoloproofs --path .


zkif example - | zkif_bulletproofs prove


zkif example - | zkif_bulletproofs verify



git clone https://github.com/QED-it/zkinterface-bellman.git
cd zkinterface-bellman
cargo install --path .

Validate / Print

zkif example - | zkif_bellman print


zkif example - | zkif_bellman prove


(not implemented)




git clone https://github.com/QED-it/zkinterface.git
cd zkinterface/cpp




zkif example - | zkif_snark setup


zkif example - | zkif_snark prove


zkif example - | zkif_snark verify

Gadgets in Rust

    zkinterface = { version = "1.1.3" }
    zkinterface-libsnark = { version = "1.1.3" }

See examples in libsnark-rust/src/test.rs

Gadgets in C / Foreign Function Interface

CFLAGS="-I $ZKINTERFACE_LIBSNARK_PATH/include -L $ZKINTERFACE_LIBSNARK_PATH/lib -l ff -l gmp -l zkif_gadgetlib"

See API in gadgetlib.h

See FFI call in Rust libsnark-rust/src/gadgetlib.rs


This first revision focuses on non-interactive proof systems (NIZKs) for general statements (i.e., NP relations) represented in the R1CS/QAP-style constraint system representation. Extension to other forms of constraint systems is planned.

The associated code is experimental.

See the specification document for more information about limitations and scope.


~89K SLoC