Python SDK
The Python SDK simplifies interacting with the Sindri API.
Installation​
Some features of the SDK require a Python version of 3.10
or above. You may encounter difficulty installing the package with older Python versions.
The Sindri Python SDK simplifies interacting with the Sindri API. You can easily install it with pip
.
pip install sindri
module sindri.py
Usage​
# Download some sample data
# git clone https://github.com/Sindri-Labs/sindri-resources.git
# pip install sindri
from sindri import Sindri
# Initialize
sindri = Sindri("<YOUR_API_KEY>", verbose_level=2)
# Upload a Circuit
circuit_upload_path: str = "sindri-resources/circuit_database/circom/multiplier2"
circuit_id: str = sindri.create_circuit(circuit_upload_path)
# Generate a Proof
proof_input_file_path = "sindri-resources/circuit_database/circom/multiplier2/input.json"
with open(proof_input_file_path, "r") as f:
proof_id: str = sindri.prove_circuit(circuit_id, f.read())
class Sindri
​
A utility class for interacting with the Sindri API.
function __init__
​
__init__(api_key: str, verbose_level: int = 0, **kwargs)
Initialize an instance of the Sindri SDK.
Args:
api_key
: Your Sindri API Key.verbose_level
: Must be either0
,1
, or2
.0
: Do not print anything to stdout.1
: Print only necesessary information from Circuit/Proof objects.2
: Print everything.
Returns:
sindri
: An instance of the class configured with your Sindri API Key.
Raises:
Sindri.APIError
:- Your API Key is improperly formatted.
function create_circuit
​
create_circuit(
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.
Args:
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
:- If
True
, block until the circuit is finished compiling. - If
False
, submit the circuit and return immediately.
- If
Returns:
circuit_id
: The UUID4 identifier associated with this circuit. This is generated by Sindri.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- There is an error with your circuit upload.
- The circuit has a compilation error (if
wait=True
).
function delete_circuit
​
delete_circuit(circuit_id: str) → None
Mark the specified circuit and any of its related proofs as deleted. For information, refer to the API docs.
Args:
circuit_id
: The circuit identifier of the circuit.
Returns:
None
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- The specified circuit does not exist.
function delete_proof
​
delete_proof(proof_id: str) → None
Mark the specified proof as deleted. For information, refer to the API docs.
Args:
proof_id
: The UUID4 identifier associated with this proof.
Returns:
None
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- The specified proof does not exist.
function get_all_circuit_proofs
​
get_all_circuit_proofs(circuit_id: str) → list[dict]
Return a list of proof infos for the provided circuit_id. For information, refer to the API docs.
Args:
circuit_id
: The circuit identifier of the circuit.
Returns:
proofs
: A list of proof infos.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- The specified circuit does not exist.
function get_all_circuits
​
get_all_circuits() → list[dict]
Return a list of all circuit infos. For information, refer to the API docs.
Args:
None
Returns:
circuits
: A list of circuit infos.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
function get_circuit
​
get_circuit(circuit_id: str, include_verification_key: bool = True) → dict
Get info for an existing circuit. For information, refer to the API docs.
Args:
circuit_id
: The circuit identifier of the circuit.include_verification_key
: Indicates whether to include the verification key in the response.
Returns:
circuit
: The info for a circuit.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- The specified circuit does not exist.
function get_proof
​
get_proof(
proof_id: str,
include_proof: bool = True,
include_public: bool = True,
include_smart_contract_calldata: bool = True,
include_verification_key: bool = True
) → dict
Get info for an existing proof. For information, refer to the API docs.
Args:
proof_id
: The UUID4 identifier associated with this proof.include_proof
: Indicates whether to include the proof in the response.include_public
: Indicates whether to include the public inputs in the response.include_smart_contract_calldata
: Indicates whether to include the proof and public formatted as smart contract calldata in the response.include_verification_key
: Indicates whether to include the verification key in the response.
Returns:
proof
: The info for a proof.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- The specified proof does not exist.
include_smart_contract_calldata=True
and the proof's circuit type does not support generating calldata for its circuit's smart contract verifier or the proof was generated before this feature was released.
function get_smart_contract_verifier
​
get_smart_contract_verifier(circuit_id: str) → str
Get the smart contract verifier for an existing circuit.
NOTE: This method wraps an experimental Sindri API endpoint is subject to change at any time.
Args:
circuit_id
: The circuit identifier of the circuit.
Returns:
smart_contract_verifier_code
: The smart contract verifier code for the circuit.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- The specified circuit does not exist.
- The circuit's type does not support this feature.
- The circuit was compiled before this feature was released.
function get_user_team_details
​
get_user_team_details() → dict
Get details about the user or team associated with the configured API Key.
Args:
None
Returns:
team
: The info for the user/team.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
function prove_circuit
​
prove_circuit(
circuit_id: str,
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.
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 during the proof creation.wait
:- If
True
, block until the proof is finished generating. - If
False
, submit the proof and return immediately.
- If
Returns:
proof_id
: The UUID4 identifier associated with this proof. This is generated by Sindri.
Raises:
Sindri.APIError
:- Your API Key is invalid.
- There is an error connecting to the Sindri API.
- The specified circuit does not exist.
- The proof input is improperly formatted.
- The proof generation fails. (if
wait=True
).
function set_api_key
​
set_api_key(api_key: str) → None
Set the API Key for the Sindri instance.
Args:
api_key
: Your Sindri API Key.
Returns:
None
Raises:
Sindri.APIError
:- Your API Key is improperly formatted.
function set_verbose_level
​
set_verbose_level(verbose_level: int) → None
Set the verbosity level for stdout printing.
Args:
verbose_level
: Must be either0
,1
, or2
.0
: Do not print anything to stdout.1
: Print only necesessary information from Circuit/Proof objects.2
: Print everything.
Returns:
None
Raises:
Sindri.APIError
:verbose_level
is invalid.