# Cheap verification

> Freivalds' check catches a wrong matrix product in n² steps instead of n³. Why Pearl needs something stronger, and how its certificate checks in milliseconds.

Source: https://pearlcodex.com/technical/math/cheap-verification/ · Last updated: 2026-10-20 · Checked against Pearl's source code at v1.5.5

Here is a fact that sounds too good to be true: you can check that someone multiplied two big matrices correctly with far less work than doing the multiplication yourself.

It’s the key idea behind any proof of work that isn’t hashing. Mining has to be expensive; checking it has to be cheap, because every node checks every block. This page shows a classic trick for cheap checking, [Freivalds’ check](https://pearlcodex.com/glossary/#freivalds), and why Pearl needs something stronger.

## Try it

Someone claims a product C = A·B, and may have cheated on a cell or two. Catch them with random vectors instead of redoing the work.

_Interactive: Freivalds’ check. Try it on the page: <https://pearlcodex.com/technical/math/cheap-verification/>_

## How does Freivalds’ check work?

Instead of recomputing A·B, pick a random vector x of 0s and 1s and compare two things:

$$
A \cdot (B \cdot x) \;\overset{?}{=}\; C \cdot x
$$

Freivalds, 1977

_Each side is a matrix times a vector: about n² steps for n × n matrices, instead of n³ for a full multiplication._

_Three matrix-vector products and a comparison. No matrix is ever multiplied by another matrix._

If C really is A·B, both sides are always equal. If C is wrong, they usually differ. A worked example with a cheat:

> **Scenario · made-up numbers: Catching a wrong cell**
>
> A = \[\[2, 3], \[1, 4]] and B = \[\[1, 0], \[2, 5]], so the true product is \[\[8, 15], \[9, 20]]. A cheater claims C = \[\[8, 15], \[9, **21**]].
>
> | x      | B·x    | A·(B·x)  | C·x      | Result     |
> | ------ | ------ | -------- | -------- | ---------- |
> | (1, 0) | (1, 2) | (8, 9)   | (8, 9)   | passes     |
> | (0, 1) | (0, 5) | (15, 20) | (15, 21) | **caught** |
> | (1, 1) | (1, 7) | (23, 29) | (23, 30) | **caught** |
>
> The wrong cell is in column 1, so any x with a 1 in position 1 exposes it. (The all-zero vector, which checks nothing, is the fourth possibility.) Half of the four choices catch the cheat.

## How sure can you be?

One random check catches a wrong answer with probability at least ½. Repeat with fresh random vectors and the chances of missing multiply:

| Rounds | Chance of missing a wrong answer |
| ------ | -------------------------------- |
| 1      | at most 1 in 2                   |
| 10     | at most 1 in 1,024               |
| 20     | at most 1 in 1,048,576           |

That probability of being fooled measures the check’s [soundness](https://pearlcodex.com/glossary/#soundness). Using random numbers from a bigger range than 0 and 1 makes each round stronger still.

**Why at least one half?**

Let D = A·B − C. If C is wrong, D has a non-zero entry, say in row i and column j. The check passes only if (D·x)\_i = 0, which is D_ij·x_j plus terms that don’t involve x_j. Fix all the other coordinates of x. Of the two choices x_j = 0 or 1, at most one makes the sum zero, since D_ij ≠ 0. So at most half of all vectors pass.

And the saving grows with size. For n = 8,192, a full multiplication is n³ ≈ 5.5 × 10¹¹ multiply-accumulates; a Freivalds round is about 3n² ≈ 2.0 × 10⁸. That’s about 2,700 times cheaper.

## Why doesn’t Pearl use it?

Three reasons, each important.

1. **Nodes never see the matrices.** Freivalds needs A, B and C in hand. The matrices declared in block 130,825’s certificate are about 1 GiB and 2 GiB. A node receives 164 bytes of public data and a proof, nothing more.
2. **The final product isn’t enough.** A Pearl ticket is built from each tile’s running sums at every checkpoint, then hashed. Freivalds can check a final product but says nothing about intermediate sums or hashes (see [rank and noise](https://pearlcodex.com/technical/math/rank-and-noise/) for why the intermediate sums matter).
3. **Privacy.** A miner’s matrices may be a company’s AI model and its users’ data. A public check shouldn’t reveal them.

So Freivalds is the right _intuition_ (checking can be vastly cheaper than doing) but not the mechanism. Pearl’s mechanism is a [zero-knowledge proof](https://pearlcodex.com/technical/cryptography/zero-knowledge/).

## How cheap is Pearl’s check?

Very. The certificate’s proof is about 59,560 bytes whatever the matrix sizes, and a node verifies it in about 7–21 ms.

- **Work behind a block:** ≈ 1.13 × 10²² MACs expected, at the snapshot difficulty
- **Winning tile:** 1,048,576 MACs 128 cells × k = 8,192
- **Proof:** 59,560 bytes constant size
- **Prove:** 5.7–17 s once per block found
- **Verify:** 7–21 ms by every node
- **Light clients:** verify too every header’s certificate

That asymmetry, from about 1.13 × 10²² multiply-accumulates of network work down to milliseconds of checking, is what makes a matrix-multiplication blockchain possible.

**Make a guess:** A pool receives a miner’s winning share: the tile’s 2 rows of A and 64 columns of B, with their Merkle paths. How can the pool check it without a zero-knowledge proof?

**Answer:** By recomputing that one tile.

The share reveals the actual rows and columns, so the pool can verify the Merkle paths against the fingerprints, regenerate the noise for those rows and columns, and redo the tile’s 1,048,576 multiply-accumulates. That’s cheap. The catch is size and privacy: a share is about 552 KB at k = 8,192, and it reveals real data. That’s why the pool then turns it into a \~60 KB zero-knowledge certificate for the chain.

## Who checks what?

Pearl’s checking happens in layers, each cheaper and more public than the last:

1. **The GPU checks every ticket**

   As the multiplication runs, each tile’s ticket is compared on the chip with the pool’s easier share target. Almost all are thrown away.

2. **The pool checks a share**

   It verifies the revealed rows and columns against the fingerprints and recomputes the tile.

3. **The gateway proves**

   For a ticket that also beats the network target, it builds the zero-knowledge certificate (seconds of work, once per block).

4. **Every node verifies**

   Each node, and each light client, checks the certificate against the header in milliseconds, without ever seeing a matrix.

> **Note: An intuition, not Pearl's proof system**
>
> Freivalds’ check is here to build intuition. Pearl’s certificate is a STARK wrapped in Plonky2 proofs; it proves the whole tile computation, including the hashes, not just a matrix product. See [the certificate](https://pearlcodex.com/technical/mining/the-certificate/).

## In short

- Doing an n × n matrix multiplication takes about n³ steps. Checking a claimed answer with Freivalds’ trick takes about 3n².
- Freivalds multiplies by a random 0/1 vector: a wrong answer is caught at least half the time, and 20 independent checks miss it with probability below one in a million.
- Pearl doesn’t use Freivalds: nodes never see the matrices, and the ticket depends on running sums along the way, not just the final product.
- Instead, each block carries a \~60 KB zero-knowledge certificate. A node checks it in about 7–21 ms, however big the multiplication was.
- Checking happens in layers: the GPU tests tickets, the pool recomputes a winning tile, and every node verifies the proof.

## Read the code

- [A node's certificate check](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/node/zkpow/verify.go#L41-L188) `node/zkpow/verify.go:41-188`
- [The Rust verifier](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/zk-pow/src/api/verify.rs#L21-L94) `zk-pow/src/api/verify.rs:21-94`
- [The precompiled verifier circuit nodes ship with](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/zk-pow/bindings/go/src/common.rs#L41-L50) `zk-pow/bindings/go/src/common.rs:41-50`
- [Pools check shares against an easier target](https://github.com/pearl-research-labs/pearl/blob/v1.5.5/zk-pow/src/api/verify.rs#L96-L140) `zk-pow/src/api/verify.rs:96-140`

## Sources

### Pearl docs

- [Pearl INT whitepaper, §4.7 (verification cost)](https://pearlresearch.ai/research/int-whitepaper)

### Other

- [Freivalds' algorithm (Wikipedia)](https://en.wikipedia.org/wiki/Freivalds%27_algorithm)
