plonky2 recursion framework handling different circuits in unified way.

Overview

generic_recursion

Version: 0.1.0

generic_recursion is a crate that allows to easily aggregate an unlimited amount of plonky2 proofs, generated with a circuit belong to a specific set of circuits, in a single recursive proof, which can be verified with the same verifier data independently from the number of proofs being aggregated.

The main component of the crate is the AggregationScheme data structure, which implements the RecursiveCircuit trait. This data structure already provides all the methods necessary to aggregate an unlimited number of plonky2 proofs generated with a set of circuits specified as input by the user, which will be henceforth referred to as base_circuits.

All the base circuits in the set specified by the user are required to employ the same format for their public inputs, and the AggregationScheme needs to know such a format. To specify the public input format of the base circuits, and the information about them which are needed by the AggregationScheme in order to compute the public inputs of the aggregated proof from the public inputs of the proofs to be aggregated, this crate introduces the PublicInputAggregation trait. The crate already provides implementations of this trait for several public input formats, which can be found in the shared_state module.

Tests

Tests can be run with:

cargo test --release

Usage

An AggregationScheme can be instantiated with the method build_circuit, which requires the user to provide the set of circuits that define which proofs can be aggregated with the instantiated AggregationScheme. Refer to section How To Specify the Set of Circuits to learn how to specify such set of circuits.

Once an AggregationScheme is instantiated, the user can start providing proofs to be aggregated, which must be generated with a circuit belonging to the set specified when instantiating the AggregationScheme. Before being aggregated, each proof must be preprocessed by invoking the prepare_base_proof_for_aggregation method, which yields a PreparedProof; the methods of AggregationScheme that recursively aggregate proofs accept as input only PreparedProofs. Once a proof is converted to a PreparedProof, the user can add it to the set of proofs to be aggregated with the add_proofs_for_aggregation method; the final aggregated proof is then computed by invoking the aggregate_proofs_with method, where the user can also provide other PreparedProofs to be aggregated that have not been previously added to the set of proofs to be aggregated.

For a real example on how to use the AggregationScheme, users can refer to the integration test test_recursive_aggregation found in tests/integration.rs

How To Specify the Set of Circuits

To specify the set of circuits that define which proofs can be aggregated the user must implement the BaseCircuitInfo trait for the data structure representing each circuit. The main purpose of such trait is binding to each circuit the format of the public inputs, by specifying the implementation of the PublicInputAggregation trait corresponding to such format:

pub trait BaseCircuitInfo<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
{
    type PIScheme: PublicInputAggregation;

    fn get_verifier_circuit_data(&self) -> VerifierCircuitData<F, C, D>;
}

The constraints that all the base circuits in the set employed to construct the AggregationScheme must share the same public input format is imposed by the fact that all the circuits provided as input to the build_circuit method must implement BaseCircuitInfo trait specifying the same implementation of PublicInputAggregation as their PIScheme.

Example

For example, suppose that a user wants to aggregate proofs generated from a set of circuits with 2 base circuits, represented by data-structures BaseCircuit1 and BaseCircuit2, which employ the format for their public input specified by SimpleStatePublicInput (which is one of the implementations of PublicInputAggregation provided by this crate). To instantiate an AggregationScheme for such set of circuits, the user should do as follows:

  1. Implement BaseCircuitInfo trait for both the circuits, specifying SimpleStatePublicInput as their PIScheme:
impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
        BaseCircuitInfo<F, C, D> for BaseCircuit1
    {
        type PIScheme = SimpleStatePublicInput;

        fn get_verifier_circuit_data(&self) -> VerifierCircuitData<F, C, D> {
            // custom implementation
        }
   }

impl<F: RichField + Extendable<D>, C: GenericConfig<D, F = F>, const D: usize>
BaseCircuitInfo<F, C, D> for BaseCircuit2<F, C, D>
{
    type PIScheme = SimpleStatePublicInput;

    fn get_verifier_circuit_data(&self) -> VerifierCircuitData<F, C, D> {
        // custom implementation
    }
}
  1. Given 2 instances of the BaseCircuit1 and BaseCircuit2 data-structures, called base_circuit_1 and base_circuit_2, respectively, build the set of circuits and instantiate the AggregationScheme with the build_circuit method as follows:
let circuit_set = vec![prepare_base_circuit_for_circuit_set(base_circuit_1),
    prepare_base_circuit_for_circuit_set(base_circuit_2)];

        let aggregation_scheme =
            AggregationScheme::build_circuit(
                circuit_set.into_iter(),
            )?;

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

You might also like...
A tool for transposing harmonica tabs into different positions and tunings
A tool for transposing harmonica tabs into different positions and tunings

A tool for transposing harmonica tabs into different positions and tunings

Learning rust by coding different sorting algorithms in it
Learning rust by coding different sorting algorithms in it

Sorting in Rust Sorting a 32 bit unsigned integer vector by using: Radix Sort Quick Sort Merge Sort Bubble Sort Inbuilt Sort (Probably Tim Sort) This

hexyl is a simple hex viewer for the terminal. It uses a colored output to distinguish different categories of bytes
hexyl is a simple hex viewer for the terminal. It uses a colored output to distinguish different categories of bytes

hexyl is a simple hex viewer for the terminal. It uses a colored output to distinguish different categories of bytes (NULL bytes, printable ASCII characters, ASCII whitespace characters, other ASCII characters and non-ASCII).

Like Lua, but in Rust, and different

AirScript It's like Lua, but in Rust, and different. Introduction AirScript is a dynamically typed, interpreted language inspired by Lua and written i

Helps you keep track of time for team members across different time zones & DST changes

Teamdate Helps you keep track of time for team members across different timezones and other daylight saving changes based off their location. Because

Easy access of struct fields in strings using different/custom pre/postfix:
Easy access of struct fields in strings using different/custom pre/postfix: "Hello, {field}" in rust

Easy access to struct fields in strings 🐠 add strung to the dependencies in the Cargo.toml: [dependencies] strung = "0.1.3" 🦀 use/import everything

Trying to solve Advent of Code 2022 in 25 different languages (1 day = 1 language)

Advent of Code 2022: 15/25 langs I’ll try to solve this Advent of Code using different language for each day. Any programs needed to run the code will

Advent of Code, this year I will attempt the 25 different languages challenge

Advent of Code 2022 As this is my third year doing Advent of Code, this time I will try the 25 Different Languages Challenge, which is solving the pro

Advent of Code, different language each day

I forgor 💀 Advent Of Code 2022 Using a different language each Day!! (For obvious reason some solutions might be absolute shitcode, since I'm learnin

Owner
null
Design token framework — adopt a unified design language across platforms, codebases, and teams

Palette Design tokens framework with atomic classes for React and Master CSS. Deliver a consistent visual identity across your apps with design tokens

Foretag 4 Aug 23, 2022
Irx-config - The library provides convenient way to represent/parse configuration from different sources

The irx-config library provides convenient way to represent/parse configuration from different sources. The main goals is to be very easy to use and t

Andriy Bakay 2 Sep 14, 2022
Polyexen demo of Plonkish Arithmetiation Format (Plaf) on the zkevm-circuits

Plaf demo This is a demo of Plaf: Plonkish Arithmetiation Format on the zkevm-circuits Steps to run this: Clone these three repositories in the same f

Eduard S. 17 Apr 6, 2023
UniSBOM is a tool to build a software bill of materials on any platform with a unified data format.

UniSBOM is a tool to build a software bill of materials on any platform with a unified data format. Work in progress Support MacOS Uses system_profile

Simone Margaritelli 32 Nov 2, 2022
A library that creates a terminal-like window with feature-packed drawing of text and easy input handling. MIRROR.

BearLibTerminal provides a pseudoterminal window with a grid of character cells and a simple yet powerful API for flexible textual output and uncompli

Tommy Ettinger 43 Oct 31, 2022
Application microframework with command-line option parsing, configuration, error handling, logging, and shell interactions

Abscissa is a microframework for building Rust applications (either CLI tools or network/web services), aiming to provide a large number of features w

iqlusion 524 Dec 26, 2022
Rust CLI utility library. Error handling, status reporting, and exit codes.

narrate This library provides CLI application error and status reporting utilities. The coloured output formatting aims to be similar to Cargo. Error

Christopher Morton 5 Nov 2, 2022
Pure Rust multi-line text handling

COSMIC Text Pure Rust multi-line text handling. COSMIC Text provides advanced text shaping, layout, and rendering wrapped up into a simple abstraction

Pop!_OS 1k Apr 26, 2023
Schemars is a high-performance Python serialization library, leveraging Rust and PyO3 for efficient handling of complex objects

Schemars Introduction Schemars is a Python package, written in Rust and leveraging PyO3, designed for efficient and flexible serialization of Python c

Michael Gendy 7 Nov 21, 2023
Building blocks for handling potentially unsafe statics.

Grounded Building blocks for handling potentially unsafe statics. This crate aims to provide useful and sound components that serve as building blocks

James Munns 3 Nov 28, 2023