Hardcore Science Popularization: Analyzing the Working Principle of zkSync Circuit Using a Zoo as an Example

Haotian
2024-03-04 10:29:29
Collection
A complex circuit is constructed by various logic gates and rules.

Author: Haotian

Many people were confused after seeing the newly released zoo science popularization graphic by @zkSync, comparing the zoo to a circuit, viewing animals with special skills as "logic gates," and interpreting the happy group photos of animals as "proof." This way, the input data of the circuit generates a proof through a series of complex calculations without revealing specific content, completing a zero-knowledge proof process. Let me try to explain it in a hardcore scientific way:

1) The zoo corresponds to the "circuit." A circuit is actually an aggregation of a series of logic gate constraints (such as addition, subtraction, multiplication, division, etc.), representing a concentrated display of all the animals' abilities. It is also a fundamental element of computers. Therefore, the "data" input into the circuit must be executable within various formulas.

In a layer2 environment, there are data such as transaction hash values, accounts, and data balances. This data can be transformed into formulas for computation. If it cannot be formulated, other encoding transformations are needed to allow the original data to become a formula, which is a prerequisite for circuit execution.

2) Various animals correspond to logic gates in the circuit. In the zoo model, there are: wooden boxes ------ representing hidden numbers, referred to as "variables"; glass boxes ------ representing visible numbers, as "public inputs"; stones ------ representing immovable numbers, viewed as "constants";

Zebras have the ability to compare whether two numbers are "equal"; if they are equal, the zebra is happy. Crocodiles represent "less than"; the crocodile is happy only if the number on the right is less than the number on the left. Spiders represent more complex multi-choice gates; inputting 0 always returns true, while inputting 1 returns false. Additionally, beavers can represent division, squirrels can denote percentages, and caterpillars represent addition, etc. Different animals represent different arithmetic operations, and the happiness or sadness of the animals represents the structure of the formula operations.

Many animals + different types of boxes combine to form a circuit. For example, to calculate a formula 2x + 3 = Y, x represents a wooden box, Y represents a stone, and 2 wooden boxes along with caterpillars, zebras, and others come to work, ultimately verifying whether the formula holds. Note that there is no need to be puzzled about why different animals have different abilities; this is the basic principle of how circuit elements work, which is the fundamental rule for computers to perform calculations.

A complex circuit is constructed by a variety of animals (logic gates) and boxes (rules).

3) Assuming the previously input formula 2x + 3 = Y holds, it means that the zebra, caterpillar, and other animals are happy, and then a "proof" will be generated for this formula. There needs to be a role that can recognize whether this proof is accurate. Therefore, to ensure the credibility of the proof, the zoo administrator, who is the builder of the circuit, simulates a special animal called Zeek. Zeek can see whether other animals are happy, which corresponds to the Verifier in the layer2 system.

The process of Zeek observing whether the animals are happy is actually the verification process of the Prover system. If all are happy, the verification passes, and the proof can truly be uploaded to the mainnet and ultimately confirmed. Of course, with thousands of animals in the zoo generating a large number of proofs, Zeek cannot check each one individually. Therefore, Zeek can also observe whether the states of countless clones of itself are happy, and this process is called Recursive Proof.

4) The process of taking photos is equivalent to generating SNARK proofs or KZG commitments, while the printed negatives correspond to the STARK\SNARK proofs themselves. The visitors of the zoo are like individual Transactions entering; only when the animals are happy and take a photo will the proof be completed and generated. Ultimately, the visitors must take the photos out of the zoo as proof to be finally confirmed on-chain.

A zoo has many animals, and it is impossible for all to be happy and work according to predetermined rules at the same time. With many logic gates, there are inevitably situations like disconnections. This can lead to congestion, lag, and error situations, resulting in invalid state transitions, Under-Constrained, which cannot pass the final verification.

ChainCatcher reminds readers to view blockchain rationally, enhance risk awareness, and be cautious of various virtual token issuances and speculations. All content on this site is solely market information or related party opinions, and does not constitute any form of investment advice. If you find sensitive information in the content, please click "Report", and we will handle it promptly.
banner
ChainCatcher Building the Web3 world with innovators