Smart Contracts
Token Registry - Proof-carrying Rollup
The point of RollupNC is to facilitate off-chain transfers of arbitrary ERC20 or the EVM gas token. On deployment, the gas token is available. Using the token registry, anyone can request a token be added to the L2 network and the permissioned sequencer can approve a token for deposit and transfer on the L2 network.
The Rollup contract is a point of contact that is only used for entry and exit. Depositing into the L2 contract requires no zero knowledge proof, however it does make use of a temporary merkle tree in the contract to batch in groups of 2^n deposits onto L2. The rollup operator confirms deposits are batched in using a zero knowledge proof. The same proof is used to commit L2 state transfers on-chain.
Once a depositor has made an L2 withdrawal transaction that has been committed to L1 in the state root, depositors can withdraw the exact amount of tokens in the L2 withdrawal transaction on L1.
Since EdDSA keys are much more efficient to use in zero knowledge than the ECDSA keys used on L1, this code base a mechanism by which pubkeys of the two cryptosystems can be associated with each-other in a verifiable manner.
Note: we describe this code base with the Poseidon hash function - the original version uses MiMC instead. The outcome is almost identical (Poseidon is actually inferior in this case) but do not be alarmed or confused by the switching of the two as the only consequence is efficiency.
These mechanics are explained in more detail in the following sections.
Deploying Poseidon Contracts
Using circomlibjs, you can generate a Poseidon hashing contract specific to the number of inputs you need. This is limited to 6 inputs, meaning you mush do multiple rounds of Poseidon hashing to hash larger quantities of inputs together.
Deployment (seen in BattleZips' RollupNC updated repo) is as follows, using hardhat-deploy:
From here, you can easily perform Poseidon hashes in Solidity as shown below (and in the BattleZips RollupNC repo [library])
Last updated