# 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](https://github.com/Zero-Proof-AI/zk-attestation-service)
powered by [SP1](https://github.com/succinctlabs/sp1) zero-knowledge proofs.
## Types
| `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
```toml
[dependencies]
zk-protocol = "0.1"
```
```rust
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:
```rust
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