vex-core 1.7.0

Core types for VEX: Agent, ContextPacket, MerkleNode, Evolution
Documentation
//! # VEX ZK Bridge
//!
//! Provides the trait-based interface for Zero-Knowledge proof verification.
//! This allows vex-core to remain decoupled from heavy ZK libraries like Plonky3
//! while still supporting "Shadow Intent" verification.

use serde_json::Value;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum ZkError {
    #[error("Verification failed: {0}")]
    VerificationFailed(String),
    #[error("Invalid proof format: {0}")]
    InvalidFormat(String),
    #[error("Missing public inputs: {0}")]
    MissingMetadata(String),
    #[error("Configuration error: {0}")]
    ConfigError(String),
}

/// Interface for ZK-STARK verification.
/// Implementations are provided by downstream crates (e.g., attest-rs).
pub trait ZkVerifier: Send + Sync + std::fmt::Debug {
    /// Verifies a STARK proof against a commitment and public inputs.
    ///
    /// # Arguments
    /// * `commitment_hash` - The root hash the proof must bind to.
    /// * `stark_proof_b64` - Base64 encoded STARK proof.
    /// * `public_inputs` - JSON values representing the non-private data.
    fn verify_stark(
        &self,
        commitment_hash: &str,
        stark_proof_b64: &str,
        public_inputs: &Value,
    ) -> Result<bool, ZkError>;

    /// Computes the JCS hash of the verifier's own parameters (Phase 3 Binding).
    fn to_jcs_hash(&self) -> Result<crate::merkle::Hash, String> {
        Ok(crate::merkle::Hash::digest(&[])) // Dummy default for mocks/Phase 1
    }
}