TapSTARK: ZK-STARKs on Bitcoin Without Protocol Upgrade
Bitlayer Research Team
December, 2024
Abstract: TapSTARK is a protocol that implements native STARK verification on Bitcoin without requiring additional upgrades. We replace the Merkle tree in the FRI PCS (Polynomial Commitment Scheme) with Bitcoin's native Taptree. However, there are differences between Taptree and the Merkle tree. We use cryptographic tools—bit commitments—to implement data commitments, addressing the differences. Additionally, the consistency of the involved algebraic equations, value consistency, and the transformation of Fiat-Shamir are verified to ensure verification integrity. The scheme allows for Merkle path verification without incurring gas fees and eliminates the need to construct a Merkle tree on-chain, thus avoiding reliance on non-standard instructions (such as OP_CAT for string concatenation).
We first introduce some background knowledge required for this blog, including ZKP (Zero-Knowledge Proof), Polynomial Commitment, and Merkle Tree.
ZKP allows a prover to convince a verifier of a statement's validity without revealing additional information. A succinct ZKP ensures sublinear communication relative to the statement size, while a transparent ZKP avoids trusted setups, making it blockchain-compatible. TapSTARK does not require the zero-knowledge property.
In (Tap-)STARK, ZKPs use Algebraic Intermediate Representations (AIRs) to encode computations into polynomial constraints with degree bounds. For example, to prove a -degree polynomial evaluates to over a size- subgroup , one shows
where vanishes on .
Directly proving this involves sending the coefficients of and , resulting in proof size and verifier complexity linear to . Using the Schwartz-Zippel Lemma, the verifier instead selects a random , checks , and concludes correctness with high probability. This reduces proof size and complexity to sublinear in , as only evaluations are exchanged. Furthermore, evaluations take time since simplifies to for . Without safeguards, however, a prover could send falsified and satisfying .
(Tap-)STARK employs a cryptographic primitive called a polynomial commitment scheme (PCS) to ensure the validity of and .
A PCS enables a prover to commit to a polynomial over a field with degree bound and convince a verifier (via an protocol) that for public , even when the verifier selects after the commitment is made.
The PCS is defined through the following algorithms:
With PCS, a prover can validate an AIR by committing to the secret polynomials and sending these commitments to the verifier. The verifier then selects a random , and the prover and verifier use the protocol to verify polynomial evaluations at . Finally, the verifier checks the polynomial constraints and decides to accept or reject.
A Merkle tree is a vector commitment scheme with linear prover complexity and logarithmic verifier complexity and proof size, all proportional to the vector size. It consists of the following algorithms:
TapSTARK replaces BitVM's Chunk with leaves in Bitcoin's Taptree, significantly simplifying the representation of commitments. This design leverages Bitcoin's native Taptree structure, associating each leaf with a specific Bitcoin script to enable independent verification of each commitment. This approach avoids the complexity of processing large data chunks inherent in traditional schemes. Each leaf functions as an autonomous commitment unit, supporting native validation operations while making the challenge process more flexible and efficient.
Using the Taptree transaction mechanism, challengers can submit transactions that reference specific leaves to verify the correctness of claims. This mechanism not only enhances the collaboration between off-chain computation and on-chain verification but also ensures that only necessary data is involved during disputes. This localized verification greatly reduces on-chain storage and computational overhead, avoiding the inefficiencies of handling large amounts of redundant information.
Furthermore, TapSTARK integrates tightly with Bitcoin's consensus mechanism, relying on Bitcoin miners to validate the correctness of Taptree paths, enhancing the reliability of the verification process. Compared to other solutions that require third-party trust or depend on complex scripts, TapSTARK provides a transparent, efficient, and scalable verification solution. This optimization not only makes on-chain verification more lightweight but also introduces stronger scalability and broader application scenarios to the Bitcoin ecosystem without compromising security.
At a high level, TapSTARK builds upon STARK by inheriting its AIR phase, which transforms the original constraints into low-degree polynomial constraints. The primary difference lies in the use of a novel Bitcoin Taptree FRI (TapFRI) as its PCS. Thus, TapSTARK can be expressed as:
TapFRI replaces the standard Merkle tree in FRI PCS with Bitcoin’s native Merkle tree, Taptree. This substitution enables gas-free verification of Merkle paths, as Bitcoin’s consensus mechanism handles the verification. Additionally, Taptrees eliminate the need to construct Merkle trees on-chain, thereby avoiding reliance on non-standard instructions like OP-CAT for string concatenation.
However, integrating FRI PCS with Taptree is not straightforward due to several challenges:
Before introducing the specific techniques in TapFRI and TapSTARK, we first outline the operation of the FRI PCS.
TapSTARK utilizes a PCS based on the fast Reed-Solomon interactive oracle proof of proximity (FRI). Given a degree bound and a committed vector, FRI enables a prover to convince a verifier that the committed vector is -close to in terms of relative Hamming distance.
The prover's complexity is , while the verifier's complexity and proof size are . With a suitably small , FRI effectively performs a low-degree test, ensuring the prover knows a unique polynomial corresponding to the committed vector with . FRI PCS is constructed by combining FRI with a remainder argument: if for a degree- polynomial , then
is a degree- polynomial. In FRI PCS, vector commitments are implemented using Merkle trees.
For polynomials with degree bounds , batch-FRI can verify that all are valid low-degree polynomials. Specifically, the prover and verifier use FRI to test whether for
where , and is chosen randomly by the verifier. The FRI PCS is directly derived from batch-FRI, as described in Algorithm 1.
Algorithm 1: The FRI PCS. A polynomial with a degree bound and , where is a finite field and is a multiplicative coset of size . WLOG, assume is a power-of-two integer.
- : sets , computes , and generates .
- : The prover holds a polynomial and the verifier know . To convince that , and :
- sends a random to .
- sets .
- For to , where :
(a). : decomposes as .
(b). : .
©. : computes . If , compute for , run and send to ; Else, send to .
- For to :
(a). : .
(b). For to :(i). : invokes to open .
(ii). : checks the correctness of related Merkle trees by . Check whether the three pairs
are on a common degree- polynomial.
- : outputs if all checks pass; otherwise outputs .
Fiat-Shamir Transformation: The protocol in FRI PCS is a public coin interactive argument of knowledge. In the online phase, sends only random elements as challenges. Using the standard Fiat-Shamir transformation, this interactive protocol can be made non-interactive. Specifically, 's random challenges are derived by hashing all prior messages.
Sub-Proofs in FRI PCS: The FRI PCS involves three main types of sub-proofs:
We introduce several building blocks used in TapSTARK.
Bitcoin employs a scripting system to govern transactions. A Bitcoin script is essentially a list of instructions attached to each transaction, specifying the conditions under which the recipient can spend the transferred Bitcoins. Although not Turing complete, the Bitcoin script supports a range of operations through Opcodes. These include checking string equality or inequality, performing basic arithmetic operations (e.g., addition), and computing hash values for given inputs. Each integer or string processed by the script is limited to a maximum of 32 bytes. The scripting language also supports conditional logic, such as if-else
constructs.
A commitment scheme is a cryptographic primitive that enables one to commit to a value while keeping it hidden, with the ability to reveal it later. Such schemes have two key security properties: hiding and binding. Hiding ensures the commitment does not disclose any information about the committed value, while binding guarantees that the committed value cannot be opened as two distinct values.
The bit commitment used in BitVM is a weaker form of commitment designed for bits within the Bitcoin script. Specifically, the bit commitment for a bit is represented as , where and are secret strings. To open , the prover provides and . The script performs: Unlocking as if and ; Unlocking as if and ; Otherwise, it does not unlock.
The bit commitment is hiding due to the non-invertibility of hash functions. However, it lacks cryptographic binding, as can technically be opened as both and . Instead, it relies on a weaker binding property enforced by a fraud-proof mechanism: if the prover opens as both and , a challenger can detect this and claim a BTC reward. To uphold this weak binding, the secret strings (hash pre-images) for any two commitments—or within the same commitment—must be distinct.
Taptree (defined in BIP-341) is a Merkle-style hash tree introduced by Greg Maxwell, Peter Wuille, and Andrew Poelstra. It enhances the privacy, efficiency, and flexibility of Bitcoin's scripting capabilities, enabling complex script designs with minimal on-chain data.
In a Taptree, each leaf node represents a Bitcoin script, while the root (referred to as Taproot) acts as the identifier for the unspent transaction output (UTXO). To unlock the UTXO, a user must provide: 1) a valid input satisfying one of the leaf scripts, and 2) a valid Merkle path corresponding to the script.
This structure reduces on-chain storage requirements by omitting temporarily unused scripts, enhancing scalability and privacy.
In BF-STARK, only the Taproot, partial scripts, and corresponding Merkle tree paths would be finally on-chain.
Hence, it is challenging for any participant to verify that the whole Taptree is correctly constructed.
To address this challenge, BF-STARK introduces the Federation.
After the prover generates a proof and the corresponding Taproot, the Federation ensures the construction correctness of the whole Taptree, including the validity of all Bitcoin scripts and the validity of the Merkle tree.
Now, we introduce the TapSTARK principle to address the aforementioned sub-proofs.
TapFRI utilizes bit commitments to represent and commit field elements. To commit to a field element with , the prover decomposes into bits (assuming little-endian order without loss of generality). The commitment to is constructed as a Bitcoin script comprising , where each bit commitment is defined as:
Here, for any , , and , the following conditions hold:
To open from , the prover supplies the inputs . The verifier runs the Bitcoin script with these inputs, which:
These operations for generating from are embedded directly in the Bitcoin script for the commitment to . While Bitcoin scripts do not natively support multiplication operations, they simulate multiplication through repeated addition.
The bit commitment suffices to commit to and open a single field element. However, for verifying an entry within a Taptree, it is necessary to validate both the Bitcoin script and the associated Taptree paths. Unlike the programmable verifier in STARK, the Taptree path validity in TapSTARK is fixed and executed by Bitcoin miners. These miners, as determined by Bitcoin’s consensus, only validate the given Taptree paths and do not ensure that the paths correspond to the entries specified by the Fiat-Shamir transformation. This limitation allows a malicious prover to cheat by selectively opening preferred entries in the Taptree without detection.
To address this issue, an additional commitment to each entry’s index is incorporated into every Tapleaf of the Taptree. For instance, if the target field element resides in the -th entry of the Taptree, the Bitcoin script for this Tapleaf includes a commitment to .
The index is bit-decomposed as . Similar to , the commitment is composed of . To unlock the script, the prover provides the inputs:
The script unlocks if and only if all the following conditions are satisfied:
After opening entries on Taptree leaves, the consistency of algebraic equations involving these entries must be verified. For instance, in the first round of Algorithm 1, to ensure that
lie on a common degree-1 polynomial, the verifier equivalently checks the algebraic equation:
where and are derived from the Taptree commitment to , and is obtained from the Taptree commitment to .
The Bitcoin script performing this check takes as inputs, stores bit commitments for these values, and implements the consistency verification based on Equation (1). The script unlocks only if all bit commitments are valid and the equation holds true.
An important requirement in the above checks is ensuring the consistency of values reused across multiple steps. For instance:
This consistency is inherently guaranteed by the properties of bit commitments. The unique secret strings within bit commitments ensure that commitments for the same or different values are distinct. Additionally, the validity of Bitcoin scripts—including whether they reference the same bit commitments—is verified by the Federation.
In TapSTARK, challenges for interactive () and query () phases are generated using the Fiat-Shamir transformation.
Bitcoin scripts for this validation take as inputs:
These scripts verify that the hash of the Taproot matches the provided hash input, ensuring the correctness of the Fiat-Shamir transformation.
https://github.com/bitlayer-org/tap-stark
ZKPs | Transparency | BTC Script Size | Need OP-CAT |
---|---|---|---|
Groth16 | No | 1 GB | No |
FFlonk | No | 0.95 GB | No |
Circle Stark | Yes | 4 MB | Yes |
TapSTARK (this work) | Yes | 15.7 MB | No |
Recently, several other ZKPs have been implemented on Bitcoin. We compare them with our TapSTARK here to highlight the contributions of our scheme. Table 1 summarizes these implementations across key dimensions (Transparency, Bitcoin Script Size, and OP-CAT), emphasizing the advantages of our approach. These dimensions primarily reflect the current execution environment of the Bitcoin network.
The first dimension is transparency, meaning no trusted setup is required. Transparency is crucial for building a decentralized system and aligns with Bitcoin’s vision. The second dimension is script size, which is constrained by Bitcoin’s consensus. Currently, a Bitcoin transaction is limited to 400 KB, though it can be increased to 4 MB through cooperation with a Bitcoin miner. A larger script size in a ZKP verifier results in more Taproot leaves and more bit commitments, thereby increasing the cost. The final dimension is whether the ZKP verifier relies on OP-CAT, a Bitcoin proposal whose approval status remains uncertain.
Groth16 and FFlonk, implemented in the BitVM project and improved by the community, suffer from large script sizes and lack transparency. These issues are avoided in TapSTARK. While Circle Stark is more efficient than other implementations, it relies on a non-activated proposal.
We introduces TapSTARK, a Bitcoin-adapted ZKP protocol based on the STARK framework. It integrates advanced cryptography with Bitcoin’s ecosystem to enable efficient on-chain proof verification while maintaining compatibility with Bitcoin’s scripting constraints. Key technologies include: Field elements are committed using compact bit commitments implemented as Bitcoin scripts. Replacing traditional Merkle trees with Bitcoin’s native Taptree, TapSTARK optimizes storage and leverages Bitcoin’s consensus for verifying paths. Algebraic equations and reused values are verified using bit commitment properties and a Federation mechanism to prevent inconsistencies. Challenges for proof phases are generated and validated through Fiat-Shamir transformations within Bitcoin scripts. Therefore, TapSTARK avoids trusted setups and non-standard Bitcoin proposals like OP-CAT, offering a transparent and scalable ZKP solution tailored for Bitcoin's limitations.