Skip to main content

Vac 101: Transforming an Interactive Protocol to a Noninteractive Argument

by
11 min read

In this post, we introduce a common technique used to convert interactive protocols to their noninteractive variant.

Introduction

The set of interactive protocols form a class of protocols that consist of communication between two parties: the Prover and the Verifier. The Prover tries to convince the Verifier of a given claim. For example, the Prover may want to convince the Verifier that she owns a specific Unspent Transaction Output (UTXO); that is, the Prover possesses the ability to spend the UTXO. In many instances, there is information that the Prover does not wish to reveal to the Verifier. In our example, it is critical that the Prover does not provide the Verifier with the spending key associated to her UTXO. In addition to the Prover's claim and secret data, there is additional data, public parameters, that the claimed statement is expressed in terms of. The public parameters can be thought of as the basis for all similar claims.

In an interactive protocol, the Prover and the Verifier are in active communication. Specifically, the Prover and the Verifier exchange messages so that the Verifier can validate the Prover's claim. However, this communication is not practical for many applications. It is necessary that any party can verify the Prover's claim in decentralized systems. It is impractical for the Prover to be in active communication with a large number of verifying parties. Instead, it is desirable for the Prover to generate a proof on their own that can convince any party. To achieve this, it is necessary for the Prover to generate the Verifier's messages in such a way that the Prover cannot manipulate the Verifier's messages for her benefit. The Fiat-Shamir heuristic 1 is used for this purpose. Even though much of our discussion will focus on Σ\Sigma-protocols, the Fiat-Shamir heuristic is not limited to Σ\Sigma-protocols. The Fiat-Shamir heuristic has been applied to zk-SNARKs, but the security in this setting has been the subject of discussion and research in recent years. Block et al. 2 provide the first formal analysis of Fiat-Shamir heuristic in zk-SNARKs.

Sigma Protocols

A Σ\Sigma-protocol is a family of interactive protocols that consists of three publicly transmitted messages between the Prover and the Verifier. In particular, the protocol has the following framework:

ProverVerifier
commitment\stackrel{\mathsf{commitment}}{\longrightarrow}
challenge\stackrel{\mathsf{challenge}}{\longleftarrow}
response\stackrel{\mathsf{response}}{\longrightarrow}

These three messages form the protocol's transcript: (commitment,challenge,response)(\mathsf{commitment}, \mathsf{challenge}, \mathsf{response}). The Verifier uses all three of these messages to validate the Prover's original claim. The Verifier's challenge should be selected uniform random from all possible challenges. Based on this selection, a dishonest Prover can only convince the the Verifier with a negligible probability.

The Schnorr Protocol

The Schnorr protocol 3 is usually the first Σ\Sigma-protocol that one studies. Additionally, the Schnorr protocol can be used as an efficient signature scheme. The Schnorr protocol provides a framework that enables the Prover to convince the Verifier that: for group elements gg and XX, the Prover knows the power to raise gg to obtain XX. Specifically, the Prover possesses some integer xx so that X=gxX = g^x. Cryptographic resources may use either multiplicative or additive notation for groups; we will use multiplicative notation. Briefly, the element gg being combined with itself in multiplicative notation is gg=g2g \cdot g = g^2, while in additive notation it is g+g=2gg + g = 2g. We assume that our group is of prime order pp, and is sufficiently large to satisfy the discrete logarithm assumption.

The Schnorr protocol proceeds as follows:

ProverVerifier
tRZpt \in_R \mathbb{Z}_p, T:=gtT := g^tT\stackrel{T}{\longrightarrow}
c\stackrel{c}{\longleftarrow}cRZpc \in_R \mathbb{Z}_p
z:=t+xcz := t + xcz\stackrel{z}{\longrightarrow}
output 1 provided gz=?TXcg^z \stackrel{?}{=} T X^c

Chaum-Pedersen protocol

A tuple of group elements (U,V,W)(U,V,W) is a DH-triple if and only if there exists some xZpx \in \mathbb{Z}_p so that V=gxV = g^x and W=UxW = U^x. The Chaum-Pedersen protocol provides a framework that enables a Prover to convince a Verifier that she possesses such a xx for a claimed DH-triple (U,V,W)(U,V,W). The Chaum-Pedersen protocol proceeds as follows:

ProverVerifier
tRZpt \in_R \mathbb{Z}_p, T:=gtT := g^t, S:=UtS := U^tT,S\stackrel{T,S}{\longrightarrow}
c\stackrel{c}{\longleftarrow}cRZpc \in_R \mathbb{Z}_p
z:=t+xcz := t + xcz\stackrel{z}{\longrightarrow}
output 1 provided gz=?TVcg^z \stackrel{?}{=} T V^c and Uz=?SWcU^z \stackrel{?}{=} SW^c

Hash Functions

Cryptographic hash functions serve as the backbone to the Fiat-Shamir heuristic. A hash function, Hash\mathsf{Hash}, is a special function that takes in an arbitrary binary string and outputs a binary string of a predetermined fixed length. Specifically, Hash:{0,1}{0,1}n\mathsf{Hash} : \{0,1\}^* \rightarrow \{0,1\}^n.

The security of cryptographic hash functions will rely on certain tasks being computationally infeasible. A task is computationally infeasible provided that there is no deterministic algorithm that can conclude the task in polynomial-time.

A cryptographic hash function satisfies the following properties:

  • Succinct: The hash function should be easy to compute; the hash Hash(b)\mathsf{Hash}({\bf{b}}) can be efficiently computed for any binary string b{\bf{b}}.
  • Preimage Resistance: It should be computationally infeasible to work backwards given the output of a hash function. Let y{\bf{y}} be a binary string of length nn. It should be 'impossible' to find some binary string x{\bf{x}} so that y=Hash(x){\bf{y}} = \mathsf{Hash}({\bf{x}}).
  • Collision Resistance: It should be difficult to find two strings that hash to the same value. It should be computationally infeasible to find two binary strings x1{\bf{x}_1} and x2{\bf{x}_2} so that Hash(x1)=Hash(x2).\mathsf{Hash}({\bf{x}_1}) = \mathsf{Hash}({\bf{x}_2}).

A related class of functions is one-way functions. A one-way function satisfies the first two conditions of a cryptographic hash function (succinct and preimage resistance). All cryptographic hash functions are a one-way functions. However, one-way functions do not necessarily satisfy collision-resistance. We will simply refer to cryptographic hash functions as hash functions for the rest of this blog. Commonly used hash functions include SHA-256 5, Keccak 6, and Poseidon 7.

The Fiat-Shamir heuristic

The Fiat-Shamir heuristic is the technique used to convert an interactive protocol to a noninteractive protocol. This is done by replacing each of the Verifier's messages with a hashed value. Specifically, the Prover generates the Verifier's message by evaluating the hash function Hash\mathsf{Hash} with the concatenation of all public values that appear in the protocol thus far. If m0,,mtm_0, \dots, m_t denote the public values in the protocol thus far, then the Verifier's message is computed as mt+1:=Hash(m0mt)m_{t+1} := \mathsf{Hash}(m_0|| \cdots || m_t).

Since Hash\mathsf{Hash} can be efficiently computed, and the messages m0,,mtm_0, \dots, m_t are public, then any verifying party can compute mt+1m_{t+1}. Critically, since Hash\mathsf{Hash} is preimage resistant and collision resistant, the Prover cannot manipulate her choices of the messages m0,,mtm_0,\dots, m_t to influence the message mt+1m_{t+1}. Hence, verifying parties can trust that mt+1m_{t+1} is sufficiently random with respect to the preceding messages.

There are two variants of the Fiat-Shamir heuristic: weak and strong. The weak variant uses all of the publicly traded messages in computing the Verifier's messages but does not include the public parameters. However, in the strong variant all of the publicly traded messages and public parameters are used to compute the Verifier's messages. We will provide a discussion on issues that can arise from using the weak Fiat-Shamir heuristic.

Schnorr Protocol with the strong Fiat-Shamir

When the strong Fiat-Shamir heuristic is applied to the Schnorr protocol, the message c=Hash(gXT)c = \mathsf{Hash}(g||X||T). This choice of cc provides security since it should be computationally infeasible to find collisions for the outputs of Hash\mathsf{Hash}. Thus, cc fixes the group elements gg, XX and TT.

The elements that would be omitted in the hash by applying weak Fiat-Shamir heuristic are gg and XX.

Chaum-Pedersen Protocol with the strong Fiat-Shamir

The message c=Hash(gUVWTS)c = Hash(g||U||V||W||T||S) when the Prover applies the strong Fiat-Shamir heuristic to the Chaum-Pedersen protocol. The properties of Hash\mathsf{Hash} fixes the generator gg and the Prover's statement (U,V,W)(U,V,W).

Improper use of the Fiat-Shamir heuristic

The Fiat-Shamir heuristic appears to be a fairly straight-forward technique to implement. However, a subtle but serious issue that can occur in the application of the Fiat-Shamir heuristic has been a point of discussion for the past few years. The issue concerns what messages are included in the hash. In particular, are the public parameters used to compute the hash value?

Bernhard et al. 8 provide a discussion of Fiat-Shamir heuristic resticted to Σ\Sigma-protocols. In particular, Bernhard et al. discuss the pitfalls of the weak Fiat-Shamir heuristic. Recall that the strong Fiat-Shamir heuristic requires that the public parameters are included in the calculations of the Verifier's messages while the weak version does not. The inclusion of the public parameters in the hash evaluations fix these public values for the entire protocol. This means that the Prover cannot retroactively change them.

The issues with the differences in the variants of the Fiat-Shamir heuristics has persisted since Bernhard et al.'s paper. In recent years, auditors from Trail of Bits and OpenZepellin have released blogs (9, 10, 11, 12, 13) and papers (14, 15) describing specific vunerabilities in zero-knowledge papers and repositories associated to the use of the weak Fiat-Shamir heuristic.

Trail of Bits coined the term FROZEN Heart to describe the use of weak Fiat-Shamir heuristic. Frozen comes from the phrase "FoRging Of ZEro kNowledge proofs", and Fiat-Shamir is the "heart" of transforming an interactive protocol to noninteractive procotol.

Now, we examine how weak Fiat-Shamir affects the Schnorr protocol and Chaum-Pedersen protocol.

Schnorr protocol with the weak Fiat-Shamir heuristic

For Schnorr, we will examine two variants: the first where we only include the Prover's claim XX but not the public parameter gg, and the second where we include the public parameter gg but not the Prover's claim XX.

Since we omit the generator gGg \in \mathbb{G} from the computation for the message cc in our first approach, then c=Hash(XT)c = \mathsf{Hash}(X||T).

Now, a malicious Prover can completes the transcript for the Schnorr protocol by selecting any zRZpz \in_R \mathbb{Z}_p. Since, gg is not fixed as it was not included in the computation of cc. But, the malicious Prover needs the transcript (T,c,z)(T,c,z) to satisfy gz=TXcg^z = TX^c. Hence, the malicious Prover can compute the generator g=(TXc)z1.g = (TX^c)^{z^{-1}}.

In our second approach, we omit the group element XGX \in \mathbb{G} from the computation for the challenge cc. That is, c=Hash(gT)c = \mathsf{Hash}(g||T).

As with the previous example, the malicious Prover takes a Schnorr transcript (T,c,z)(T,c,z) where zRZpz \in_R \mathbb{Z}_p. It is necessary for the malicious Prover to find a value XX so that gz=TXcg^z = TX^c. This can be acheived by computing X=(gzT1)c1X = (g^z T^{-1})^{c^{-1}}.

Chaum-Pedersen protocol with the Fiat-Shamir heuristic

The Verifier's message c=Hash(T,S)c = Hash(T,S) when weak Fiat-Shamir heuristic is applied. The Prover's triple (U,V,W)(U,V,W) and the generator gg are not fixed by cc. As such, a malicious Prover can generate values for U,V,WU,V,W, and gg that satisfy the Verifier's identity checks. In the case of a malicious Prover, TT and SS are randomly group elements instead of being computed using a value tt that the Prover selected. This means a malicious Prover must randomly select the value zz as well.

Given the values that have been fixed so far, each of the Verifier's identities consist of two unknowns. Hence, it is necessary to select one of these unknowns from each identity so that a malicious Prover can compute the last value. For instances, suppose that the malicious Prover randomly selects VV and WW. The malicious Prover can compute g=(TVc)1/zg = (T V^c)^{1/z} and V=(SWc)1/zV = (SW^c)^{1/z}. Thus, the malicious Prover has a claimed statement (U,V,W)(U,V,W) for generator gg that passes the Verifier's identities using weak Fiat-Shamir heuristic.

The omission of any of the values U,V,W,U,V,W, and gg in the computation of cc allows a malicious Prover to forge a proof.

Conclusion

The Fiat-Shamir heuristic is an essential technique to convert an interactive protocol to a variant that does not require communication. Additionally, careful application of this technique is necessary to maintain the integrity of the system.

References