Nova: Recursive SNARKs without trusted setup

Overview

Nova: Recursive SNARKs without trusted setup

Nova is a high-speed recursive SNARK (a SNARK is type cryptographic proof system that enables a prover to prove a mathematical statement to a verifier with a short proof and succinct verification, and a recursive SNARK enables producing proofs that prove statements about prior proofs). The details of Nova are described in our paper. Recursive SNARKs including Nova have a wide variety of applications such as constructions of verifiable delay functions (VDFs), succinct blockchains, and incrementally verifiable versions of verifiable state machines. A distinctive aspect of Nova is that it is the simplest recursive proof system in the literature. Furthermore, it achieves the smallest verifier circuit (a key metric to minimize in this context): the circuit is constant-sized and its size is dominated by two group scalar multiplications.

This repository provides libnova, a Rust library library implementation of Nova. The current release implements the core building blocks in Nova, and future releases will use cycles of elliptic curves to support recursive composition of proofs.

To run tests, run:

cargo test

References

Nova: Recursive Zero-Knowledge Arguments from Folding Schemes
Abhiram Kothapalli, Srinath Setty, and Ioanna Tzialla
Cryptology ePrint Archive: Report 2021/370

Acknowledgements

v0.1.0 includes code written by: Abhiram Kothapalli, Srinath Setty, and Ioanna Tzialla.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Comments
  • Refactor to allow non-determinisim.

    Refactor to allow non-determinisim.

    This PR refactors proving in a number of ways. At least some of these changes are necessary to support determinism in the computation of F. The existing code didn't allow this, since compute was always called on the same circuit prototype contained in the public parameters.

    • separate circuit/output computation and synthesis into two traits
    • at the lowest level, support caller-controlled stepping of the proof
    • for convenience, allow caller to provide iterators yielding successive outputs and (un-synthesized) circuits
    • most simply, and consistent with current implementation, automatically create such iterators when ComputeStep is implemented

    This change also makes num_steps optional, and the state accumulated in a RecursiveSNARK tracks the actual number of steps used. This allows for applications where the number of steps is not known in advance.

    It's likely that further small changes may be needed when integrating downstream consumers who will need this functionality, but until integration happens, it is difficult to anticipate what that may entail beyond my best guesses here.

    NOTE: in the future, we should support a recursive proof which does not expose the number of steps. This will be important for applications in which knowing the number of steps required to compute a final result leaks information. Having the option to generate proofs without revealing the number of steps will eliminate effective 'timing attacks' on such applications.


    UPDATE: I added support for non-unary functions, building on the first part. I know that makes this a fairly large PR, but I had to rework a fair amount of the foundation to get here.

    The basic idea is that for higher-arity functions, the implementer should implement methods (compute_inner and synthesize_step_inner, which operate on and return a vector of scalars. The goal was to make the actual mechanism as hidden from the caller/user as possible, but some leakage was unavoidable so far.

    Under the hood, at each step, the inputs are hashed to get the true unary input for the step function, F — and the outputs are again hashed to produce the unary output. Both hashes are proved in the circuit.

    Because we need to avoid storing the initial input (Z0) in the public parameters, it's necessary to first create an 'empty' input used to generate the R1CS shape. That means the caller does (unfortunately) have to create the poseidon constants for the relevant scalar and arity. This is not especially difficult, but it would be nicer if it could have been avoided. This wart means that the constants are generated twice in this case. With more machinery, the public parameters and IO enum could be more symbiotic, but for now I think this is a reasonable tradeoff.

    opened by porcuquine 6
  • Modules are not public

    Modules are not public

    Hi - the circuit, gadgets, and poseidon modules are not public. Can we make them public?

    pub mod bellperson; mod circuit; pub mod errors; mod gadgets; pub mod pasta; mod poseidon; pub mod r1cs; pub mod traits;

    opened by arthurgreef 3
  • Add support for using bellperson to generate R1CS.

    Add support for using bellperson to generate R1CS.

    This PR adds support for using bellperson R1CS (shape and witness) generation.

    It depends on changes in this PR so cannot merge until that does. Once it has, we can update the git dependency here to finalize.

    opened by porcuquine 2
  • Compilation error: failed to select a version for the requirement `funty =

    Compilation error: failed to select a version for the requirement `funty = "~1.2"`

    Full compilation error:

    error: failed to select a version for the requirement `funty = "~1.2"`
    candidate versions found which didn't match: 2.0.0, 1.1.0, 1.0.1, ...
    location searched: crates.io index
    required by package `bitvec v0.22.3`
        ... which satisfies dependency `bitvec = "^0.22.3"` of package `ec-gpu-gen v0.3.0`
        ... which satisfies dependency `ec-gpu-gen = "^0.3.0"` of package `bellperson v0.22.0`
        ... which satisfies dependency `bellperson = "^0.22"` of package `bellperson-nonnative v0.3.1`
        ... which satisfies dependency `bellperson-nonnative = "^0.3.1"` of package `nova-snark v0.8.1 (/home/t490/programs/Nova)`
    

    For an amusing history which led to this issue, I think this is relevant: https://github.com/bitvecto-rs/funty/issues/3

    TL;DR, seems as if they killed funty version 1.2 5 days ago.

    I think using bellperson = "0.24.0" (and updating bellperson-nonnative to also use this bellperson) will solve it.

    opened by vicsn 1
  • Serde serialization

    Serde serialization

    Draft pull request as this pull request depends on a pull request on the pasta_curves repo: https://github.com/zcash/pasta_curves/pull/36/commits

    Fixes #46

    opened by arthurgreef 1
  • Support Pasta curves.

    Support Pasta curves.

    Now that https://github.com/zcash/pasta_curves is licensed under MIT/Apache, we can depend on it directly here. This simplifies trait definitions (which previously had to be wrapped, with duplicate implementations of standard operations, when providing) for pasta curves.

    I removed the dev dependency on Ristretto under the assumption that it was only a placeholder whose purpose could be served by Pasta now. This allowed upgrading the rand dependency, which is useful downstream.

    opened by porcuquine 1
  • compiling to solidity/evm?

    compiling to solidity/evm?

    hey this library looks great. we are looking for a "next gen" circom library for implementing smart contracts on blockchains. Do you have any plans going forward to support compiling to other languages such as solidity/huff?

    opened by sourdzl 2
  • Optimization: The running instance does not need to absorbed.

    Optimization: The running instance does not need to absorbed.

    Given that the public IO of the incoming R1CS instance contains the hash of the running instance in addition to (params, U, i, z0, zi), we can skip absorbing the running instance.

    opened by srinathsetty 0
  • Serde Serialization

    Serde Serialization

    Serde serialization an deserialization for shape, parameters, instances, and witnesses.

    Depends on the following PR on pasta_curves.

    https://github.com/zcash/pasta_curves/pull/36/commits

    opened by arthurgreef 1
Owner
Microsoft
Open source projects and samples from Microsoft
Microsoft
Spartan: High-speed zkSNARKs without trusted setup

Spartan: High-speed zkSNARKs without trusted setup Spartan is a high-speed zero-knowledge proof system, a cryptographic primitive that enables a prove

Microsoft 435 Jan 4, 2023
Interfaces for Relations and SNARKs for these relations

SNARK and Relation Traits The arkworks ecosystem consists of Rust libraries for designing and working with zero knowledge succinct non-interactive arg

arkworks 648 Dec 26, 2022
Spartan2: High-speed zero-knowledge SNARKs.

Spartan2: High-speed zero-knowledge SNARKs. Spartan is a high-speed zkSNARK, where a zkSNARK is type cryptographic proof system that enables a prover

Microsoft 7 Jul 28, 2023
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

Diem 16.7k Jan 8, 2023
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

Diem 16.7k Dec 29, 2022
nAssets are Nova Finance’s framework for building programmable assets.

nAssets are Nova Finance’s framework for building programmable assets. nAssets can be used to tokenize and store collective forms of value while also instructing assets to yield, exchange or rebalance.

Nova Finance 45 Dec 28, 2021
Diem’s mission is to build a trusted and innovative financial network that empowers people and businesses around the world.

Note to readers: On December 1, 2020, the Libra Association was renamed to Diem Association. The project repos are in the process of being migrated. A

Diem 16.7k Jan 9, 2023
Enigma Core library. The domain: Trusted and Untrusted App in Rust.

Enigma Core library Service Master Develop CI Badge Pure Rust Enclave && Untrusted in Rust. Core is part of the Enigma node software stack. The Core c

SCRT Labs 89 Sep 14, 2022
A collection of comparison-benchmarks for Nova & related Proving systems

Nova benchmarks Here's a list of some of the benchmarks we've been taking to better understand how Nova performs vs other proof systems. Live version:

Privacy & Scaling Explorations (formerly known as appliedzkp) 18 Apr 17, 2023
Implementation of Nova using arkworks for learning purposes

nova-study Implementation of Nova using arkworks-rs just for learning purposes. Warning: Implementation from scratch to learn the internals of Nova. D

null 16 Apr 23, 2023
A fast, simple, recursive content discovery tool written in Rust.

A simple, fast, recursive content discovery tool written in Rust ?? Releases ✨ Example Usage ✨ Contributing ✨ Documentation ?? ?? What the heck is a f

epi 3.6k Dec 30, 2022
Left Recursive PEG for rust

Left Recursive Parsing Expression Grammar (PEG) lrpeg allows left recursive rules, and uses ratpack parsing for speed. I wrote a blog post to introduc

Sean Young 66 Jun 13, 2022
Non-Recursive Inverting of Binary Tree in Rust

Non-Recursive Inverting of Binary Tree in Rust The idea is to implement the classical Inverting of Binary Tree but without using recursion. Quick Star

Tsoding 15 Dec 6, 2022
Rust macro to make recursive function run on the heap (i.e. no stack overflow).

Decurse Example #[decurse::decurse] // ?? Slap this on your recursive function and stop worrying about stack overflow! fn factorial(x: u32) -> u32 {

Wisha W. 18 Dec 28, 2022
The recursive model index, a learned index structure

RMI This is a reference implementation of recursive model indexes (RMIs). A prototype RMI was initially described in The Case for Learned Index Struct

Learned Systems 162 Dec 27, 2022
Recursive & Iterative Binary Search Tree Implementations within Rust

bst-rs Recursive & Iterative Binary Search Tree Implementations within Rust Table of Contents Personal Goals About Quick Start License Contributing In

Hamothy 6 Oct 1, 2022
STARK - SNARK recursive zero knowledge proofs, combinaison of the Winterfell library and the Circom language

STARK - SNARK recursive proofs The point of this library is to combine the SNARK and STARK computation arguments of knowledge, namely the Winterfell l

Victor Colomb 68 Dec 5, 2022
Minimal recursive "truncate file/directory names to meet requirements" tool

trunc_filenames ssokolow@monolith ~ % trunc_filenames --help trunc_filenames 0.1.0 Rename files and directories to fit length limits. WARNING: Will n

Stephan Sokolow 2 Nov 20, 2022
A language parser tool to build recursive descent top down parser.

lang-pt A language parser tool to generate recursive descent top down parser. Overview Parsers written for the languages like Javascript are often cus

Creative Forest 7 Jan 4, 2023