Example: PoI Task Circuit for Matrix Multiplication
To illustrate the application of ZK wrappers in the context of Proof of Intelligence (PoI), consider a task where a node must prove the correctness of a matrix multiplication operation, a common computation in AI workloads. The task involves computing the product of two 2x2 matrices, A and B, to produce a resulting 2x2 matrix C:

Task Specification
Input
Two 2x2 matrices, A and B, with integer elements (e.g., A = [[1, 2], [3, 4]], B = [[5, 6], [7, 8]]).
Computation
Matrix product C = A × B (resulting in C = [[19, 22], [43, 50]]).
Output
The resulting 2x2 matrix C.
Circuit Design
The ZK Circuit Encodes
The ZK circuit encodes the matrix multiplication logic using arithmetic constraints over a finite field, assuming 32-bit integer arithmetic for simplicity.
Constraints for Multiplication
Constraints for Multiplication: Each element c{ij} in C is computed as the sum of products: c{ij} = a{i1} × b{1j} + a{i2} × b{2j}. For a 2x2 matrix, this requires 4 multiplication gates per element, though optimized to 2 per element using efficient arithmetic techniques.
Total Constraints
Total Constraints: With 4 elements in C, each requiring 2 multiplications and 1 addition, the circuit approximates 12 constraints. Additional constraints ensure input validity (e.g., bounds on integer values) and arithmetic correctness.
Proof Pod Generation
Using zk-SNARKs, Proof Pod generates a proof π for the computation C = A × B without revealing A or B. The proof size is ~288 bytes, and it can be verified in ~2ms on-chain through either EVM contracts or native Substrate pallets.
Integration with PoI
Task Assignment
The node receives matrices A and B via a Verifiable Random Function (VRF)-assigned task integrated with BABE's epoch randomness, ensuring fair distribution of computational work.
Computation and Proof
The node computes C using Substrate's off-chain workers, generates π in a secure environment, and submits both to the network.
Verification
Validators verify π through the verification pallet to confirm correctness, updating the node's PoI score based on the validated computation within Substrate's unified state management system.
This example demonstrates how ZK wrappers enable PoI tasks to secure AI computations while preserving privacy. The node can prove that it performed the matrix multiplication correctly without revealing the input matrices, ensuring both integrity and confidentiality in a decentralized setting through Substrate's robust infrastructure.

