You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the Prover of a smaller circuit and without public input has been compiled, the proof generation crashes when attempted with a malicious larger circuit that does have public inputs.
To Reproduce
use dusk_plonk::prelude::*;use rand::rngs::StdRng;use rand::SeedableRng;constCAPACITY:usize = 1 << 4;constLABEL:&[u8] = b"check_public_inputs";#[derive(Default)]pubstructTestSize{witnesses:Vec<BlsScalar>,sum:BlsScalar,}implTestSize{pubfnnew(witnesses:Vec<BlsScalar>,sum:BlsScalar) -> Self{Self{ witnesses, sum }}}implCircuitforTestSize{fncircuit<C>(&self,composer:&mutC) -> Result<(),Error>whereC:Composer,{let sum = self.witnesses.iter().fold(C::ZERO, |acc, scalar| {let w = composer.append_witness(*scalar);let constraint = Constraint::new().left(1).a(acc).right(1).b(w);
composer.gate_add(constraint)});let expected_sum = composer.append_witness(self.sum);
composer.assert_equal(sum, expected_sum);Ok(())}}#[test]fnsize(){let rng = &mutStdRng::seed_from_u64(0x10b);let pp = PublicParameters::setup(CAPACITY, rng).expect("Creation of public parameter shouldn't fail");// compiling the default version of TestSize, which only one gate: sum = 0let(prover, _verifier) = Compiler::compile::<TestSize>(&pp,LABEL).expect("It should be possible to compile the prover and verifier");// Create circuit with more gateslet pi:Vec<BlsScalar> = [BlsScalar::one();5].into();let sum = pi.iter().sum();let circuit = TestSize::new(pi, sum);let result = prover.prove(rng,&circuit).err();assert_eq!(
result,Some(dusk_plonk::error::Error::InvalidCircuitSize),"proof creation for different sized circuit shouldn't be possible");}
Expected behaviour
Don't crash
The text was updated successfully, but these errors were encountered:
Describe the bug
When the
Prover
of a smaller circuit and without public input has been compiled, the proof generation crashes when attempted with a malicious larger circuit that does have public inputs.To Reproduce
Expected behaviour
Don't crash
The text was updated successfully, but these errors were encountered: