plonk icon indicating copy to clipboard operation
plonk copied to clipboard

Refactor Composer into trait

Open vlopes11 opened this issue 2 years ago • 1 comments

A composer is a set of functionalities that can be extended into different implementators, such as debuggers or even PLONKup.

This commit introduces the composer as trait, and targets to reduce the complexity of the implementation of multiple components of the composer.

With this simplification, we achieved significant performance boost for public inputs evaluation.

We also removed some of the exported types that are leaked internals. The user shouldn't be aware of public inputs indexes, kzg commitments, keys or any permutation argument. Instead, he should work with proofs, public inputs, public parameters, labels, circuits, provers and verifiers.

The proof generation was largely simplified, reducing its arguments to a random number generator for the proof blinders, and a circuit instance for its witnesses.

The proof verification was simplified to take only the proof and its public inputs. The public inputs are not encoded into the proof because they are often used from external sources, such as blockchain payload.

A debugger was introduced and it will output CDF files if the feature flag is on, and the CDF_OUTPUT environment variable is set. These CDF files are expected to be read from the TCDB debugger - a CLI application inspired in gdb, for zk-SNARKS Plonk circuits.

Finally, a type-safe constraint was introduced, binding the prover and verifier with their concrete circuit implementation. This allowed great simplification of the verification process since the user don't need to manage verification keys anymore.

vlopes11 avatar Aug 15 '22 16:08 vlopes11

Codecov Report

Merging #700 (c2be965) into master (66accb8) will increase coverage by 3.10%. The diff coverage is 85.21%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #700      +/-   ##
==========================================
+ Coverage   80.14%   83.25%   +3.10%     
==========================================
  Files          47       46       -1     
  Lines        3526     3630     +104     
==========================================
+ Hits         2826     3022     +196     
+ Misses        700      608      -92     
Impacted Files Coverage Δ
src/commitment_scheme/kzg10/key.rs 85.64% <0.00%> (+1.85%) :arrow_up:
src/composer/polynomial.rs 0.00% <0.00%> (ø)
src/constraint_system/witness.rs 50.00% <ø> (ø)
src/error.rs 0.00% <0.00%> (ø)
src/fft/polynomial.rs 42.14% <ø> (+1.65%) :arrow_up:
src/lib.rs 100.00% <ø> (ø)
src/proof_system/proof.rs 95.73% <ø> (ø)
src/proof_system/widget.rs 92.75% <ø> (+0.26%) :arrow_up:
src/debugger.rs 27.36% <27.36%> (ø)
src/runtime.rs 38.46% <38.46%> (ø)
... and 35 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 66accb8...c2be965. Read the comment docs.

codecov[bot] avatar Aug 15 '22 16:08 codecov[bot]