Skip to content

Commit

Permalink
add meta field to compile/prove endpoint methods
Browse files Browse the repository at this point in the history
  • Loading branch information
KPreisner committed Aug 23, 2024
1 parent 920f986 commit 308d657
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/sindri/sindri.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,11 @@ def _set_json_request_headers(self) -> None:
}

def create_circuit(
self, circuit_upload_path: str, tags: list[str] | None = None, wait: bool = True
self,
circuit_upload_path: str,
tags: list[str] | None = None,
wait: bool = True,
meta: dict | None = None,
) -> str:
"""Create a circuit. For information, refer to the
[API docs](https://sindri.app/docs/reference/api/circuit-create/).
Expand All @@ -359,6 +363,9 @@ def create_circuit(
- `circuit_upload_path`: The path to either
- A directory containing your circuit files
- A compressed file (`.tar.gz` or `.zip`) of your circuit directory
- `meta`: An arbitrary mapping of metadata keys to string values.
This can be used to track additional information about the circuit such as an ID
from an external system.
- `tags`: A list of tags to assign the circuit. Defaults to `["latest"]` if not
sepecified.
- `wait`:
Expand Down Expand Up @@ -405,7 +412,10 @@ def create_circuit(
response_status_code, response_json = self._hit_api(
"POST",
"circuit/create",
data={"tags": tags},
data={
"tags": tags,
"meta": json.dumps(meta),
},
files=files,
)
if response_status_code != 201:
Expand Down Expand Up @@ -740,13 +750,16 @@ def prove_circuit(
proof_input: str,
perform_verify: bool = False,
wait: bool = True,
meta: dict | None = None,
**kwargs,
) -> str:
"""Prove a circuit with specified inputs. For information, refer to the
[API docs](https://sindri.app/docs/reference/api/proof-create/).
Args:
- `circuit_id`: The circuit identifier of the circuit.
- `meta`: An arbitrary mapping of metadata keys to string values. This can be used to
track additional information about the proof such as an ID from an external system.
- `proof_input`: A string representing proof input which may be formatted as JSON for any
framework. Noir circuits optionally accept TOML formatted proof input.
- `perform_verify`: A boolean indicating whether to perform an internal verification check
Expand Down Expand Up @@ -783,6 +796,7 @@ def prove_circuit(
"proof_input": proof_input,
"perform_verify": perform_verify,
"prover_implementation": prover_implementation,
"meta": json.dumps(meta),
},
)
if response_status_code != 201:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sindri.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def test_circuit_create_prove_other(self):
1. Test delete proof
1. Test delete circuit
"""
circuit_id = sindri.create_circuit(noir_circuit_dir)
proof_id = sindri.prove_circuit(circuit_id, noir_proof_input)
circuit_id = sindri.create_circuit(noir_circuit_dir, tags=["latest", "pytest"], meta={"py-sdk": "pytest"})
proof_id = sindri.prove_circuit(circuit_id, noir_proof_input, meta={"py-sdk": "pytest"})
sindri.get_all_circuit_proofs(circuit_id)
sindri.get_circuit(circuit_id)
sindri.get_proof(proof_id)
Expand Down

0 comments on commit 308d657

Please sign in to comment.