This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
Circuit is satisfied but plonk proof verification fails #46
Open
Description
Hi! I have the following test using the current tip of dev
(09474a):
#[test]
fn setup_prove_verify() {
// the program `def main(public field a) -> field { return a }`
let program: Prog<Bn128Field> = Prog {
arguments: vec![Parameter::public(Variable::new(0))],
return_count: 1,
statements: vec![Statement::constraint(Variable::new(0), Variable::public(0))],
};
// generate a dummy universal setup of size 2**10
let crs: Crs<<Bn128Field as BellmanFieldExtensions>::BellmanEngine, CrsForMonomialForm> =
Crs::<<Bn128Field as BellmanFieldExtensions>::BellmanEngine, CrsForMonomialForm>::dummy_crs(2usize.pow(10) as usize);
// transpile
let hints = transpile(Computation::without_witness(program.clone())).unwrap();
// run a circuit specific (transparent) setup
let pols = setup(Computation::without_witness(program.clone()), &hints).unwrap();
// generate a verification key from the circuit specific setup and the crs
let vk = make_verification_key(&pols, &crs).unwrap();
// run the program
let interpreter = Interpreter::default();
// extract the witness
let witness = interpreter
.execute(program.clone(), &[Bn128Field::from(42)])
.unwrap();
// bundle the program and the witness together
let computation = Computation::with_witness(program.clone(), witness);
// transpile
let hints = transpile(Computation::without_witness(program.clone())).unwrap();
// check that the circuit is satisfied
assert!(is_satisfied(computation.clone(), &hints).is_ok());
// generate a proof with no setup precomputations and no init params for the transcript, using Blake2s
let proof: BellmanProof<<Bn128Field as BellmanFieldExtensions>::BellmanEngine, PlonkCsWidth4WithNextStepParams> =
prove_by_steps::<_, _, Blake2sTranscript<_>>(
computation,
&hints,
&pols,
None,
&crs,
None,
)
.unwrap();
// verify the proof using Blake2s
let ans = verify::<_, Blake2sTranscript<_>>(&proof, &vk).unwrap();
// check that the proof is verified
assert!(ans);
}
I would have expected the proof to be verified correctly because the circuit is satisfied, but this test fails. I checked and it fails in the last check in verification.
Is there something I am doing wrong here? Thanks!
Metadata
Assignees
Labels
No labels