Crates.io | snarkify-sdk |
lib.rs | snarkify-sdk |
version | 0.1.0-alpha.9 |
source | src |
created_at | 2023-09-27 00:23:35.650645 |
updated_at | 2024-11-05 19:16:08.895436 |
description | Snarkify Rust SDK for Streamlined Serverless Prover Development and Deployment |
homepage | |
repository | |
max_upload_size | |
id | 984189 |
size | 97,395 |
The Snarkify SDK is a Rust library designed to simplify the creation and deployment of ZKP provers as serverless services to Snarkify Trustless Cloud.
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
snarkify.rs
in your src/bin
directoryProofHandler
trait and prove
method for proof creationsnarkify_sdk::run::<{YourProofHandler}>()
in the main functionHere'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>()
}
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"
}'