This article details my implementation of Sum-Check done in OCaml, as well as a quick introduction to what the Protocol accomplishes and how it gets used.

It assumes a high-degree of technical understanding.

The full code can be found at the Github repo.


Sum-Check is an Interactive Protocol through which a Prover proves to a Verifier that their evaluation of some multi-variate polynomial g over the hypercube is equal to some value H.

This is one example of Verifiable Computation, where one party does some work, and the other party can trust in the result of that work in Sublinear Time (Time that grows slower than linear, essentially that it's asymptotically cheaper than running the computation themself).

The particular computation that we do in this protocol is summing over the boolean hypercube (That is, adding up g evaluated at each combination of values that the v-variables could be, where each variable is a boolean random variable) which is essentially #SAT ( Sharp SAT, from complexity theory ). Similar to how SAT asks if a given Boolean formula has a satisfying assignment, #SAT asks how many satisfying assingments a Boolean formula has.

This is interesting on its own, and gets used to build SNARKs by first using the Fiat-Shamir Heuristic to remove the interactive aspect of the protocol (The Prover sending a random challenge to the Verifier at each round, which gets replaced by the hash of the transcript).

This implementation assumes that the Oracle check is accomplished by some other means, and it hardcodes the formula / field size for convenience.

For more details, including justification for why the results follow from the conditions, see the resources section.


Given a v-variate polynomial g defined over some finite field F, the Prover wishes to prove that the value they claim (C) is equal to H (Defined below, also called #SAT from complexity theory).



Essentially, gi is the original g, with Xi free, all previous random variables assigned to the supplied random values, and all later values summed over.

What the Verifier checks

The Verifier must check the following in order to be convinced that the given value C is correct (Equal to H):

  1. That C and the first partial equation agree.


  1. That each subsequent gi is consistent with the last.


  1. That all gi are univariate polynomials of degree 1 (or 0).
  2. That evaluating g at the random point (r1,...,rv) is equal to the last given polynomial.



A propositional formula is supplied (As well as a field size). The formula is arithmetized. The sumcheck protocol then runs to completion (Or until it fails because any of the above checks failed).

For each round i1,,v , the Prover comes up with a total_sum gi1 and a partial_sum gi (For the first round, g0=C).

The Verifier checks that they agree ( gi1=gi(0)+gi(1) ), and that gi is a univariate of degree at most 1.

The Verifier chooses a random value ri.

The Prover constrains the polynomial with that value.

Unless this is the last round, another round begins with the following changes:

  1. round = round + 1
  2. ri is added to the list of random numbers (r1,...,ri)
  3. The working polynomial now has ri in place of xi

If this is the last round, the Verifier checks that gv is univariate of degree at most 1, and that an Oracle supplied evaluation of the original polynomial g is equal to the gv we arrived at:


If that passes, then the Verifier is convinced that H is equal to the C that the Prover claimed.


Justin Thaler's book

Justin Thaler's article

Share this article: