Skip to content

Commit

Permalink
Merge pull request #803 from dusk-network/mocello/802_composer
Browse files Browse the repository at this point in the history
Turn `Composer` trait into a struct
  • Loading branch information
moCello authored Dec 21, 2023
2 parents 4b3568f + 08dc0f6 commit 3a18dd1
Show file tree
Hide file tree
Showing 29 changed files with 334 additions and 439 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Improve InvalidCircuitSize error [#792]
- Hide all modules except 'prelude' [#782]
- Turn `Composer` trait into a struct [#802]
- Rename `Arithmetization` to `Gate` [#802]

### Removed

- Remove `Builder` struct with introduction of `Composer` struct [#802]

## [0.18.0] - 2023-12-13

Expand Down Expand Up @@ -542,6 +548,7 @@ is necessary since `rkyv/validation` was required as a bound.
- Proof system module.

<!-- ISSUES -->
[#802]: https://github.com/dusk-network/plonk/issues/802
[#797]: https://github.com/dusk-network/plonk/issues/797
[#796]: https://github.com/dusk-network/plonk/issues/796
[#792]: https://github.com/dusk-network/plonk/issues/792
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ pub struct TestCircuit {
}

impl Circuit for TestCircuit {
fn circuit<C>(&self, composer: &mut C) -> Result<(), Error>
where
C: Composer,
fn circuit(&self, composer: &mut Composer) -> Result<(), Error>
{
let a = composer.append_witness(self.a);
let b = composer.append_witness(self.b);
Expand Down
17 changes: 7 additions & 10 deletions benches/plonk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ impl<const DEGREE: usize> Default for BenchCircuit<DEGREE> {
}

impl<const DEGREE: usize> Circuit for BenchCircuit<DEGREE> {
fn circuit<C>(&self, composer: &mut C) -> Result<(), Error>
where
C: Composer,
{
fn circuit(&self, composer: &mut Composer) -> Result<(), Error> {
let w_a = composer.append_witness(self.a);
let w_b = composer.append_witness(self.b);
let w_x = composer.append_witness(self.x);
Expand All @@ -59,19 +56,19 @@ impl<const DEGREE: usize> Circuit for BenchCircuit<DEGREE> {
composer.component_add_point(w_z, w_z);
composer.append_logic_and::<128>(w_a, w_b);
composer.append_logic_xor::<128>(w_a, w_b);
composer.component_boolean(C::ONE);
composer.component_boolean(Composer::ONE);
composer.component_decomposition::<254>(w_a);
composer.component_mul_generator(
w_y,
dusk_jubjub::GENERATOR_EXTENDED,
)?;
composer.component_mul_point(w_y, w_z);
composer.component_range::<128>(w_a);
composer.component_select(C::ONE, w_a, w_b);
composer.component_select_identity(C::ONE, w_z);
composer.component_select_one(C::ONE, w_a);
composer.component_select_point(C::ONE, w_z, w_z);
composer.component_select_zero(C::ONE, w_a);
composer.component_select(Composer::ONE, w_a, w_b);
composer.component_select_identity(Composer::ONE, w_z);
composer.component_select_one(Composer::ONE, w_a);
composer.component_select_point(Composer::ONE, w_z, w_z);
composer.component_select_zero(Composer::ONE, w_a);

diff = composer.constraints() - prev;
prev = composer.constraints();
Expand Down
Loading

0 comments on commit 3a18dd1

Please sign in to comment.