Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Keep witness argument immutable on halo2_mock_prover (#175)
Browse files Browse the repository at this point in the history
Closes #170 

---

On the SuperCircuit's `halo2_mock_prover` method, we are currently
overriding the `super_witness` dict object.
Initially it holds the `TraceWitness` objects of each internal circuit,
but after the loop it holds the JSON representation of the witness of
the circuit.

Since the elements in the dict are indexed by their `rust_id`, after the
loop all the elements have been replaced, leaving the caller of
`halo2_mock_prover` with a "modified" `witness`.

It's not a big problem, but it's confusing sometimes when writing tests,
if you want to verify some of the assignments, because the order of
lines becomes relevant.

I didn't add the return of the `witness_json` because so far I've seen
no use for it. Maybe it could be interesting.
  • Loading branch information
sraver authored Nov 7, 2023
1 parent f1e7491 commit cfdb6dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "chiquito"
version = "0.1.2023110200"
version = "0.1.2023110700"
edition = "2021"
license = "MIT OR Apache-2.0"
authors = ["Leo Lara <[email protected]>"]
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/python/chiquito/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ def gen_witness(self: SuperCircuit, *args: Any) -> Dict[int, TraceWitness]:
def halo2_mock_prover(
self: SuperCircuit, super_witness: Dict[int, TraceWitness], k: int = 16
):
witness_json = {}
for rust_id, witness in super_witness.items():
if rust_id not in self.ast.sub_circuits:
raise ValueError(
f"SuperCircuit.halo2_mock_prover(): TraceWitness with rust_id {rust_id} not found in sub_circuits."
)
witness_json: str = witness.get_witness_json()
super_witness[rust_id] = witness_json
witness_json[rust_id] = witness.get_witness_json()
rust_chiquito.super_circuit_halo2_mock_prover(
list(self.ast.sub_circuits.keys()), super_witness, k
list(self.ast.sub_circuits.keys()), witness_json, k
)


Expand Down

0 comments on commit cfdb6dc

Please sign in to comment.