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

Commit

Permalink
black fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
qwang98 committed Sep 10, 2023
1 parent 912b0f9 commit 832923f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions examples/mimc7.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,5 @@ def mapping(self, args):
x_in_value, k_value = args
self.map(self.mimc7_circuit, (x_in_value, k_value))


Mimc7SuperCircuit()
2 changes: 1 addition & 1 deletion src/frontend/python/chiquito/chiquito_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def expose(self: ASTCircuit, signal: Queriable, offset: ExposeOffset):
def add_step_type(self: ASTCircuit, step_type: ASTStepType, name: str):
self.annotations[step_type.id] = name
self.step_types[step_type.id] = step_type

def add_fixed_assignment(self: ASTCircuit, offset: int, lhs: Queriable, rhs: F):
if not isinstance(lhs, Fixed):
raise ValueError(f"Cannot assign to non-fixed signal.")
Expand Down
24 changes: 15 additions & 9 deletions src/frontend/python/chiquito/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,38 @@ def __init__(self: SuperCircuit):
def sub_circuit(self: SuperCircuit, sub_circuit: Circuit) -> Circuit:
assert self.mode == SuperCircuitMode.SETUP
if sub_circuit.rust_ast_id != 0:
raise ValueError("SuperCircuit: sub_circuit() cannot be called twice on the same circuit.")
raise ValueError(
"SuperCircuit: sub_circuit() cannot be called twice on the same circuit."
)
ast_json: str = sub_circuit.get_ast_json()
sub_circuit.rust_ast_id: int = rust_chiquito.ast_to_halo2(ast_json)
self.ast.sub_circuits[sub_circuit.rust_ast_id] = sub_circuit.ast
return sub_circuit

# called under mapping()
# generates TraceWitness for sub_circuit
def map(self: SuperCircuit, sub_circuit: Circuit, args: Any) -> TraceWitness:
assert self.mode == SuperCircuitMode.Mapping
witness: TraceWitness = sub_circuit.gen_witness(args)
if sub_circuit.rust_ast_id == 0:
raise ValueError("SuperCircuit: must call sub_circuit() before calling map() on a Circuit.")
raise ValueError(
"SuperCircuit: must call sub_circuit() before calling map() on a Circuit."
)
self.ast.witnesses[sub_circuit.rust_ast_id] = witness
return witness

# called at the outermost level
# generates TraceWitness mapping
def gen_witness(self: SuperCircuit, args: Any) -> Dict[int, TraceWitness]:
self.mode = SuperCircuitMode.Mapping
self.mapping(args)
self.mode = SuperCircuitMode.NoMode
witnesses: Dict[int, TraceWitness] = self.ast.witnesses
del self.ast.witnesses # so that we can generate different witness mapping in the next gen_witness() call
del (
self.ast.witnesses
) # so that we can generate different witness mapping in the next gen_witness() call
return witnesses

# def gen_witness(self: Circuit, args: Any) -> TraceWitness:
# self.mode = CircuitMode.Trace
# self.witness = TraceWitness()
Expand All @@ -85,12 +91,12 @@ def halo2_mock_prover(self: SuperCircuit, witnesses: Dict[int, TraceWitness]):
for rust_ast_id, witness in witnesses.items():
witness_json: str = witness.get_witness_json()
if rust_ast_id not in self.ast.sub_circuits:
raise ValueError(f"SuperCircuit.halo2_mock_prover(): TraceWitness with rust_ast_id {rust_ast_id} not found in sub_circuits.")
raise ValueError(
f"SuperCircuit.halo2_mock_prover(): TraceWitness with rust_ast_id {rust_ast_id} not found in sub_circuits."
)
rust_chiquito.add_witness_to_ast(witness_json, rust_ast_id)
for sub_circuit_id in self.ast.sub_circuits:
pass



# def halo2_mock_prover(self: Circuit, witness: TraceWitness):
# if self.rust_ast_id == 0:
Expand Down

0 comments on commit 832923f

Please sign in to comment.