AgentSkillsCN

snark-testing

使用样本数据测试 SNARK 提交。当测试证明提交、验证 API、确认 SNARK 操作正常工作或调试证明处理时使用。

SKILL.md
--- frontmatter
name: snark-testing
description: Test SNARK submissions with sample data. Use when testing proof submission, validating the API, verifying SNARK operations work correctly, or debugging proof handling.
allowed-tools: Read, Bash

SNARK Testing Assistant

When testing SNARK submissions, follow these steps:

1. Load Test Data

First, read the sample proof files:

bash
cat test-data/sample-groth16-proof.txt
cat test-data/sample-verification-key.txt

2. Submit to API

Create a test submission:

bash
curl -X POST http://localhost:8080/api/v1/snark \
  -H "Content-Type: application/json" \
  -d '{
    "proof": "<base64-from-sample-groth16-proof.txt>",
    "verification_key": "<base64-from-sample-verification-key.txt>",
    "public_inputs": "AQIDBA==",
    "proof_system": "groth16",
    "submitter": "test-user"
  }'

3. Verify Storage

After submission, verify the SNARK was stored:

List all SNARKs:

bash
curl http://localhost:8080/api/v1/snarks

Get specific SNARK by ID:

bash
curl http://localhost:8080/api/v1/snark/1

4. Test Validation

Test error handling by submitting invalid data:

Invalid base64:

bash
curl -X POST http://localhost:8080/api/v1/snark \
  -H "Content-Type: application/json" \
  -d '{
    "proof": "not-valid-base64!@#",
    "verification_key": "also-invalid",
    "public_inputs": "bad-data",
    "proof_system": "groth16",
    "submitter": "test-user"
  }'

Missing required fields:

bash
curl -X POST http://localhost:8080/api/v1/snark \
  -H "Content-Type: application/json" \
  -d '{
    "proof": "AQIDBA=="
  }'

5. Test Delete Operation

bash
curl -X DELETE http://localhost:8080/api/v1/snark/1

Then verify deletion:

bash
curl http://localhost:8080/api/v1/snarks

Expected Response Format

Successful Submission

json
{
  "id": 1,
  "proof": "base64-encoded-proof-data...",
  "verification_key": "base64-encoded-vk-data...",
  "public_inputs": "AQIDBA==",
  "proof_system": "groth16",
  "submitter": "test-user",
  "timestamp": 1234567890,
  "status": "pending"
}

Error Response

json
{
  "error": "Invalid base64 encoding in proof field"
}

Common Test Scenarios

  1. Happy Path: Submit valid Groth16 proof, verify storage, retrieve by ID
  2. Edge Cases: Empty strings, very long base64 data, special characters in submitter
  3. Invalid Data: Malformed base64, missing fields, wrong field types
  4. Concurrent Submissions: Submit multiple SNARKs rapidly to test ID generation
  5. Delete and Retrieval: Delete a SNARK and verify 404 on subsequent retrieval

Performance Testing

Test with multiple concurrent submissions:

bash
for i in {1..10}; do
  curl -X POST http://localhost:8080/api/v1/snark \
    -H "Content-Type: application/json" \
    -d '{...}' &
done
wait

Debugging Tips

  • Check server logs: Set RUST_LOG=debug when running the server
  • Verify server is running: curl http://localhost:8080/
  • Check for port conflicts: lsof -i :8080
  • Examine kernel state: Look at Hoon kernel debug output