Leveraging the zkSVM
Please reach out to request an API key and generate a proof in only a few minutes.
Proof Generation
The high-level flow is to start the session, send requests containing SVM transactions, end the session to trigger proof generation, and poll the endpoint to retrieve summary statistics.
Start Session
Kick off a session and initialize the genesis accounts that should exist before transaction processing. The request will be rejected if it doesn't contain a valid access key.
use zksvm_client::session::Session;
let mut session = Session::new(SERVER_URL, SERVER_PORT, API_KEY)?;
let session_id = session.start(genesis_accounts).await?;
Send Transaction
Send SVM transactions that the prover should include in the ZK proof.
There's a max cap of 50 due to memory constraints of the underlying zkVM, and the server will return how many transactions are remaining for the current session.
let remaining_txs = session.send_transaction(tx).await?;
assert_eq!(49, remaining_txs);
End Session
End the session to trigger proof generation and select the SP1 proof type. Supported types are core
, compressed
, and groth16
. The last option is recommended for most uses, including on-chain verification.
Since proving is async, the response only contains a successful acknowledgement of the request but not the completed proof details.
use zksvm_api_types::common::ProofType;
session.end(ProofType::Groth16).await?;
Proof Verification
Once the prover has completed proof generation, the proof can be verified either locally or via an on-chain program.
Test Utilities
The library provides a few utilities to initialize program accounts and generate sample SVM transactions for convenience.
System Constraints
There are a few limitations to keep in mind. The system currently places a hard cap of 50 transactions per session due to memory constraints of the underlying zkVM, which is around 24B cycles. The server will reject requests that send additional transactions beyond 50. Not that if you start a new session, old data from previous sessions are not persisted.
The zkSVM contains several pre-installed Solana Program Library (SPL) programs, e.g. the token
and token-2022
programs, but any custom programs need to be deployed before they can be interacted with.
Last updated