Protocol Concepts
Statement

Statement

A statement is a logical expression that contains one or more variables and that can be either true or false. A statement is abstract in the sense that the statement alone do not have any value, but specify a set of logic rules that can be used to determine if the statement is true or false for given values of the variables.

Statement can often be expressed in natural language, for example "Over 18 years old" is a statement that contains the variable age, and that is true if and only if age > 18.

Formalisation

Jump to Implementation if you are only looking for the code.

Let consider ss a statement as a function defined on nn real variables:

s:Rn{true,false}\large s: \mathbb{R}^n \rightarrow \{\text{true}, \text{false}\}

We can assign the values for each variables of a statement as a vector v=(v1,v2,...,vn)v = (v_1, v_2, ..., v_n), with viv_i the value of the ii-th variable. We note VV the set of all possible vectors possible, V=RnV = \mathbb{R}^n. So v,vV\forall v, v \in V.

The logic rules are represented as a set R\cal R of logical propositions. Each rule rir_i can involves any variables viv_i (atleast one), and can only be expressed using logical operators (\land, \lor, ¬\lnot) and/or comparison operators (==, >>, <<, \geq, \leq).

The function ss can be defined as the following:

s(v)={true,if all rules in R are satisfied by vfalse,otherwises(v) = \begin{cases} \text{true}, & \text{if all rules in } \mathcal{R} \text{ are satisfied by } \mathbf{v} \\ \text{false}, & \text{otherwise} \end{cases}

Example:

n=1,V={age},R={r1} with r1="age>18"n = 1, V = \{\text{age}\}, \cal R = \{r_1\} \text{ with } r_1 = "\text{age} > 18"

A statement is analogous to a predicate in logic.

Some observations:

  • If there is two rules that are mutually exclusive, then ss cannot be true for any vv.
  • If there's a variable viv_i that is not used in any rule, then ss is equivalent to the statement that does not contain viv_i but has the same set of rules.

Zero-knowledge statement

We can divide the set VV as the union of two distinct sets: VprivateV_{private} and VpublicV_{public}, such that VprivateVpublic=V_{private} \cap V_{public} = \emptyset and VprivateVpublic=VV_{private} \cup V_{public} = V.

We redefine the statement function ss as the prover that returns a new proof pPp \in P:

s:(Vprivate,Vpublic)P\large s: (V_{private}, V_{public}) \rightarrow P, with PP the set of all possible proofs of the statement ss.

We say that pp is an Attestation proof.

Example: We can rewrite the previous statement as

n=1,Vprivate={age},Vpublic=,R={r1} with r1="age>18"n = 1, V_{private} = \{\text{age}\}, V_{public} = \emptyset, \cal R = \{r_1\} \text{ with } r_1 = "\text{age} > 18"