Brevis 백서

Brevis

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 5쪽 중 4쪽

eir proofs for storage in zkAggregatorRollup. • InsertQueryResults (zkQueryNet → zkAggregatorRollup): zkQueryNet may invoke this interface to submit a batch of queries and corresponding query results along with their proofs. • FetchAttestedData (zkQueryNet → zkAggregatorRollup): Via this in- terface, zkQueryNet can look up block header contents or query results from zkAggregatorRollup, along with their Verkle tree inclusion proof, which can be efficiently verified against the rollup state root directly in the Base Chain Rollup Contract. 28 6.1.4. Rollup Fee Model In zkAggregatorRollup, a fee is paid when zkQueryNet sends the FetchAttestedData request to the rollup. The paid fee is used to cover the prover cost, Rollup → BaseChain commit gas cost, and sequencer cost. To amortize the cost, the Rollup → BaseChain zk commit only occurs once the sequencer has accumulated enough FetchAttestedData requests. Naturally, there will be a timeout to ensure that the batch waiting time is upper-bounded. In the future, there will be finer-grained fee models where each user may select the maximum delay and the maximum fee they are willing to pay. 6.1.5. Basic Workflow The overall workflow of zkAggregatorRollup is as follows: (1) The sequencer receives a InsertBlockHeaders or InsertQueryResults trans- action. (2) The sequencer verifies if the submitted block headers or query results are valid by checking the enclosed validity proof. (3) If valid, insert the block headers or query results into the Verkle tree. (4) The sequencer sends the Verkle tree updates and the block headers/query results to a rollup prover to generate proof attesting that the Verkle tree is correctly updated and the validity of the block headers/query results has been verified. (5) The rollup prover sends back the proof to the sequencer. (6) As more InsertBlockHeaders or InsertQueryResults transactions are sub- mitted, the sequencer accumulates more proofs. (7) The sequencer dispatches the accumulated proofs to a rollup prover for aggrega- tion as soon as the sequencer receives enough FetchAttestedData transactions from zkQueryNet. (8) The rollup prover aggregates the proofs and sends back the aggregate proof to the sequencer. (9) The sequencer commits the accumulated Verkle tree root updates to the Base Chain contract and submits the aggregate proof to prove the validity of these updates. In the following two subsections, we describe the detailed protocols for the rollup 29 sequencer and the rollup prover network. 6.2. Rollup Sequencer In zkAggregatorRollup, the sequencer verifies the validity proof for the block headers and query results and maintains Verkle trees for storage of attested block headers and query results. Initially, the sequencer is a centralized server and will become a decentralized sequencer network in the future. Whenever a InsertBlockHeaders or InsertQueryResults transaction is processed by the sequencer, the Verkle tree is updated and a new rollup block is generated. A rollup block i is finalized on Base Chain if the Verkle tree root at block number i has been committed to Base Chain rollup contract and the corresponding validity proof has been verified in the Base Chain rollup contract. Note that a FetchAttestedData transaction won’t update the Verkle tree state so a new rollup block is not generated (but the sequencer still needs to take some actions, to be introduced later). Below we describe in detail how the sequencer handles these transactions. 6.2.1. Insert Block Headers Let’s assume the latest rollup block number is i. The Verkle tree at block number i is represented by T bi with its root denoted by rootbi . Suppose that the sequencer receives a InsertBlockHeaders transaction from a zkFabric relayer. The following information should be submitted with the transaction: • A list of block headers to be stored: B = {Bcn}c,n each element Bcn represents the block header of chain c at block number n. • Aggregate proof π(B) that attests the correctness of the block headers. • Hash of the block headers H(B). The hash along with the aggregate proof π(B) will be later submitted to the rollup prover as part of the public inputs to the recursive verification circuit; otherwise, the recursive verification circuit will need to take the full list of block headers B, which increases the verification circuit size. Then the workflow for the sequencer to handle theInsertBlockHeaders transaction is as follows: (1) The sequencer verifies the validity proof π(B) for the submitted block headers 30 B. (2) If valid, it generates a new rollup block i + 1 and updates the Verkle tree by inserting the verified block headers, i.e., inserts key-value pair ( c, n) 7→ H(Bcn) for each block Bcn ∈ B. Note that only the hash values of the block headers are stored in the Verkle tree leaves; the full block header contents are stored in a separate KV DB and be accessed via H(Bcn) 7→ Bcn. (3) The sequencer sends the Verkle tree update T bi → Tbi+1 along with the block headers B, their hash value H(B) and the validity proof π(B) to one of the rollup provers to generate a validity proof πi+1 = π π(B), T bi → Tbi+1 attesting the fact that the validity proof π(B) was correctly verified and that the Verkle tree update T bi → Tbi+1 was correct. The proof πi+1 is then sent back from the rollup prover to the sequencer. Note that to speed up the proof generation process, the proofs for different rollup blocks can be generated in parallel on different rollup provers. The new Verkle tree rootbi+1 won’t be immediately committed to Base Chain. In- stead, the Rollup → BaseChain commit will be triggered by FetchAttestedData transaction from zkQueryNet, which will be specified in Section 6.2.3. Protocol 1 formalizes the above flow for inserting new block headers. Protocol 1 Sequencer: InsertBlockHeaders Input: A list of block headers B = {Bcn}c,n Input: Aggregate proof π(B) that attests the correctness of the block headers Input: Hash of the block headers H(B) Input: The latest rollup block number i 1: if Verify(π(B))=True then 2: Increment the rollup number to i + 1 3: for each block Bcn ∈ Bdo 4: Insert key-value pair (c, n) 7→ H(Bcn) into Verkle tree 5: Insert key-value pair H(Bcn) 7→ Bcn to KV DB 6: end for 7: Send Verkle tree update T bi → Tbi+1, block headers B, hash value H(B) and proof π(B) to a rollup prover 8: end if 6.2.2. Insert Query Results The flow for handling the InsertQueryResults transaction is described in Protocol 2, which is similar to InsertBlockHeaders. 31 Protocol 2 Sequencer: InsertQueryResults Input: A list of queries and corresponding query results QR = {(Qi, Ri)}i where element represents the i-th query Qi and corresponding result Ri. Each query Qi is associated with a unique query ID (denoted by Qi · id). Input: Hash of queries and results H(QR) Input: Aggregate proof π(QR) that attests the correctness of the query results Input: The latest rollup block number i 1: if Verify(π(QR))=True then 2: Increment the rollup number to i + 1 3: for each block (Qi, Ri) ∈ QRdo 4: Insert key-value pair Qi · id 7→ H(Qi||Ri) into Verkle tree 5: Insert key-value pair H(Qi||Ri) 7→ (Qi, Ri) to KV DB 6: end for 7: Send Verkle tree update T bi → Tbi+1, queries/results QR, hash value H(QR) and proof π(Q) to a rollup prover 8: end if 6.2.3. Fetch Attested Data As previously mentioned, when zkQueryNet sends a FetchAttestedData request to the sequencer, not only the data and its inclusion proof is returned, but also the Rollup → BaseChain state root commit and finalization may be triggered. Specifically, assume that the last finalized rollup block number on Base Chain is nf , and the latest rollup block number is nr, which means that rollup blocks nf + 1, ..., nr haven’t been committed and finalized on Base Chain. The corresponding rollup proofs are πnf +1, ..., πnr and Verkle tree roots are rootnf +1, ...,rootnr . To amortize the cost, the sequencer will commit and attest these Verkle tree roots in the Base Chain rollup contract once the number of accumulated FetchAttestedData requests exceeds M (of course, there will be a timeout to cap the max wait- ing time for each batch of requests). Suppose the current accumulated number of FetchAttestedData requests is m (batch counter). The flow for a FetchAttestedData transaction is as follows (see Protocol 3) (1) zkQueryNet submits a FetchAttestedData transaction to the sequencer with some key. For example, key could be chain ID+block number for block header retrieval or query ID for data query results. (2) The sequencer look up the value via key 7→ hash(value) 7→ value from the Verkle tree and the KV DB, and generates inclusion proof for the fetched data. The sequencer then sends the data value and the inclusion proof to zkQueryNet for verification on Base Chain. 32 (3) The sequencer increments the batch counter m → m + 1. (4) If the batch counter m ≥ M , the sequencer sends proofs πnf +1, ..., πnr to a rollup prover for aggregation. (5) After receiving the aggregate proof ˆπnf +1→nr , the sequencer commits the Verkle tree roots rootnf +1, ...,rootnr to the Base Chain rollup contract and submit the attestation proof ˆπnf +1→nr to finalize these state commits. (6) The sequencer reset the batch counter m = 0. Protocol 3 Sequencer: FetchAttestedData Input: key (key is chain ID + block number for block header retrieval or query ID for data query results) 1: Look up the value for the key from the Verkle tree and the KV DB. 2: Generate inclusion proof for the key-value pair 3: Send the key-value pair and the inclusion proof to zkQueryNet 4: Increment the batch counter m → m + 1 5: if m ≥ M then 6: Send accumulated rollup block proofs πnf +1, ..., πnr to a rollup prover for ag- gregation. 7: After receiving the aggregate proof ˆ πnf +1→nr , commit the Verkle tree roots rootnf +1, ...,rootnr to the Base Chain rollup contract and submit the attestation proof ˆπnf +1→nr to finalize these state commits. 8: Reset batch counter m = 0 9: end if 6.3. Rollup Prover Network The rollup prover network is responsible for generating proofs for rollup blocks. Provers in the network are expected to utilize accelerators such as GPUs, FPGAs, and ASICs to reduce the proving time and proving cost. The sequencer may dispatch a single-rollup-block proof job or a multi-rollup-block aggregation-proof job to a rollup prover. Multiple rollup provers may generate proofs in parallel. Figure 6 illustrates how the aggregate proof is generated by rollup provers. 6.3.1. Single Rollup Block Proof Each single rollup block proof involves two circuits: (1) A V erkle tree circuit that proves the correctness of Verkle tree update (in particular, the correctness of tree update after inserting a key-value pair). (2) A recursive verification circuit that proves that the proof π(B) of block 33 proof for rollup block i+1 proof for rollup block i+2 proof for rollup block i+k Aggregate Proof Rollup Prover 1 Recursive Verification Circuit Verkle Tree Circuit Aggregation Circuit Rollup Prover 2 Recursive Verification Circuit Verkle Tree Circuit Aggregation Circuit Rollup Prover 3 Recursive Verification Circuit Verkle Tree Circuit Aggregation Circuit Rollup Prover 4 Recursive Verification Circuit Verkle Tree Circuit Aggregation Circuit query result proof query + results + hash Verkle tree update i+k Ethereum block header proof Ethereum block header + hash Verkle tree update i+1 Cosmos block header proof Cosmos block header + hash Verkle tree update i+2 ...... ...... Figure 6. Proof generation by rollup provers. headers or the query results proof π(QR) has been correctly verified. After receiving the rollup block proof assignment from the sequencer, the rollup prover first generates two proofs using the two circuits. Then it aggregates the two proofs into one proof and sends it back to the sequencer. In terms of ZKP design, the recursive verification circuit is of particular interest, where we embrace a composable architecture and don’t restrict ourselves to one particular ZKP development framework. • The “inner” proof π(B) or π(QR) may be generated in heterogeneous sys- tems (e.g., Plonk, Groth16, STARKs) for performance reasons. For example, our benchmark results [32] show that SHA-256 proof generation is faster in Groth16 than in Plonk due to its special binary wire values, while other operations such as elliptic curve pairing and non-native field arithmetics may be faster in Plonk- ish arithmetization than R1CS due to its flexibility. Thus, different blockchain consensus mechanisms may be best proved in different proving systems, not to mention the more heterogeneous query patterns. As a result, the recursive verifi- cation circuit should be able to verify different proving systems in the circuit. In fact, such a composable architecture has already been adopted in production ZK systems such as Polygon zkEVM [19] which compose STARKs with Groth16. 34 • Moreover, Brevis zkAggregatorRollup commits to multiple Base Chains where heterogeneous cryptographic primitives are supported. For example, while Ethereum only supports BN254 pairing as a pre-compile, other blockchains sup- port efficient pairing over other elliptic curves as pre-compiles or built-ins. This opens up the space for more efficient recursion such as the 2-chain scheme [37]. • Finally, we are also researching and developing efficient “outer” layer protocols that enable efficient and interoperable instantiations (e.g., LegoSNARKs [36], sumcheck [35]). 6.3.2. Multi-Rollup-Block Aggregation Proof In addition, the rollup prover may also be assigned a job for aggregating the multi- ple rollup block proofs πi, ..., πi+k. Then a single aggregate proof is sent back to the sequencer and will be later submitted to Base Chain for on-chain verification. Our current implementation is using the batching technique [18] and will evolve to more sophisticated aggregation techniques such as aPlonk [34] and Nova [39] The assignment of proving jobs within the rollup prover network is of independent interest and won’t be discussed in this paper. We will publish separate papers on the economy design for the rollup prover network. 7. Use Cases Brevis empowers developers to create dApps that can access omnichain data across arbitrary time horizons in a way that was previously impossible. This innovation will undoubtedly establish a new paradigm, transforming how dApps are developed across all sectors. In this section, we present several immediate applications, but we anticipate the community will discover many more use cases. 7.1. ZK Multi-blockchain Interoperability As discussed in Section 4, nearly all existing interoperability solutions fall into the “ex- ternal validation model” which necessitates trust in an intermediary entity. Although on-chain light client solutions are trust-minimized in theory, they are prohibitively expensive to implement in practice. Brevis addresses this challenge by combining light client protocol and ZKP, where zkFabric generates ZK Proof of Consensus for all con- 35 nected blockchains and stores the corresponding block headers in zkAggregatorRollup. With these zk-attested block headers available, constructing a zkBridge on top of Brevis is as straightforward as implementing a ZQE with the following Query API: byte [] g e t _ m e s s a g e ( uint256 [] chain_ids , uint256 [][] m e s s a g e _ i d s ) ; This Query API enables batched delivery of multiple messages from different blockchains. An off-chain relayer can drive this Query API by monitoring source chain messages and assisting the destination chain receiver smart contract in calling the Agent Smart Contract with the appropriate message ids and chain ids. Existing multi-chain dApps, including cross-chain DeFi and asset bridges, can easily adapt to this ZK interoperability solution without altering their application-layer smart con- tracts. 7.2. Data-driven DeFi In addition to the liquidity farming reward auto-adjustment example discussed in Sec- tion 3, we believe data-driven DeFi will become a broad class of applications leveraging Brevis, thanks to the scalability and privacy it enables. With trust-free access to comprehensive historical and omnichain trading flows, derivatives such as options can now incorporate novel exercise conditions, such as Ex- ponential Time Weighted Price or Time-Volume Weighted Price. Alternative deriva- tives tracking user behavior, price trends, protocol or blockchain TVL changes, volatil- ity, price correlations, and more will also be possible through various implementations of ZQEs. On-chain active fund management solutions can generate ZK proofs demonstrat- ing that position adjustments are based solely on specific algorithmic models derived from market data, without any unauthorized human intervention. Furthermore, due to the privacy-preserving property of Brevis, the precise model parameters can remain concealed to maintain a competitive market advantage. 7.3. User Acquisition with T rust-free Revenue Sharing The lifecycle of user acquisition in Web 2.0 typically concludes at the point of user download or registration. At this stage, advertisers pay advertising channels, and their 36 relationship terminates. This arrangement is suboptimal for both parties: advertisers pay the same upfront price for all acquired users, without the ability to differentiate based on their Lifetime Value; advertising channels also cannot share long-term revenue streams, even when acquiring high-value users. This lose-lose situation arises because, in the Web 2.0 world, post-acquisition user data falls within the advertiser’s private domain, making it impossible for advertising channels to access post-acquisition user statistics in a trust-free way. Web 3.0 has the potential to fundamentally transform this user acquisition model since most user activity data are in the public domain. However, current Web 3.0 user acquisition platforms, such as Quest3, still follow the Web 2.0 paradigm because there is no way to obtain post-acquisition user revenue data directly on-chain and in a trust- free manner. Brevis revolutionizes this by enabling advertising channels to generate revenue proofs for all users they acquire. By leveraging Brevis, the user acquisition landscape in Web 3.0 will undergo a fundamental shift: advertisers will pay only for high-value users, and advertising channels will be incentivized to match users with individual advertisers optimally. 7.4. zkDID With the capability to prove any statistics about users’ historical behaviors, Brevis will be an essential tool for constructing trust-free zkDID solutions that can be employed in various use cases. 7.4.1. Prevent Sybil Attacks Since creating an account on the blockchain incurs practically zero cost, the issue of Sybil Attacks has plagued the blockchain community from day one. When incen- tivized user acquisition events or retrospective airdrops occur, it is often challenging for blockchain projects to differentiate bots from real users. Off-chain solutions fre- quently entail regulatory and trust issues by creating a centralized token distribution entity. By using Brevis, applications can send queries to different ZQEs to generate ZK proofs of individual or aggregated users’ identities based on hard-to-fake on-chain behaviors, such as account age, interaction with KYC’ed exchanges, fees paid to rel- evant protocols or dApps, long-term holding of meaningful assets, and more. Using 37 anti-Sybil solutions built with Brevis, dApp developers can prevent Sybil Attacks in airdrop campaigns or beta rollouts to exclusive early contributors while operating in a fully trust-free manner. 7.4.2. User Life Cycle Management While accessing external data for a dApp can help prevent Sybil Attacks, a dApp’s internal data can be crucial for building a trust-free user life cycle management pro- cess. For example, a loyalty system can be constructed for new users who passed the initial Sybil Attack firewall b
프로젝트로 돌아가기