circom-compat icon indicating copy to clipboard operation
circom-compat copied to clipboard

Invalid proofs when proving in parallel.

Open recmo opened this issue 2 years ago • 1 comments

The ProvingKey<Bn254>, ConstraintMatrices<Fr> are shared through constant reference. WitnessCalculator is cloned and passed as mutable reference.

recmo avatar Mar 18 '22 21:03 recmo

Adding a Mutex around the WitnessCalculator solves it. So .clone() on it is not actually safe.

The clone call happens concurrently (because the types allow it). Forcing the clone to be sequential does not solve the issue. Forcing calculate_witness_element to be sequential does solve it. This despite the calls being on separated clones instances. So it appears that clone() creates unsafe shared state.

recmo avatar Mar 18 '22 21:03 recmo