Skip to content

Commit

Permalink
Merge branch 'master' into reconcile
Browse files Browse the repository at this point in the history
  • Loading branch information
xevisalle authored Mar 4, 2022
2 parents 0778171 + e532089 commit 0d83802
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 37 deletions.
66 changes: 61 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

### Changed

- Change variable names for more consistency with the paper [#631](https://github.com/dusk-network/plonk/issues/631)

## [0.10.0] - 24-02-22

## Changed

- Update canonical and canonical-derive to 0.7 [#666](https://github.com/dusk-network/plonk/pull/666)
- Update dusk-bls12_381 to 0.9 [#666](https://github.com/dusk-network/plonk/pull/666)
- Update jubjub to 0.11 [#666](https://github.com/dusk-network/plonk/pull/666)
- Update rust edition to 2021 [#667](https://github.com/dusk-network/plonk/pull/667)

## [0.9.2] - 06-01-22

### Added

- Add `circuit::verify` to `Circuit` module. [#656](https://github.com/dusk-network/plonk/pull/656)

## [0.9.1] - 05-01-22

### Added

- Add support for rendering LaTeX in the docs [#630](https://github.com/dusk-network/plonk/pull/630)
- Add `append_public_witness` to `TurboComposer`. [#654](https://github.com/dusk-network/plonk/issues/654)

## [0.9.0] - 10-11-21

### Added
Expand Down Expand Up @@ -211,7 +231,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- 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.
- Fixes [#311](https://github.com/dusk-network/plonk/issues/311) - big_mul and big_mul_gate documentation nit.

## [0.3.1] - 05-10-20

Expand All @@ -223,7 +243,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- `Circuit` trait API & usability improvements (#313)
- `Circuit` trait API & usability improvements [#313](https://github.com/dusk-network/plonk/issues/313)

## [0.2.11] - 29-09-20

Expand Down Expand Up @@ -283,7 +303,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

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

Expand Down Expand Up @@ -369,3 +389,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- KZG10 polynomial commitment scheme implementation.
- fft module with Polynomial ops implemented.
- Proof system module.

<!-- VERSIONS -->
[unreleased]: https://github.com/dusk-network/plonk/compare/v0.10.0...HEAD
[0.10.0]: https://github.com/dusk-network/plonk/compare/v0.9.2...v0.10.0
[0.9.2]: https://github.com/dusk-network/plonk/compare/v0.9.1...v0.9.2
[0.9.1]: https://github.com/dusk-network/plonk/compare/v0.9.0...v0.9.1
[0.9.0]: https://github.com/dusk-network/plonk/compare/v0.8.2...v0.9.0
[0.8.2]: https://github.com/dusk-network/plonk/compare/v0.8.1...v0.8.2
[0.8.1]: https://github.com/dusk-network/plonk/compare/v0.8.0...v0.8.1
[0.8.0]: https://github.com/dusk-network/plonk/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/dusk-network/plonk/compare/v0.6.1...v0.7.0
[0.6.1]: https://github.com/dusk-network/plonk/compare/v0.6.0...v0.6.1
[0.6.0]: https://github.com/dusk-network/plonk/compare/v0.5.1...v0.6.0
[0.5.1]: https://github.com/dusk-network/plonk/compare/v0.5.0...v0.5.1
[0.5.0]: https://github.com/dusk-network/plonk/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/dusk-network/plonk/compare/v0.3.6...v0.4.0
[0.3.6]: https://github.com/dusk-network/plonk/compare/v0.3.5...v0.3.6
[0.3.5]: https://github.com/dusk-network/plonk/compare/v0.3.4...v0.3.5
[0.3.4]: https://github.com/dusk-network/plonk/compare/v0.3.3...v0.3.4
[0.3.3]: https://github.com/dusk-network/plonk/compare/v0.3.2...v0.3.3
[0.3.2]: https://github.com/dusk-network/plonk/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/dusk-network/plonk/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/dusk-network/plonk/compare/v0.2.11...v0.3.0
[0.2.11]: https://github.com/dusk-network/plonk/compare/v0.2.10...v0.2.11
[0.2.10]: https://github.com/dusk-network/plonk/compare/v0.2.9...v0.2.10
[0.2.9]: https://github.com/dusk-network/plonk/compare/v0.2.8...v0.2.9
[0.2.8]: https://github.com/dusk-network/plonk/compare/v0.2.7...v0.2.8
[0.2.7]: https://github.com/dusk-network/plonk/compare/v0.2.6...v0.2.7
[0.2.6]: https://github.com/dusk-network/plonk/compare/v0.2.5...v0.2.6
[0.2.5]: https://github.com/dusk-network/plonk/compare/v0.2.4...v0.2.5
[0.2.4]: https://github.com/dusk-network/plonk/compare/v0.2.3...v0.2.4
[0.2.3]: https://github.com/dusk-network/plonk/compare/v0.2.2...v0.2.3
[0.2.2]: https://github.com/dusk-network/plonk/compare/v0.2.1...v0.2.2
[0.2.1]: https://github.com/dusk-network/plonk/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/dusk-network/plonk/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/dusk-network/plonk/releases/tag/v0.1.0
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "dusk-plonk"
version = "0.9.0"
categories =["algorithms", "cryptography", "science"]
edition = "2018"
version = "0.10.0"
categories =["algorithms", "cryptography", "science", "mathematics"]
edition = "2021"
keywords = ["cryptography", "plonk", "zk-snarks", "zero-knowledge", "crypto"]
license = "MPL-2.0"
repository = "https://github.com/dusk-network/plonk"
Expand All @@ -20,15 +20,15 @@ exclude = [
merlin = {version = "3.0", default-features = false}
rand_core = {version="0.6", default-features=false}
dusk-bytes = "0.1"
dusk-bls12_381 = {version = "0.8", default-features = false, features = ["groups", "pairings", "endo"]}
dusk-jubjub = {version = "0.10", default-features = false}
dusk-bls12_381 = {version = "0.9", default-features = false, features = ["groups", "pairings", "endo"]}
dusk-jubjub = {version = "0.11", default-features = false}
itertools = {version = "0.9", default-features = false}
hashbrown = {version = "0.9", default-features=false, features = ["ahash"]}
rayon = {version = "1.3", optional = true}
cfg-if = "1.0"
# Dusk related deps for WASMI serde
canonical = {version = "0.6", optional = true}
canonical_derive = {version = "0.6", optional = true}
canonical = {version = "0.7", optional = true}
canonical_derive = {version = "0.7", optional = true}

[dev-dependencies]
criterion = "0.3"
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@

_This is a pure Rust implementation of the PLONK proving system over BLS12-381_

This library contains a modularized implementation of KZG10 as the default polynomial commitment scheme.

This library contains a modularised implementation of KZG10 as the default
polynomial commitment scheme.

**DISCLAIMER**: This library is currently unstable and still needs to go through
an exhaustive security analysis. Use at your own risk.

## Usage

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2021-11-17
nightly-2021-10-28
59 changes: 38 additions & 21 deletions src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,27 +317,13 @@ where
public_inputs: &[PublicInputValue],
transcript_init: &'static [u8],
) -> Result<(), Error> {
let gates = verifier_data.key().padded_gates();
let pi_indexes = verifier_data.public_inputs_indexes();

let mut dense_pi = vec![BlsScalar::zero(); gates];

public_inputs
.iter()
.map(|pi| pi.0.clone())
.flatten()
.zip(pi_indexes.iter().cloned())
.for_each(|(value, pos)| {
dense_pi[pos] = -value;
});

let mut verifier = Verifier::new(transcript_init);

verifier.verifier_key.replace(*verifier_data.key());

let opening_key = pub_params.opening_key();

verifier.verify(proof, opening_key, &dense_pi)
verify(
pub_params,
verifier_data,
proof,
public_inputs,
transcript_init,
)
}

/// Return the list of public inputs generated by the gadget
Expand All @@ -346,3 +332,34 @@ where
/// Returns the Circuit size padded to the next power of two.
fn padded_gates(&self) -> usize;
}

/// Verify the provided proof for the compiled verifier data
pub fn verify(
pub_params: &PublicParameters,
verifier_data: &VerifierData,
proof: &Proof,
public_inputs: &[PublicInputValue],
transcript_init: &'static [u8],
) -> Result<(), Error> {
let gates = verifier_data.key().padded_gates();
let pi_indexes = verifier_data.public_inputs_indexes();

let mut dense_pi = vec![BlsScalar::zero(); gates];

public_inputs
.iter()
.map(|pi| pi.0.clone())
.flatten()
.zip(pi_indexes.iter().cloned())
.for_each(|(value, pos)| {
dense_pi[pos] = -value;
});

let mut verifier = Verifier::new(transcript_init);

verifier.verifier_key.replace(*verifier_data.key());

let opening_key = pub_params.opening_key();

verifier.verify(proof, opening_key, &dense_pi)
}
20 changes: 18 additions & 2 deletions src/constraint_system/composer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,21 @@ impl TurboComposer {
var
}

/// Allocate a witness value into the composer and return its index.
///
/// Create a public input with the scalar
pub fn append_public_witness<T: Into<BlsScalar>>(
&mut self,
scalar: T,
) -> Witness {
let scalar = scalar.into();
let witness = self.append_witness(scalar);

self.assert_equal_constant(witness, 0, Some(-scalar));

witness
}

/// Adds a width-4 poly gate.
///
/// The final constraint added will enforce the following:
Expand Down Expand Up @@ -303,12 +318,13 @@ impl TurboComposer {
/// Constrain `a` to be equal to `constant + pi`.
///
/// `constant` will be defined as part of the public circuit description.
pub fn assert_equal_constant(
pub fn assert_equal_constant<C: Into<BlsScalar>>(
&mut self,
a: Witness,
constant: BlsScalar,
constant: C,
pi: Option<BlsScalar>,
) {
let constant = constant.into();
let constraint = Constraint::new().left(1).constant(-constant).a(a);

// TODO maybe accept `Constraint` instead of `Option<Scalar>`?
Expand Down

0 comments on commit 0d83802

Please sign in to comment.