zk-protocol 0.4.0

Shared protocol types for the ZK attestation service — any agent can use these to compose AttestRequest/AttestResponse.
Documentation

zk-protocol

Shared protocol types for composing ZK attestation requests and responses.

Any agent or service can use this crate to communicate with a ZK attestation service powered by SP1 zero-knowledge proofs.

Types

Struct Purpose
AttestRequest Request a Groth16 ZK proof from the attester
AttestResponse Proof, public values, and VK hash returned by the attester
RegisterResponse Confirmation after registering an ELF program
AgentResponse Agent endpoint response with program_id and elf_hash

Quick start

[dependencies]
zk-protocol = "0.1"
use zk_protocol::{AttestRequest, AttestResponse, serialize_input};

// Serialize your program input
let input_bytes = serialize_input(&my_data).unwrap();

// Build the request
let req = AttestRequest {
    program_id: "sha256:abcdef...".into(),
    input_bytes,
    stdin_items: vec![],          // or multiple items for multi-read programs
    claimed_output: None,
    verify_locally: true,
};

Multi-read programs

If your zkVM program calls sp1_zkvm::io::read() multiple times, use stdin_items instead of input_bytes. Each entry in the vec maps to one io::read() call inside the guest program:

let req = AttestRequest {
    program_id: id.clone(),
    input_bytes: vec![],
    stdin_items: vec![
        bincode::serialize(&first_arg).unwrap(),
        bincode::serialize(&second_arg).unwrap(),
    ],
    claimed_output: None,
    verify_locally: true,
};

License

MIT