Quickstart

Get started with Zero Proof AI in minutes. This guide will walk you through integrating agent verification into your application.

Prerequisites

  • A Zero Proof AI account
  • An API key (get one from your dashboard)
  • Basic knowledge of REST APIs

Installation

Zero Proof AI works with any HTTP client. Here are examples in popular languages:

bash
npm install axios
# or
npm install node-fetch

Three-Step Integration

Step 1: Request a Challenge

First, request a verification challenge for your AI agent. The challenge contains a unique nonce that your agent will use to generate a proof.

JavaScript
const response = await fetch('https://api.zeroproofai.com/v1/verify/challenge', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Api-Key': 'your_api_key_here'
  },
  body: JSON.stringify({
    agent_id: 'shop-bot-001',
    action: 'purchase',
    context: {
      item: 'wireless-headphones',
      price: 149
    }
  })
});

const challenge = await response.json();
// {
//   challenge_id: "ch_7x9k2a8f...",
//   nonce: "a8f3e1d9...",
//   expires_in: 300,
//   timestamp: 1234567890
// }

Step 2: Generate Proof

Your AI agent generates a zero-knowledge proof using the challenge nonce. This proves the agent's identity without exposing secrets.

JavaScript
// Generate proof using your agent's credentials
const proof = generateProof({
  nonce: challenge.nonce,
  agentId: 'shop-bot-001',
  action: 'purchase',
  secret: process.env.AGENT_SECRET
});

// For MVP: Simple implementation
// Production: Use cryptographic ZK proofs
const crypto = require('crypto');
const proofData = `${challenge.nonce}:${agentId}:${action}`;
const proof = crypto.createHash('sha256')
  .update(proofData + secret)
  .digest('hex');

Step 3: Verify & Authorize

Submit the proof to verify your agent. If successful, you'll receive a verification result with a confidence score.

JavaScript
const verifyResponse = await fetch('https://api.zeroproofai.com/v1/verify/proof', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Api-Key': 'your_api_key_here'
  },
  body: JSON.stringify({
    challenge_id: challenge.challenge_id,
    proof: proof,
    agent_signature: agentSignature // optional
  })
});

const result = await verifyResponse.json();
// {
//   verified: true,
//   agent_id: "shop-bot-001",
//   action: "purchase",
//   confidence: 0.99,
//   timestamp: "2025-01-01T12:00:00Z",
//   session_id: "ch_7x9k2a8f..."
// }

if (result.verified) {
  // Agent is verified - proceed with transaction
  await processPurchase();
}

Complete Example

Here's a complete example putting it all together:

shopping-agent.js
const ZeroProofAI = require('./zeroproof-client');

async function verifyAndPurchase(agentId, item, price) {
  const client = new ZeroProofAI(process.env.ZEROPROOF_API_KEY);
  
  try {
    // Step 1: Request challenge
    const challenge = await client.requestChallenge({
      agent_id: agentId,
      action: 'purchase',
      context: { item, price }
    });
    
    // Step 2: Generate proof
    const proof = await client.generateProof(
      challenge.nonce,
      agentId,
      'purchase'
    );
    
    // Step 3: Verify
    const result = await client.verifyProof({
      challenge_id: challenge.challenge_id,
      proof
    });
    
    if (result.verified) {
      console.log('✓ Agent verified with confidence:', result.confidence);
      return await processPurchase(item, price);
    } else {
      throw new Error('Agent verification failed');
    }
  } catch (error) {
    console.error('Verification error:', error);
    throw error;
  }
}

// Usage
verifyAndPurchase('shop-bot-001', 'wireless-headphones', 149)
  .then(order => console.log('Order placed:', order.id))
  .catch(error => console.error('Purchase failed:', error));

Check Verification Status

You can check the status of a verification at any time using the session ID:

JavaScript
const statusResponse = await fetch(
  `https://api.zeroproofai.com/v1/verify/status/${sessionId}`,
  {
    headers: {
      'X-Api-Key': 'your_api_key_here'
    }
  }
);

const status = await statusResponse.json();
// {
//   session_id: "ch_7x9k2a8f...",
//   status: "verified",
//   agent_id: "shop-bot-001",
//   action: "purchase",
//   created_at: "2025-01-01T12:00:00Z",
//   verified_at: "2025-01-01T12:00:02Z",
//   confidence: 0.99,
//   expires_at: "2025-01-01T12:05:00Z"
// }

Error Handling

Always handle potential errors in your integration:

try {
  const result = await client.verifyProof({ challenge_id, proof });
  
  if (!result.verified) {
    // Handle verification failure
    console.error('Verification failed:', result.error);
  }
} catch (error) {
  if (error.response?.status === 401) {
    console.error('Invalid API key');
  } else if (error.response?.status === 404) {
    console.error('Challenge not found or expired');
  } else {
    console.error('Verification error:', error.message);
  }
}

Next Steps

Need help? Join our community or contact support for assistance with your integration.