Skip to main content

Getting Started with the Sindri Python SDK

Generate your first ZK proof with Sindri in just ten lines of code - 5 min ⏱️

Prerequisites

First, obtain your Sindri API Key. Please review the access management section for guidance on obtaining a Sindri API Key for your account. Send an email to hello@sindri.app to create a Sindri account.

Next, clone the sindri-resources GitHub repo, which contains resources and sample data for the Sindri API. Then, navigate to the reference_code directory.

git clone https://github.com/Sindri-Labs/sindri-resources.git
cd sindri-resources/reference_code/

Python SDK

info

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

Using the SDK

Compile and prove a circuit on Sindri by running:

SINDRI_API_KEY=<YOUR_API_KEY> python3 sdk_quickstart.py

The sdk_quickstart.py script first initializes an instance of the Sindri class with the provided API Key from the SINDRI_API_KEY environment variable. Then, it uploads the Circom multiplier2 circuit from the Sindri Circuit Database to Sindri, which compiles and hosts the circuit and returns its unique ID: circuit_id. Finally, this script creates a zero-knowledge proof for the circuit on Sindri's accelerated hardware with the sample circuit input provided in input.json.

reference_code/sdk_quickstart.py
loading...
Output
Circuit: Create
circuit_id: 5c011135-9f50-497e-83ee-770ad177ad5c
Circuit: Poll until Ready/Failed
Circuit: Get circuit detail for circuit_id: 5c011135-9f50-497e-83ee-770ad177ad5c
{ 'circuit_id': '5c011135-9f50-497e-83ee-770ad177ad5c',
'circuit_name': 'multiplier2',
'circuit_type': 'circom',
'compute_time': 'P0DT00H00M07.422818S',
'date_created': '2023-12-05T02:28:45.776Z',
'status': 'Ready'}

Prove circuit
proof_id: fd8410a7-2c06-4deb-8d66-300c2defc0a6
Proof: Poll until Ready/Failed
Proof: Get proof detail for proof_id: fd8410a7-2c06-4deb-8d66-300c2defc0a6
{ 'circuit_id': '5c011135-9f50-497e-83ee-770ad177ad5c',
'circuit_name': 'multiplier2',
'circuit_type': 'circom',
'compute_time': 'P0DT00H00M01.674586S',
'date_created': '2023-12-05T02:28:56.381Z',
'proof_id': 'fd8410a7-2c06-4deb-8d66-300c2defc0a6',
'status': 'Ready'}