Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move PI to separated file * Include TRANSCRIPT_INIT & TRIM_SIZE consts for trait * Add PiPositionsHolder trait as Circuit supertrait * Remove `gadget` call from Circuit::verify() fn It wasted a lot of time and also was useless to call the `gadget` fn again for the verify fn in the Circuit trait. Thanks to the refactor done to the PublicInputs and how they're handled now we no longer need to call it. * Use extend instead of append to reduce allocations * Declare zeros array only once * Refactor Public Inputs handling in Composer Previously we were storing the dense representation of the public inputs that were used with the `Composer` instance. This was constly, since most of the public inputs were zero and therefore storing them was useless but also we needed to collect the position information in the Circuit trait in such difficult ways. With this refactor we currently have: - Public Inputs are now passed to gate-functions as `Option<BlsScalar>`. - The `Composer` no longer stores the dense public input vector. Instead we store two sparse vectors which contain the values and the positions. - We include a function that allows the `Composer` to construct the dense PI vector from it's sparse ones. - We've added ways for the consumer to get access to the positions vector. This will allow to simplify the public input management on the `Circuit` trait. * Implement bytes-PI conversion trait * Use simple PublicInputValue struct for PI handling After discussions with @ZER0 we realized there's not a need to have a really big trait to handle the public inputs and all we need is a simple structure that implements the conversions from the different PI types that we can have in PLONK circuits into the format that PLONK requires which is `&[BlsScalar]`. - Created `PublicInputValue` which is implemented for `BlsScalar`, `JubJubScalar` and `JubJubAffine`. - Forced the `Circuit` trait to use this struct as source of the public input values needed in the verification step. * Impl HashMap for PublicInputs storage Instead of storing the sparse representation of the non-zero PublicInputs as two different `Vec` which are logically connected but not tecnollogically(code-wise). With this change we can have them strictly correlated since they're stored linked in the `HashMap`. * Use BTreeMap instead of HashMap We need to return the PI positons(and store them) in order since otherways when consumers ask for these data, it would be returned wrongly if we don't return it ordered. * Extend circuit tests to use ECC ops This also allows to test wether the support for the PI handling of the Circuit trait is correct. * Remove prints * Make Circuit::TRIM_SIZE auto impl from const_gen To allow (although it's not recommended to do) variable-size circuits, we need a way to express different circuit sizes (TRIM_SIZE) for the same circuit. By setting the `Circuit::TRIM_SIZE` inherit the value from the const generic parameter N, we enable this behaviour leaving an API that is not bad. * Address reveiw comments * Use copied() in iters instead of * * Update README.md with code examples * Change circuit module name * Check invariants for pi BTreeMap insertion * Impl `padded_circuit_size` for `VerifierKey` * Remove verify_proof & build_pi from Circuit Since these two functions didn't need `Self` or `self` and also were independent, we've been able to remove them from the trait. This closes #396 and also allows us to have a generic method that can verify Proofs of any `Circuit` without needing to have access to the type of it. * Update CHANGELOG * Address @ZER0's PR suggestions * Add canonical_derive as dep behind `canon` feature * Remove hyperlink from SNARK docs. The docs file had a faulty hyperlink. This is because within files it is not possible to connect to mod level markdowns. This is now removed. * Add rust-toolchain file using `nightly` * Add default Dusk config for rustfmt.toml * Fix "broken links" lint warning Resolves: #443 * Replace collections::HashMap for hashbrown::HashMap Resolves: #424 * Update CHANGELOG * Apply cargo fmt --all to crate * Remove unused code from the lib During the refactors that we've done, some functions became legacy code and were not removed. That's a problem since it makes the codebase harder to navigate and mantain. Resolves: #439 * Update CHANGELOG * Move to test mod test-only fns for CKey & VKey * Cut visibility of crate structures & fn's Currently, we expose a way too much things when indeed we should try to expose publicly in the API only the necessary stuff. We have modules as fft or transcript_protocol which shouldn't be pub. Also there are quite some structures which are pub but never meant to be used by the lib consumers. The idea is that with this PR we're able to make more clear which are the things that the consumer is suposed to call or do. Closes #438 * Update CHANGELOG * Move rand_core import to test mod * Use `match` instead of double `if` as @ZER0 suggest * Fix typo * Move rand fn inside impl block under tests mod * Fix test fn public visibility * Remove Polynomial & Evaluations asscoc unused fns * Fix typo * Use crate:: route instead of `super::super::..` * Add dusk-bytes Error as BytesError in plonk We've added an enum variant for it as well as a conversion from dusk_bytes::Error to dusk_plonk::Error so that we can use `?` * Impl Serializable for OpeningKey * Remove the usage of read_g2_affine The goal is to remove the serialization module at the end by implementing the `dusk_bytes` trait. This is one step forward. * Impl Serializable + tests for Commitment * Remove serde support * Impl Serializable for ProofEvaluations & tests * Fix PubParams serialization API naming conventions * Impl Serializable & tests for ProofEvaluations * Impl Serializable & testst for VerifierKey * Impl Serializable & tests for VerifierKey * Impl Serializable & tests for Proof * Remove serialisation module from crate Since we had here a lot of duplicated read/write impls for data structures that already have this behaviour implemented, this simply removes the entire module and all of it's functions. Closes #437 * mend * Update serialization API conventions ProverKey The implementations were using the `serialization` module instead of the `dusk_bytes` trait functions. - Updated the implementations to no longer use the `serialisation` module functions and use the `dusk-bytes` ones. - Updated the fn docs to be more specific and clear about the differences of using raw/unchecked vs. to/from bytes. * Update PublicParameters to_bytes to use new ck serde * Impl dusk_bytes::Serializable for EvaluationDomain * Impl to/from bytes for Evaluations * Impl to/from bytes for Polynomial * Refactor ProverKey serialization ProverKey was pulling all of the serde from the `serialisation` module that is no longer supported and removed. Therefore, a refactor was needed so that we use the canonical implementation done for the dusk_bytes traits for the structures contained inside the ProverKey. - Updated the serialization-related fn docs to be more explicit. - Refactored `to_bytes()` and `from_bytes()` to use `dusk_bytes` trait functions in order to remove duplicity. * Remove legacy unused code for poly_iter_sum * This seems to be a leftover from #285 * Fix absent polys writing inside ProverKey When we want to convert into bytes a `ProverKey` there are some of it's internal widget ProverKeys that contain empty polynomials because they haven't been used during the circuit building process. The serialization now is fixed and this structures are serialized correctly consuming no space when they're null. * Set correct capacity for bytes buffer * Update CHANGELOG * Address @ZER0's nits * Consolidate API renaming consistently Resolves: #354 * Fix PublicParameters serialization issues * Address rebase errors * Make proof_system module private * Fix Error type used for Serializable impl Proof In order to impl the propper `BadLenght` trait & others we need to set the associated error for the `Serializable` trait impl for `Proof` as `dusk_bytes::Error` and take profit of the conversion with `?` to convert the error into a `plonk::Error` when needed. Resolves: #447 * Fix canon feature related compilation errors - Remove `Canon` impl for `Proof`. - Make the `std::Error` impl behind `std` flag. Resolves: #450 * Update CHANGELOG.md * Implement ID associated const for Circuit trait As discussed with the core team, this would enable features like circuit versioning with techniqes like: > You could generate the ID by hashing the `gadget()` fn code in a proc_macro with something like Blake3. Resolves: #417 * Address @ZER0's nits * Apply fmt * Bump to 0.6.0 Resolves: #458 Co-authored-by: Luke Pearson <luke@dusk.network>
- Loading branch information