POST
/
proofs
/
generate
curl -X POST https://api.treeship.dev/v1/proofs/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "proofType": "performance",
    "circuitType": "zk-SNARK",
    "publicInputs": {
      "timestamp": 1706380800,
      "modelVersion": "v2.1",
      "datasetHash": "0x7d8f9e8a7b6c5d4e"
    },
    "privateInputs": {
      "testResults": [0.97, 0.96, 0.98, 0.95],
      "trainingData": "encrypted_blob",
      "hyperparameters": {
        "learning_rate": 0.001,
        "batch_size": 32
      }
    },
    "assertions": [
      "average_accuracy > 0.95",
      "min_accuracy > 0.90",
      "training_data_private"
    ],
    "metadata": {
      "agentId": "agent_ml_001",
      "description": "ML model performance proof"
    }
  }'
{
  "proofId": "proof_7d8f9e8a7b6c5d4e",
  "proofType": "performance",
  "circuitType": "zk-SNARK",
  "proof": {
    "data": "0x8f9d3a4e5b6c7d8e9f0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v...",
    "publicInputs": {
      "timestamp": 1706380800,
      "modelVersion": "v2.1",
      "datasetHash": "0x7d8f9e8a7b6c5d4e"
    },
    "verificationKey": "0x2a3b4c5d6e7f8g9h0i1j2k3l4m5n6o7p8q9r0s1t2u3v4w5x6y7z8a9b0c1d2e",
    "circuitHash": "0x9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b"
  },
  "assertions": {
    "average_accuracy > 0.95": true,
    "min_accuracy > 0.90": true,
    "training_data_private": true
  },
  "status": "success",
  "generationTime": 156,
  "proofSize": 192,
  "metadata": {
    "agentId": "agent_ml_001",
    "description": "ML model performance proof"
  },
  "createdAt": "2024-01-27T12:30:00Z",
  "expiresAt": "2024-02-27T12:30:00Z"
}

Request

proofType
string
required
Type of proof to generate. Options:
  • performance - Prove agent performance metrics
  • capability - Prove agent capabilities
  • transaction - Prove transaction validity
  • compliance - Prove regulatory compliance
  • data_integrity - Prove data hasn’t been tampered with
  • execution - Prove code execution occurred correctly
circuitType
string
default:"zk-SNARK"
Zero-Knowledge circuit type. Options: zk-SNARK, zk-STARK
publicInputs
object
required
Public inputs that will be revealed in the proof
{
  "timestamp": 1706380800,
  "version": "1.0",
  "merkleRoot": "0x7d8f9e8a..."
}
privateInputs
object
required
Private inputs used in computation but not revealed
{
  "secretData": "encrypted_blob",
  "privateKey": "0x...",
  "sensitiveMetrics": {...}
}
assertions
array
required
List of statements to prove
[
  "accuracy > 0.95",
  "latency < 100ms",
  "data_not_modified",
  "authorized_access_only"
]
metadata
object
Additional metadata for the proof
{
  "agentId": "agent_123",
  "taskId": "task_456",
  "description": "Model accuracy proof"
}
curl -X POST https://api.treeship.dev/v1/proofs/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "proofType": "performance",
    "circuitType": "zk-SNARK",
    "publicInputs": {
      "timestamp": 1706380800,
      "modelVersion": "v2.1",
      "datasetHash": "0x7d8f9e8a7b6c5d4e"
    },
    "privateInputs": {
      "testResults": [0.97, 0.96, 0.98, 0.95],
      "trainingData": "encrypted_blob",
      "hyperparameters": {
        "learning_rate": 0.001,
        "batch_size": 32
      }
    },
    "assertions": [
      "average_accuracy > 0.95",
      "min_accuracy > 0.90",
      "training_data_private"
    ],
    "metadata": {
      "agentId": "agent_ml_001",
      "description": "ML model performance proof"
    }
  }'

Response

proofId
string
Unique identifier for the generated proof
proofType
string
Type of proof that was generated
circuitType
string
Zero-Knowledge circuit type used
proof
object
The generated Zero-Knowledge proof
assertions
object
Results of each assertion
{
  "average_accuracy > 0.95": true,
  "min_accuracy > 0.90": true,
  "training_data_private": true
}
status
string
Proof generation status: success, failed, partial
generationTime
number
Time taken to generate the proof in milliseconds
proofSize
number
Size of the proof in bytes
metadata
object
Metadata provided in the request
createdAt
string
ISO 8601 timestamp of proof generation
expiresAt
string
ISO 8601 timestamp when proof expires (if applicable)
{
  "proofId": "proof_7d8f9e8a7b6c5d4e",
  "proofType": "performance",
  "circuitType": "zk-SNARK",
  "proof": {
    "data": "0x8f9d3a4e5b6c7d8e9f0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v...",
    "publicInputs": {
      "timestamp": 1706380800,
      "modelVersion": "v2.1",
      "datasetHash": "0x7d8f9e8a7b6c5d4e"
    },
    "verificationKey": "0x2a3b4c5d6e7f8g9h0i1j2k3l4m5n6o7p8q9r0s1t2u3v4w5x6y7z8a9b0c1d2e",
    "circuitHash": "0x9e8d7c6b5a4f3e2d1c0b9a8f7e6d5c4b"
  },
  "assertions": {
    "average_accuracy > 0.95": true,
    "min_accuracy > 0.90": true,
    "training_data_private": true
  },
  "status": "success",
  "generationTime": 156,
  "proofSize": 192,
  "metadata": {
    "agentId": "agent_ml_001",
    "description": "ML model performance proof"
  },
  "createdAt": "2024-01-27T12:30:00Z",
  "expiresAt": "2024-02-27T12:30:00Z"
}

Proof Types

Performance Proof

Prove AI model performance without revealing training data:
const performanceProof = await treeship.proofs.generate({
  proofType: 'performance',
  publicInputs: {
    modelId: 'model_123',
    benchmarkDataset: 'imagenet_test'
  },
  privateInputs: {
    accuracyScores: [0.97, 0.96, 0.98],
    trainingData: encryptedData,
    modelWeights: privateWeights
  },
  assertions: [
    'top1_accuracy > 0.95',
    'inference_time < 50ms',
    'no_data_leakage'
  ]
});

Transaction Proof

Prove transaction validity without revealing amounts:
const transactionProof = await treeship.proofs.generate({
  proofType: 'transaction',
  publicInputs: {
    transactionId: 'tx_789',
    timestamp: Date.now()
  },
  privateInputs: {
    amount: 50000,
    balance: 75000,
    fees: 250
  },
  assertions: [
    'amount > 0',
    'balance >= amount + fees',
    'authorized_sender'
  ]
});

Compliance Proof

Prove regulatory compliance:
const complianceProof = await treeship.proofs.generate({
  proofType: 'compliance',
  publicInputs: {
    regulation: 'GDPR',
    jurisdiction: 'EU'
  },
  privateInputs: {
    userConsents: consentDatabase,
    dataProcessingLogs: auditLogs,
    retentionPeriods: retentionData
  },
  assertions: [
    'explicit_consent_obtained',
    'data_minimization_applied',
    'retention_limits_respected'
  ]
});

Advanced Features

Batch Proof Generation

Generate multiple proofs efficiently:
const batchProofs = await treeship.proofs.generateBatch([
  {
    proofType: 'performance',
    publicInputs: {...},
    privateInputs: {...},
    assertions: [...]
  },
  {
    proofType: 'compliance',
    publicInputs: {...},
    privateInputs: {...},
    assertions: [...]
  }
]);

Proof Composition

Combine multiple proofs into one:
const composedProof = await treeship.proofs.compose({
  proofs: [performanceProof.proofId, complianceProof.proofId],
  composition: 'AND', // All proofs must be valid
  metadata: {
    description: 'Combined performance and compliance proof'
  }
});

Custom Circuits

Use custom Zero-Knowledge circuits:
const customProof = await treeship.proofs.generate({
  proofType: 'custom',
  circuitDefinition: {
    language: 'circom',
    source: circuitSource,
    constraints: 1000000
  },
  publicInputs: {...},
  privateInputs: {...}
});

Use Cases

Best Practices

Never include sensitive data in publicInputs. Use privateInputs for confidential information.
  1. Input Validation: Always validate inputs before proof generation
  2. Assertion Design: Make assertions specific and verifiable
  3. Key Management: Securely store verification keys
  4. Proof Caching: Cache proofs for repeated verification
  5. Circuit Optimization: Optimize circuits for your use case

Next Steps