-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Composer into trait #700
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
ba9f947
to
a107f2f
Compare
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.
a107f2f
to
1ab1699
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generally the changes LGTM, the only remark (apart from the few thingies I commented about) is that there are quite a big amount of comments missing compared to the old version of plonk.
In my opinion the protocol and implementation are already complicated enough and if in doubt I would rather opt for too many comments than too few.
pub trait Composer: Sized + Index<Witness, Output = BlsScalar> { | ||
/// Zero representation inside the constraint system. | ||
/// | ||
/// A turbo composer expects the first witness to be always present and to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 'turbo'
|
||
/// `One` representation inside the constraint system. | ||
/// | ||
/// A turbo composer expects the 2nd witness to be always present and to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 'turbo'
// | ||
// Copyright (c) DUSK NETWORK. All rights reserved. | ||
|
||
//! PLONK turbo composer definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove 'turbo'
pub fn serialized_size(&self) -> usize { | ||
self.prepare_serialize().0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would calculate the size in this function and not in prepare_serialize
. in that case we don't prepare for serialization when we simply want to get the size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid duplicated code. If we repeat the calculation here, then we are duplicating the implementation for when we actually serialize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would the code be duplicated? We can call serialized_size
where we need the size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving on @vlopes11 request and allowing the merge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I like the API simplification. Not sure about those #[deprecated]
attributes, but I also couldn't find another way to just emit a compiler warning.
I do second the removal of the word "turbo" everywhere, as @moCello suggested, but it's really just a nit and can be addressed at any time.
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 CDFfiles 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.