Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Parallelize construction of the verifier pairing inputs with Rayon when `std` is enabled, retaining the serial `no_std` path [#1001]

## [0.24.0] - 2026-10-08

### Added
Expand Down Expand Up @@ -842,6 +846,7 @@ is necessary since `rkyv/validation` was required as a bound.
[#1011]: https://github.com/dusk-network/plonk/issues/1011
[#1006]: https://github.com/dusk-network/plonk/issues/1006
[#1004]: https://github.com/dusk-network/plonk/issues/1004
[#1001]: https://github.com/dusk-network/plonk/issues/1001
[#992]: https://github.com/dusk-network/plonk/issues/992
[#987]: https://github.com/dusk-network/plonk/issues/987
[#986]: https://github.com/dusk-network/plonk/issues/986
Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ required-features = ["alloc"]
name = "plonk"
harness = false

[[bench]]
name = "verification"
harness = false
required-features = ["std"]

[[test]]
name = "append_gate"
required-features = ["alloc"]
Expand Down
50 changes: 50 additions & 0 deletions benches/verification.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use std::hint::black_box;

use criterion::{Criterion, criterion_group, criterion_main};
use dusk_plonk::prelude::*;

#[derive(Default)]
struct VerificationCircuit;

impl Circuit for VerificationCircuit {
fn circuit(&self, composer: &mut Composer) -> Result<(), Error> {
for input in 1..=32u64 {
composer.append_public(input);
}

Ok(())
}
}

fn verification_benchmark(c: &mut Criterion) {
let pp = PublicParameters::setup(1 << 6, &mut rand_core::OsRng)
.expect("failed to generate pp");
let (prover, verifier) =
Compiler::compile::<VerificationCircuit>(&pp, b"dusk-network")
.expect("failed to compile circuit");
let (proof, public_inputs) = prover
.prove(&mut rand_core::OsRng, &VerificationCircuit)
.expect("failed to prove");

assert_eq!(public_inputs.len(), 32);
verifier
.verify(&proof, &public_inputs)
.expect("failed to verify proof");

c.bench_function("Verify 32 public inputs", |b| {
b.iter(|| verifier.verify(black_box(&proof), black_box(&public_inputs)))
});
}

criterion_group! {
name = verification;
config = Criterion::default().sample_size(10);
targets = verification_benchmark
}
criterion_main!(verification);
34 changes: 26 additions & 8 deletions src/proof_system/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,22 @@ pub(crate) mod alloc {
//
// Note that we negate this value to be able to subtract
// the pairings later on, using the multi Miller loop.
let left_projective = -(self.w_z_chall_comm.0
+ (self.w_z_chall_w_comm.0 * u_challenge));
let compute_left = || {
-(self.w_z_chall_comm.0
+ (self.w_z_chall_w_comm.0 * u_challenge))
};

// Compute the G_1 element of the second pairing:
// z * [W_z]_1 + (u * z * w) * [W_zw]_1 + [F]_1 - [E]_1
let right_projective =
msm_variable_base(&scalarmuls_points, &scalarmuls_scalars);
let compute_right =
|| msm_variable_base(&scalarmuls_points, &scalarmuls_scalars);

#[cfg(feature = "std")]
let (left_projective, right_projective) =
rayon::join(compute_left, compute_right);
#[cfg(not(feature = "std"))]
let (left_projective, right_projective) =
(compute_left(), compute_right());
Comment thread
moCello marked this conversation as resolved.

#[cfg(test)]
assert_grouped_msm_equivalence(
Expand Down Expand Up @@ -728,13 +737,22 @@ pub(crate) mod alloc {
//
// Note that we negate this value to be able to subtract
// the pairings later on, using the multi Miller loop.
let left_projective = -(self.w_z_chall_comm.0
+ (self.w_z_chall_w_comm.0 * u_challenge));
let compute_left = || {
-(self.w_z_chall_comm.0
+ (self.w_z_chall_w_comm.0 * u_challenge))
};

// Compute the G_1 element of the second pairing:
// z * [W_z]_1 + (u * z * w) * [W_zw]_1 + [F]_1 - [E]_1
let right_projective =
msm_variable_base(&scalarmuls_points, &scalarmuls_scalars);
let compute_right =
|| msm_variable_base(&scalarmuls_points, &scalarmuls_scalars);

#[cfg(feature = "std")]
let (left_projective, right_projective) =
rayon::join(compute_left, compute_right);
#[cfg(not(feature = "std"))]
let (left_projective, right_projective) =
(compute_left(), compute_right());

#[cfg(test)]
assert_grouped_msm_equivalence(
Expand Down
Loading