#prover #serverless #zkp #deployment #cloud #service #snarkify

snarkify-sdk

Snarkify Rust SDK for Streamlined Serverless Prover Development and Deployment

6 releases

0.1.0-alpha.6 Feb 7, 2024
0.1.0-alpha.5 Nov 8, 2023
0.1.0-alpha.1 Sep 27, 2023

#694 in Web programming

Download history 23/week @ 2023-12-23 1/week @ 2023-12-30 34/week @ 2024-01-06 56/week @ 2024-01-13 27/week @ 2024-01-20 36/week @ 2024-01-27 34/week @ 2024-02-03 22/week @ 2024-02-10 56/week @ 2024-02-17 44/week @ 2024-02-24 40/week @ 2024-03-02 78/week @ 2024-03-09 92/week @ 2024-03-16 58/week @ 2024-03-23 127/week @ 2024-03-30 36/week @ 2024-04-06

338 downloads per month

MIT/Apache

21KB
248 lines

Snarkify SDK

The Snarkify SDK is a Rust library designed to simplify the creation and deployment of ZKP provers as serverless services to Snarkify Trustless Cloud.

Installation

To include the Snarkify SDK in your project, add the following line to your Cargo.toml under [dependencies]:

snarkify-sdk = "0.1.0"

or simply run

cargo add snarkify-sdk

Quick Start

Code changes

  1. Create a new file snarkify.rs in your src/bin directory
  2. Implement the ProofHandler trait and prove method for proof creation
  3. Invoke snarkify_sdk::run::<{YourProofHandler}>() in the main function

Here's a basic example illustrating how to use the SDK:

use std::io;

use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use snarkify_sdk::prover::ProofHandler;

struct MyProofHandler;

#[derive(Deserialize)]
struct MyInput {
    public_input: String,
}

#[derive(Serialize)]
struct MyOutput {
    proof: String,
}

#[async_trait]
impl ProofHandler for MyProofHandler {
    type Input = MyInput;
    type Output = MyOutput;
    type Error = ();

    async fn prove(data: Self::Input) -> Result<Self::Output, Self::Error> {
        Ok(MyOutput {
            proof: data.public_input.chars().rev().collect(),
        })
    }
}

fn main() -> Result<(), io::Error> {
    snarkify_sdk::run::<MyProofHandler>()
}

Running & Testing

As an example, to run the prover basic_prover in examples directory, simply run

cargo run --example basic_prover

and you can test the prover locally with a sample request like

curl --location --request POST 'http://localhost:8080' \
--header 'Content-Type: application/json' \
--header 'ce-specversion: 1.0' \
--header 'ce-id: abcdef123456' \
--header 'ce-source: test' \
--header 'ce-type: com.test.example' \
--data-raw '{
     "public_input": "aloha"
 }'

Dependencies

~19–35MB
~595K SLoC