Skip to main content

Overview

Proof-of-Inference (PoI) is a cryptographic verification system that enables trustless verification of AI model outputs on the blockchain. By creating hash-based commitments for inputs, outputs, and model identifiers, Nexis ensures that inference results can be verified without requiring the full computation to be replicated on-chain.

Cryptographic Commitments

Hash-based commitments for inputs, outputs, and models

IPFS Integration

Decentralized storage for proof artifacts

On-Chain Verification

Smart contract attestation and validation

Economic Security

Stake-backed guarantees with slashing

Architecture

The Proof-of-Inference system consists of several interconnected components:

InferenceCommitment Structure

The core data structure for proof-of-inference is the InferenceCommitment struct:

Field Descriptions

Hash Commitment Scheme

Input Hash

The input hash is a cryptographic commitment to the input data:

Output Hash

The output hash commits to the inference result:

Model Hash

The model hash identifies the specific model version used:

Recording Inference

The recordInference function creates an on-chain commitment:

Implementation

Event Emission

When an inference is recorded, the contract emits an event:
This event can be indexed and listened to by verifiers, task systems, and monitoring tools.

Verification Process

The verification process involves multiple steps:

Attestation Implementation

Attestation Event

IPFS Integration

Proof Artifact Structure

The proof URI points to a comprehensive artifact on IPFS:

Uploading to IPFS

Security Considerations

Hash Collision Resistance

Always use keccak256 (SHA-3) for hash commitments. Never use deprecated hash functions like SHA-1 or MD5.
The keccak256 hash function provides:
  • Collision Resistance: Computationally infeasible to find two inputs with same hash
  • Pre-image Resistance: Cannot reverse hash to recover original input
  • Second Pre-image Resistance: Cannot find different input with same hash

Timestamp Validation

Always validate timestamps against block timestamps to prevent replay attacks.
This ensures:
  • Temporal ordering of inferences
  • Deadline enforcement
  • Replay attack prevention

Proof URI Integrity

Validate IPFS URIs and implement redundant pinning to prevent data loss.
Best practices:
  1. Pin to Multiple Services: Use Infura, Pinata, and local nodes
  2. Verify CID: Recompute content hash and compare with URI
  3. Set Expiry: Implement proof retention policies
  4. Backup Critical Data: Archive important proofs off IPFS

Advanced Patterns

Batch Verification

Verify multiple inferences in a single transaction:

Probabilistic Verification

Reduce costs by verifying a random sample:

Optimistic Verification

Assume valid unless challenged:

Performance Optimization

Gas Optimization

Minimize on-chain storage by storing only hashes, not full data.

IPFS Optimization

  1. Use CDN Gateways: Cache frequently accessed proofs
  2. Implement Lazy Loading: Load proofs only when needed
  3. Compress Artifacts: Use gzip compression for JSON data
  4. Batch Uploads: Combine multiple proofs in single IPFS object

Event Indexing

Use The Graph or similar service for efficient event querying:

Testing & Development

Local Testing

Troubleshooting

Common Issues

Problem: Computed hashes don’t match on-chain commitmentsSolutions:
  • Ensure consistent serialization (sort JSON keys)
  • Use same encoding (UTF-8 for strings)
  • Verify byte order for binary data
Problem: Cannot upload proof artifacts to IPFSSolutions:
  • Check IPFS node connectivity
  • Verify API credentials (Infura/Pinata)
  • Reduce artifact size if too large
  • Use alternative IPFS service
Problem: Attestation takes too long or times outSolutions:
  • Implement async verification queue
  • Use probabilistic sampling for large batches
  • Optimize IPFS gateway performance
  • Cache frequently accessed proofs
Problem: Transaction reverts with “UnauthorizedDelegate”Solutions:
  • Verify VERIFIER_ROLE is granted
  • Check signer address matches verifier
  • Ensure contract is not paused

Next Steps

AI Agents Guide

Learn about agent registration and management

LangGraph Integration

Build complex workflows with state machines

Complete Examples

View full implementation examples

API Reference

Explore the complete API documentation