Zero-knowledge gives mathematical proofs to statements and conditions without revealing any of the information required to do so. 【short definition】
zkSync is a scaling and privacy engine for Ethereum. Its current functionality scope includes low gas transfers of ETH and ERC20 tokens in the Ethereum network, atomic swaps & limit orders as well as native L2 NFT support.
zkSync is built on ZK Rollup architecture. ZK Rollup is an L2 scaling solution in which all funds are held by a smart contract on the mainchain, while computation and storage are performed off-chain. For every Rollup block, a state transition zero-knowledge proof (SNARK) is generated and verified by the mainchain contract. This SNARK includes the proof of the validity of every single transaction in the Rollup block. Additionally, the public data update for every block is published over the mainchain network in the cheap calldata.
ZK rollups use validity proofs; every batch or roll-up includes a cryptographic proof called a ZK-(SNARK / STARK) that is proved by a protocol like PLONK. After proving the post-state root is correct, the rollup publishes the proof to Ethereum mainnet.
One of the currently most sought-after goals in the ZK space is to create a zk-layer 2 solution that is fully EVM-compatible/equivalent. (This is a very hard problem that has been one of the biggest hurdles that many teams are working hard to overcome. )
Most currently available solutions in production only act as payment layer with limited functionality (Polygon Hermez, Aztec, ...) or have added functionality with their custom execution engine (VM) that's non-EVM compatible (StarkEx + Cairo, Loopring, zkSync 1.x + Zinc, etc).
There are two types of operations in zkSync:
Priority operations
Transactions
The currently available iteration of zkSync is not EVM-compatible and supports payment functionality, limited smart contracts in a low-level language called Zinc, NFT minting, and a few other functions. However, there is already a fully EVM-compatible version of zkSync live on the Rinkeby testnet and is expected to launch on mainnet in the coming months.
Anyone can bridge funds to the rollup via the native bridge and use the network for payments using zkWallet. The wallet also allows users to mint and receive NFTs on the network as well as send and receive payments.
zkEVM
zkEVM is a virtual machine that executes smart contracts in a way that is compatible with zero-knowledge-proof computation. It is the key to building an EVM-compatible ZK Rollup while preserving the battle-tested code and knowledge gained after years of working with Solidity. Our zk-EVM keeps EVM semantics, but is also ZK-friendly and takes on traditional CPU architectures.
zkSync 2.0
zkSync 2.0 is the name of the network upgrade that brings zkEVM functionality and opens up the space network to Turing complete operations.
It will fully support all the tooling that is used for writing smart contracts on Ethereum, whether it's core tooling like HardHat, ethers.js, Dapptools, OpenZeppelin, Solidity, Vyper, and others. Also, core infrastructure like TheGraph will be able to index data on-chain in order to create better blockchain data fetching infrastructure for building scalable decentralized applications.
A myriad of projects is already planning to deploy their newest versions of their protocols on zkSync 2.0. This includes protocols like Aave, Curve, Balancer, 1inch, Argent wallet, and various others. It will also be supported by bridges like Connext and Hop in order to have cross-L2 liquidity without having to bridge to Ethereum.
zkPorter (opens new window) puts data availability — essential transaction data needed to reconstruct state — offchain rather than on Ethereum. Instead, data availability is secured using proof of stake (PoS) by zkSync token stakers. This enables much higher scalability (tens of thousands TPS), and as a result, ultra-low transaction fees comparable with sidechains (in the range of a few cents).
The security of zkPorter is still better than any other L1 or sidechain. In the worst case, where a malicious actor controls both the sequencer and over ⅔ of the total stake, they can sign a valid state transition but withhold the data. In this case, the state is “frozen” and users will not be able to withdraw, but the attacker’s stake is frozen as well. Thus, there is no direct way for an attacker with a large stake to financially benefit from an exploit.
Optimistic Ethereum block production is primarily managed by a single party, called the "sequencer," which helps the network by providing the following services: Providing instant transaction confirmations and state updates. Constructing and executing L2 blocks. Submitting user transactions to L1.
The sequencer will provide a fast, offchain confirmation of your transaction. This confirmation is semi-trusted: a sequencer cannot trigger an invalid state update (e.g. steal funds) but can still fail to include a transaction after it was confirmed, or reorder transactions over a short window of time. 【Even you passed zk offchain, not until it is sync with the mainnet】
A transaction is considered final when a zero knowledge proof has been generated and posted to Ethereum. Depending on activity, this can take from 15 minutes to 3 hours.
Let’s Compare zkSync & Abitrum, Optimism(OR)
1) Significantly higher security
ZK Rollup eliminates reliance on watchers, replacing the game-theoretic economic security with cryptographic security — you trust pure math rather than incentivized actors.
2) Higher capital efficiency
In ORs, native withdrawals of any asset takes a long time (the best case: 1 week). This is a security parameter and cannot be reduced without an exponential decrease in security.
For fungible tokens, this problem can be mitigated by liquidity providers that have significant idle liquidity on the other side of the bridge. To compensate for the capital opportunity costs, the users are charged a fee to bypass the waiting period.
For smaller amounts this might be acceptable, but for professional traders this will already constitute a significant cost and will reflect on their margins. For institutions that need to periodically move huge volumes of liquidity (say, billions of dollars) between L1 and L2, this solution will not be efficient since it’s very unlikely that liquidity providers will keep that much money idle.
3) UX for NFTs
Native withdrawals of NFTs cannot be accelerated — the liquidity provider solution does not apply because NFTs are unique. Thus, to withdraw an NFT, users must wait 1 week or potentially more.
In zkSync, any withdrawal is finalized between 15 minutes and 3 hours, with faster times when there is higher activity.
4) Transaction costs
ZK Rollups are cheaper for most popular crypto use cases because it requires the least amount of data to be posted on-chain (no signatures and no transaction parameters).
However, for some common use cases, the cost savings are an order of magnitude more significant! Specifically, ZK Rollups only need to post the final changes to state, and since many transactions touch the same storage slots, this cost is amortized. For example, all trading and oracle update transactions in the same block come with zero data availability costs.
Finally, zkSync 2.0 will have an extension called zkPorter that offers constant 1-3 cent transaction fees by putting data offchain. Optimistic rollups fundamentally cannot have such an extension with off-chain data availability because there is no way for the watchers to verify the validity of every single transaction without public data for it. So, it’s not possible for them to offer such a hybrid system to users who prefer ultra-low fees over security.
Let’s have a Comparasion
The bridge validators are identical with the sidechain validators and use the same staking mechanism (e.g. in case of Polygon/Matic PoS).
The most important thing to understand about this topic is that no matter how the sidechain itself is secured, when it’s used as a scaling solution, security of the assets always depends on the goodwill of the majority of the bridge validators. (If the majority is compromised, they can irreversibly steal all of the assets.)
And since most bridges operate in a delegated PoS model under a low latency consensus requirement, the majority of the stake is usually controlled by only a handful of validator servers physically located in the same data center. The risk of all of these servers being compromised is nontrivial and a lot more than a theoretical threat!
zkRollup(On-chain) vs Sidechains
Lower Cost
Cost of zkRollups is 1/50 L1
zkPorter(Off-chain) vs Sidechains
Lower Cost & More Security
zkPorter relies on Ethereum for transaction validity and on zkSync token stakers for data availability. Malicious actor controls both the sequencer and over ⅔ of the total stake, they can sign a valid state transition but withhold the data. This would freeze the state and users would not be able to withdraw, but the attacker’s stake is frozen as well.
Comments from Enzo
One of the biggest disadvantage of zk is the computing power and time(around 40s) required to create a shielded transaction. It is unsustainable in long term, especially if you compare it to the concept of creating private channels for transactions between specific parties.
zk-Rollup is hard to build DApps, first of all you need to write the smart contract in a different language & know well in zk proof. Different zk-Rollup applications can’t interact with each other within Layer 2.