use anyhow::Result;
pub mod prelude;
#[cfg_attr(docsrs, doc(cfg(feature = "risc0")))]
#[cfg(feature = "risc0")]
pub mod risc0;
#[cfg_attr(docsrs, doc(cfg(feature = "sp1")))]
#[cfg(feature = "sp1")]
pub mod sp1;
pub trait ZKAgent {
fn execute(&self, input: &[u8], program: &dyn ZKProgram) -> Result<Box<dyn ZKExe>>;
fn verify(&self, proof: &dyn ZKExe) -> Result<Vec<u8>>;
}
pub trait ZKProgram {
fn id(&self) -> &[u8; 32];
fn name(&self) -> Option<&str>;
fn elf(&self) -> &[u8];
fn agent(&self) -> &dyn ZKAgent;
fn execute(&self, input: &[u8], agent: Option<&dyn ZKAgent>) -> Result<Box<dyn ZKExe>>
where
Self: Sized,
{
let agent = agent.unwrap_or(self.agent());
agent.execute(input, self)
}
}
pub trait ZKExe {
fn cipher_bytes(&self) -> &[u8];
fn program_id(&self) -> &[u8; 32];
fn agent(&self) -> &dyn ZKAgent;
fn program(&self) -> Option<&dyn ZKProgram>;
fn program_name(&self) -> &str {
self.program()
.map(|p| p.name())
.flatten()
.unwrap_or("unnamed program")
}
}