The last two lessons worked with one number at a time. This lesson puts many numbers together, in lists and in grids — linear algebra, but every number is reduced mod a prime. A ZK proof starts life as a computation, and that computation gets turned into a pile of checks written with exactly this machinery. One small example carries the whole lesson: the prime , small enough that every step is easy to check by hand.
Vectors and the dot product
A list of numbers is called a vector. Vectors add and scale entry by entry, just like ordinary numbers — and one more operation, the dot product, turns two vectors into a single number.
Addition and scaling work entry by entry, with the usual reduction mod at the end. The dot product is different: it multiplies matching entries and adds the results, collapsing two lists into one number. Every other operation in this lesson — matrices, systems, constraints — is built entirely out of dot products.
Matrix times vector
A matrix is a grid of numbers, and multiplying it by a vector means taking the dot product of each row with that vector.
Each output entry is one row of dotted with — nothing more. A matrix, seen this way, is just a stack of dot products: a machine that turns one vector into another. Keep , , and the output in mind; they carry through the rest of this lesson.
Solving a system
Running the machine backwards — given the output, find the input — is where division mod earns its keep.
The two rows of give two equations in and . Eliminating leaves one equation in alone, solved by multiplying by ‘s inverse mod rather than dividing. Substituting back into the first equation recovers . The answer, , is exactly the vector Fig. 2 started from — the system undoes the matrix.
The inverse matrix
Solving from scratch every time is wasteful. A single matrix, , can undo in one multiplication — as long as a number called the determinant isn’t .
The determinant of is ; for this , that’s mod . Swap the diagonal entries, negate the other two, and scale everything by the determinant’s inverse to get . A determinant of means the rows carry the same information — one is a multiple of the other — so the matrix loses information and can’t be undone.
Constraints as dot products
Here’s the payoff. A claimed computation — a handful of numbers satisfying some equations — packs into one vector, and each equation becomes a check built entirely from dot products.
Pack the claim’s values — including a leading for constants — into a vector . Three carefully chosen rows, , , and , each pick out the right entries of by dotting with it, and the single real multiplication checks that the computation’s claimed step actually happened. Stack many such rows into matrices , , , and this becomes entry by entry — the shape of R1CS, a constraint system many ZK proofs use.
Where this shows up
Three ideas, each resting on the last: the dot product, matrices built from dot products, and constraints that are nothing but dot products wearing a disguise.
A dot product turns two lists into one number. A matrix is a stack of dot products, and it can be undone — by solving directly, or by building its inverse once — whenever its determinant isn’t . And a ZK constraint is exactly three dot products and one multiplication. But real proofs work with lists of millions of entries, and multiplying that many numbers the slow way is too expensive. The next lesson meets the trick that makes it fast.
- A dot product multiplies matching entries of two vectors and adds the results, reducing mod — two lists in, one number out.
- A matrix times a vector is one dot product per row; the matrix is a machine that turns one vector into another.
- Solving for works by eliminating variables and dividing by the inverse mod , the same elimination used with ordinary numbers.
- A matrix has an inverse exactly when its determinant isn’t ; a zero determinant means two rows carry the same information and the matrix can’t be undone.
- A computation’s claimed values pack into a vector , and each step becomes a constraint — the shape of R1CS.