TrainingQualityVerifier
Overview
TrainingQualityVerifier.circom is a standalone zk-SNARK circuit that proves a language-model’s training meets or exceeds a required quality threshold without revealing raw training samples, model outputs, or proprietary scores.
It serves as the “first gate” in the ZK-AgentMesh verification pipeline and can also be embedded in any project that needs zero-knowledge assurance of model-training quality.
Purpose
The circuit enables an agent developer to convince a verifier that:
Every individual training sample scores at least
min_quality_threshold.The average quality across all samples meets the same threshold.
The proof ties back to a prior on-chain training commitment and model weights hash, preventing post-hoc tampering.
All of the above are proven without exposing:
The underlying data or model responses.
Exact per-sample scores or private metrics.
Inputs
Private Inputs
Training data
training_samples[n_samples × 32]
One Poseidon-hashed field element per token (flattened)
Model outputs
model_responses[n_samples × 32]
Poseidon-hashed response tokens
Quality metrics
quality_scores[n_samples]
Integer score 0–1000 per sample
Integrity
training_seed
Salt used during the commitment phase
Model hash
model_weights_hash
Poseidon hash of final model weights
Public Inputs
agent_id
256-bit unique agent identifier
min_quality_threshold
Minimum acceptable score (0–1000)
training_commitment_hash
Commitment published before training
creator_address
EVM address of developer
Public Outputs
quality_verified
1 if all checks pass, otherwise 0
average_quality
Mean score (integer field element)
training_proof_hash
Poseidon hash binding agent, seed, avg. quality, creator
model_integrity_proof
Poseidon hash binding model weights to seed and agent
Circuit Logic
Per-Sample Check Each
quality_scores[i]is constrained withGreaterEqThanto be ≥min_quality_threshold.Average Calculation
AverageCalculatorsums all scores and enforcesaverage × n_samples == sum.Average Threshold A second
GreaterEqThangate ensuresaverage_quality ≥ min_quality_threshold.Conjunction of Conditions
quality_verifiedis the product ofthe average-threshold flag
the cumulative product of all individual flags If any single check fails, the product is zero.
Hash Commitments
training_proof_hash= Poseidon(agent_id, training_seed, average_quality, creator_address)model_integrity_proof= Poseidon(model_weights_hash, training_seed, agent_id)
These hashes are referenced by higher-level circuits or on-chain contracts.
Compilation
# Requirements: circom 2.x, snarkjs, pot16_final.ptau
circom TrainingQualityVerifier.circom \
--r1cs --wasm --sym --c
snarkjs groth16 setup TrainingQualityVerifier.r1cs \
pot16_final.ptau \
tqv_final.zkey
snarkjs zkey export verificationkey tqv_final.zkey \
tqv_verification_key.jsonProof Workflow
# 1. prepare input.json with private + public signals
node TrainingQualityVerifier_js/generate_witness.js \
TrainingQualityVerifier_js/TrainingQualityVerifier.wasm \
input.json witness.wtns
# 2. generate proof
snarkjs groth16 prove tqv_final.zkey \
witness.wtns \
proof.json public.json
# 3. verify locally
snarkjs groth16 verify tqv_verification_key.json \
public.json proof.jsonpublic.json will contain the four public outputs, ready for on-chain submission.
Security
Private inputs never leave the prover’s environment.
Poseidon hashing maintains circuit efficiency on BN128.
Tampering with model weights is detectable through
model_integrity_proof.The circuit must be recompiled if
n_samplesorn_metricschange.
Status
Current version: stable for integer quality metrics (0–1000).
Planned: floating-point support via fixed-point encoding; integration of additional metrics per sample.
Last updated