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]
:
toml
snarkify-sdk = "0.1.0"
or simply run
shell
cargo add snarkify-sdk
snarkify.rs
file in your /src
dirProofHandler
trait and prove
methodrun::<YourProofHandler>()
in the main functionHere's a basic example illustrating how to use the SDK:
```rust use serde::{Deserialize, Serialize}; use snarkify_sdk::{prover::ProofHandler, run}; use std::io::Error;
struct MyProofHandler;
struct MyInput { public_input: String, }
struct MyOutput { proof: String, }
impl ProofHandler for MyProofHandler {
type Input = MyInput;
type Output = MyOutput;
type Error = ();
fn prove(data: MyInput) -> Result
fn main() -> Result<(), Error> {
run::
```
As an example, to run the prover basic_prover
in examples directory, simply run
shell
cargo run --example basic_prover
and you can test the prover locally with a sample request like
shell
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"
}'