circom-compat
circom-compat copied to clipboard
Invalid proofs when proving in parallel.
The ProvingKey<Bn254>
, ConstraintMatrices<Fr>
are shared through constant reference. WitnessCalculator
is cloned and passed as mutable reference.
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.