Skip to content

Commit

Permalink
Release version 0.6 (#457)
Browse files Browse the repository at this point in the history
* 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
CPerezz and Luke Pearson committed Mar 11, 2021
1 parent 11366f5 commit 8e431bf
Show file tree
Hide file tree
Showing 67 changed files with 2,904 additions and 2,388 deletions.
110 changes: 98 additions & 12 deletions CHANGELOG.md
Expand Up @@ -6,148 +6,231 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.6.0] - 11-03-21

### Added

- Implement `dusk_bytes::Serializable` for all possible structures that need serde. [#352](https://github.com/dusk-network/plonk/issues/352)
- Introduced a new type that unifies the Public Inputs `PublicInputValue`. [#416](https://github.com/dusk-network/plonk/issues/416)
- Impl `padded_circuit_size` for `VerifierKey` [#351](https://github.com/dusk-network/plonk/issues/351)
- Impl a generic method that can verify Proofs of any `Circuit`. [#396](https://github.com/dusk-network/plonk/issues/396)

### Removed
- Deprecated `anyhow` and `thiserror` [#343](https://github.com/dusk-network/plonk/issues/343)

- Remove `Canon` impl for `Proof`. [#450](https://github.com/dusk-network/plonk/issues/450)
- Remove serde support completely from the repo. [#353](https://github.com/dusk-network/plonk/issues/353)
- Removed previous implementations attached to `PublicInputValues`. [#416](https://github.com/dusk-network/plonk/issues/416)
- Deprecated `anyhow` and `thiserror`. [#343](https://github.com/dusk-network/plonk/issues/343)
- Remove `serialisation` module and use single serialization fn's. [#347](https://github.com/dusk-network/plonk/issues/347)
- Remove uncessary `match` branch for `var_c` [#414](https://github.com/dusk-network/plonk/issues/414)
- Remove legacy fns and move to test modules the only-for-testing ones. [#434](https://github.com/dusk-network/plonk/issues/434)

### Changed
- Updated the native errors to all originate from the same enum

- Constrained as much as possible the visibility of fns, structs and it's fields [#438](https://github.com/dusk-network/plonk/issues/438)]
- Store the sparse repr of the PI and positions in a `BTreeMap` [#427](https://github.com/dusk-network/plonk/issues/427)
- Transcript Init and trim size are associated constants of the Circuit trait [#351](https://github.com/dusk-network/plonk/issues/351)
- Replace `collections::HashMap` by `hashbrown::HashMap`. [#424](https://github.com/dusk-network/plonk/issues/424)
- `Circuit` trait now only requires `padded_circuit_size` for trimming. [#351](https://github.com/dusk-network/plonk/issues/351)
- Remove `verify_proof` & `build_pi` from `Circuit`. [#396](https://github.com/dusk-network/plonk/issues/396)
- Update API naming conventions to be standard across the crate. [#354](https://github.com/dusk-network/plonk/issues/354)
- Updated the native errors to all originate from the same enum. [#343](https://github.com/dusk-network/plonk/issues/343)

## [0.5.1] - 02-02-21

### Changed

- Implement `Clone` for `PublicParameters` [#383](https://github.com/dusk-network/plonk/issues/383)

## [0.5.0] - 27-01-21

### Changed

- Upgrade canonical to v0.5 (#371)
- Upgrade dusk-bls12_381 to v0.6
- Upgrade dusk-jubjub to v0.8

## [0.4.0] - 26-01-21

### Fixed

- Heavy data structures from unchecked [#332](https://github.com/dusk-network/plonk/issues/332)

### Changed

- Refactored to/from_bytes criteria for some structs (#333)
- API breaking - Implement to/from unchecked bytes for public parameters (#332)

## [0.3.6] - 17-12-20
### Added

### Added

- To/From bytes impl for `PublicInput`.

### Changed

- Changed `compute_permutation_poly` to simpler version.

## [0.3.5] - 25-11-20

### Changed

- Changed `Proof` & `ProofEvaluations` byte conversion fn signatures.

### Added

- Implemented `Canon` for `Proof`.

## [0.3.4] - 02-11-20

### Changed

- dusk-jubjub update to `v0.5.0` with API renaming
- dusk-bls12_381 update to `v0.3.0` with API renaming

## [0.3.3] - 02-11-20

### Added

- `canon` feature to manage `Canon` derivations usage in ecc libs.

### Changed

- dusk-jubjub update to `v0.4.0`
- dusk-bls12_381 update to `v0.2.0`

## [0.3.2] - 29-10-20

### Changed

- dusk-bls12_381 update to `v0.1.5`
- dusk-jubjub update to `v0.3.10`
- Fixes #311 - big_mul and big_mul_gate documentation nit.

## [0.3.1] - 05-10-20

### Added

- Method to change the `trim_params_size` for the `Circuit` trait.

## [0.3.0] - 05-10-20

### Changed

- `Circuit` trait API & usability improvements (#313)

## [0.2.11] - 29-09-20

### Changed

- Now `Circuit` inputs are set in the circuit structure as `Option<T>`.
- Make `PublicInput::value()` fn public.
- Make pi_builder return `Result<T>`
- Refactored examples for the `Circuit` trait impl
according to the new changes.
according to the new changes.

### Removed

- Removed `CircuitInputs` from the crate.

## [0.2.10] - 23-09-20

### Added
- Added `CircuitBuilder` trait and a example for it.

- Added `CircuitBuilder` trait and a example for it.

## [0.2.9] - 11-09-20

### Added

- Added `ProverKey` & `Verifierkey` to the public API as exported types.

### Changed
- Use `dusk-bls12_381 v0.1.4`.
- Use `dusk-jubjub v0.3.8`.

- Use `dusk-bls12_381 v0.1.4`.
- Use `dusk-jubjub v0.3.8`.

## [0.2.8] - 25-08-20

### Added

- Add a `variable_base_scalar_mul` method using a variable base curve add gate.

### Changed
- `ecc::scalar_mul` now named fixed_base_scalar_mul

- `ecc::scalar_mul` now named fixed_base_scalar_mul

## [0.2.7] - 13-08-20

### Added

- `Anyhow` & `thiserror` for error handling support.
- Serialisation methods for the crate public structures &
`serde` support.
`serde` support.
- Add a `variable_base_scalar_mul` method using a variable base curve add gate.

### Removed

- `failure` for error support since has been deprecated.

### Changed

- `add_witness_to_circuit_description` requires now just to send
a `Scalar` and returns a constant & constrained witness `Variable`.
a `Scalar` and returns a constant & constrained witness `Variable`.
- Update `add_witness_to_circuit_description` fn sig (#282, #284)
- dusk-jubjub version updated to 0.3.6
- `ecc::scalar_mul` now named fixed_base_scalar_mul

## [0.2.6] - 03-08-20

### Changed

- Make public inputs vector publicly accessible.

## [0.2.5] - 31-07-20

### Changed

- ECC Point from `ecc:scalar_mul` should have its attributes exposed.

## [0.2.4] - 29-07-20

### Changed

- Changed `dusk-jubjub` version to `v0.3.5` to fix Fr random gen.

## [0.2.3] - 28-07-20

### Changed

- Changed `dusk-jubjub` version to `v0.3.4` to update dhke generation.

## [0.2.2] - 25-07-20

### Added

- Method to create constrained witness values. @CPerezz

### Changed

- Visibility of the `Proof::verify()` fn to `pub(crate)`. @CPerezz
- Changed `dusk-jubjub` version to `v0.3.3` since `v0.3.2` was yanked.

## [0.2.1] - 24-07-20 [yanked]

### Added

- Method to create constrained witness values. @CPerezz

### Changed

- Visibility of the `Proof::verify()` fn to `pub(crate)`. @CPerezz


## [0.2.0] - 20-07-20

### Added

- Prover and Verifier abstraction @kevaundray
- Error handling and custom errors @CPerezz
- Add prelude file @CPerezz
Expand All @@ -159,17 +242,20 @@ a `Scalar` and returns a constant & constrained witness `Variable`.
- Add identity separation challenge to each identity @kevaundray

### Changed

- Widget splitting to modularize the codebase @kevaundray

### Fixed

- Bug in "front-end" assertions in logic_constraint gates @CPerezz
- Broken links in the docs @CPerezz

### Removed
- Serde support for the time being.

- Serde support for the time being.

## [0.1.0] - 25-04-20

### Added

- PLONK algorithm implementation.
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "dusk-plonk"
version = "0.5.1"
version = "0.6.0"
authors = ["Kevaundray Wedderburn <kevtheappdev@gmail.com>",
"Luke Pearson <luke@dusk.network>",
"CPerezz <carlos@dusk.network>"]
Expand All @@ -25,15 +25,15 @@ merlin = "2.0.0"
rand = "0.7"
rand_core = {version="0.5", default-features=false}
dusk-bytes = "0.1"
# Built by default with "std", "alloc", "pairing", "groups" and "endo" features.
dusk-bls12_381 = "0.6"
dusk-jubjub = "0.8"
itertools = "0.9.0"
rand_chacha = "0.2"
rayon = "1.3.0"
serde = "1.0"
hashbrown = "0.9"
# Dusk related deps for WASMI serde
canonical = {version = "0.5", optional = true}
canonical_derive = {version = "0.5", optional = true}

[dev-dependencies]
tempdir = "0.3"
Expand All @@ -47,4 +47,4 @@ std = []
nightly = []
trace = []
trace-print = ["trace"]
canon = ["dusk-bls12_381/canon", "dusk-jubjub/canon", "canonical"]
canon = ["dusk-bls12_381/canon", "dusk-jubjub/canon", "canonical", "canonical_derive"]

0 comments on commit 8e431bf

Please sign in to comment.