| 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:
cat test-data/sample-groth16-proof.txt
cat test-data/sample-verification-key.txt
2. Submit to API
Create a test submission:
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:
curl http://localhost:8080/api/v1/snarks
Get specific SNARK by ID:
curl http://localhost:8080/api/v1/snark/1
4. Test Validation
Test error handling by submitting invalid data:
Invalid base64:
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:
curl -X POST http://localhost:8080/api/v1/snark \
-H "Content-Type: application/json" \
-d '{
"proof": "AQIDBA=="
}'
5. Test Delete Operation
curl -X DELETE http://localhost:8080/api/v1/snark/1
Then verify deletion:
curl http://localhost:8080/api/v1/snarks
Expected Response Format
Successful Submission
{
"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
{
"error": "Invalid base64 encoding in proof field"
}
Common Test Scenarios
- Happy Path: Submit valid Groth16 proof, verify storage, retrieve by ID
- Edge Cases: Empty strings, very long base64 data, special characters in submitter
- Invalid Data: Malformed base64, missing fields, wrong field types
- Concurrent Submissions: Submit multiple SNARKs rapidly to test ID generation
- Delete and Retrieval: Delete a SNARK and verify 404 on subsequent retrieval
Performance Testing
Test with multiple concurrent submissions:
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=debugwhen 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