owned this note
owned this note
Published
Linked with GitHub
# Full verification of the Mina blockchain on EVM
## Introduction
The [Ethereum Foundation](https://ethereum.foundation/) (EF) and [Mina Foundation](https://minaprotocol.com/) (MF) would like to announce a Request for Proposals (RfP) for the design and implementation of a mechanism to verify the Pickles SNARK on Ethereum.
Direct verification of this SNARK on the EVM appears to be too costly. Thus, we are accepting proposals for systems that may perform some preprocessing on the Pickles SNARK (e.g., by computing a STARK that verifies the Pickles SNARK which itself may be efficiently verified on the EVM).
The goal of this is (1) to enable full-verification of the Mina blockchain on Ethereum to enable inter-op between the two chains, and (2) to enable applications more generally to use recursive SNARKs on Ethereum.
## Table of Contents
[toc]
## Definitions
Let
\begin{align*}
p &= 2^{254} + 45560315531419706090280762371685220353 \\
q &= 2^{254} + 45560315531506369815346746415080538113 \\
\mathbb{G}_1 &= \left\{ (x, y) \in \mathbb{F}_p \mid y^2 = x^3 + 5 \right\} \\
\mathbb{G}_2 &= \left\{ (x, y) \in \mathbb{F}_q \mid y^2 = x^3 + 5 \right\} \\
n_1 = 17 \\
n_2 = 16
\end{align*}
Note that $|\mathbb{G}_1| = q$ and $|\mathbb{G}_2| = p$.
The Pickles SNARK verifier as used in Mina has several components
1. Computing several hash values from the data of the proof. This involves using the Poseidon hash function with 63 full rounds both over $\mathbb{F}_p$ and $\mathbb{F}_q$ with round constants and MDS matrix specified [here for $\mathbb{F}_p$](https://github.com/o1-labs/marlin/blob/master/oracle/src/pasta/fp.rs) and [here for $\mathbb{F}_q$](https://github.com/o1-labs/marlin/blob/master/oracle/src/pasta/fq.rs). This step is fairly cheap and could likely be implemented with reasonable gas cost on EVM.
2. Checking several arithmetic equations. Again, this step is fairly cheap and could be implemented directly on EVM.
3. Performing one multi-scalar multiplication (MSM) of size $2 n_2 + 4 + (2 + 25) = 63$, for which some of the bases are fixed and some are variable. The step could likely be implemented directly on EVM with reasonable efficiency, although it is likely to be more expensive than steps 1 and 2.
4. For each $i$, performing a multi-scalar multiplication over $\mathbb{G}_i$ of size $2^{n_i}$ with a fixed array of bases, and with scalars that can be very efficiently computed from the proof.
Step 4 is very unlikely to be efficiently computed directly on EVM, unless the computation is split over several blocks. As an alternative, we suggest grant recipients produce an additional proof (e.g., a AIR-based STARK or a BN128-based SNARK) which verifies the computation of that step.
## Reference implementation
A Rust implementation of the Pickles verifier can be found [here](https://github.com/o1-labs/marlin/blob/master/dlog/plonk/src/verifier.rs#L207). It makes a procedure call to verify the underlying polynomial commitment opening, which code is located [here](https://github.com/o1-labs/marlin/blob/master/dlog/commitment/src/commitment.rs#L612).
## Extended discussion
As mentioned above, the most expensive part of the verifier, and the part which would likely have to be verified in an auxiliary proof-system outside of EVM, is two MSMs. In this section, we describe these MSMs in more detail. Let $\mathbb{G}_k$ be one of the two curves defined above and let $\mathbb{F}$ be its scalar field. Let $\phi \colon \{ 0, 1 \}^{128} \to \mathbb{F}$ be the algorithm defined by `to_field` [here](https://github.com/o1-labs/marlin/blob/49f81edc9c86e5907d26ea791fa083640ad0ef3e/oracle/src/sponge.rs#L33).
Given an integer $i < 2^{n_k}$, define $\mathsf{bits}(i)$ to be the little-endian bit array of length $n$ representing the binary expansion of $i$.
From a given Pickles SNARK, one will derive a sequence of challenges $c_0, \dots, c_{n_k - 1} \in \{ 0, 1 \}^{128}$. The associated MSM is
$$
\sum_{i = 0}^{2^{n_k} - 1} s_i G_i = H
$$
where
$$
s_i := \prod_{\substack{0 \leq j < n_k \\ \mathsf{bits}(i)[j] = 1}} \phi(c_j)
$$
and where $G_0, \dots, G_{2^{n_k} - 1} \in \mathbb{G}$ is a fixed sequence of group elements as generated by [this algorithm](https://github.com/o1-labs/marlin/blob/master/dlog/commitment/src/srs.rs#L70).
### Observations
The sequence of scalars $\left\{ s_i \right\}_{0 \leq i < 2^{n - 1}}$ can be reordered in such a way that each term can be obtained by the previous by at most one multiplication and one division. If one also reorders the fixed sequence of bases $\left\{ {G}_i \right\}_{0 \leq i < 2^{n - 1}}$ accordingly, this makes the MSM $\sum_i s_i {G}_i$ well suited to verifying with an AIR-based STARK, since the computation can be expressed as a loop in which each iteration is very efficiently expressed as an arithmetic computation (modulo lookups in a fixed lookup table).
## Version of code
The github commit of the code which will serve as the spec will be determined at the beginning of the project. The code is developed in the open at https://github.com/o1-labs/marlin and https://github.com/minaprotocol/mina/.
## Process summary
The entire process can be summarised as follows:
1. **Request:** Release of RfP (this post)
2. **Gather:** Vendors submit proposals
3. **Deliberate:** EF and MF decide which proposal to accept, and comes up with a plan based on the resources and needs of the accepted proposal.
4. **Propose:** EF and MF propose the plan to vendor, and makes adjustments based on vendor's feedback
5. **Begin:** Vendor accepts and work begins
## Engagement timeline
The proposed timeline of the engagement is approximately 6 months.
Members of the EF and the MF will be available at all times to answer questions and comments during planning and implementation in order to make life as easy as possible for the vendor.
## Deliverables
Deliverable will take the form of
- A program `aux-proof-gen` that takes as input a Mina blockchain-state and associated Pickles SNARK and produces an auxiliary proof. It must be possible to run this program in less than 15 minutes on a cloud instance with at most 16 cores and 32 GB of memory.
- An Ethereum smart contract `aux-proof-verify` that has an internal state corresponding to the Mina blockchain state, and which can be set to a new state only if one provides an auxiliary proof that verifies. The contract should use at most 5M gas.
- For a given Mina blockchain state $s$, it should be possible to produce an auxiliary proof using `aux-proof-gen` that verifies on `aux-proof-verify` with state $s$ if and only if one posseses a Pickles SNARK associated to state $s$.
- A high-level description of the implemented auxiliary proof system.
- Two blog posts describing the progress of the work; one halfway through the engagement and one at the end.
- All code delivered under this RfP will be released under Apache License, Version 2.0.
## Fee Structure
### Invoices
Based on the timeline of this RfP, the chosen vendor will be expected to submit 2 invoices:
- a first invoice of 50% of the total engagement fee at the start of the engagement
- a second invoice of 50% of the total engagement fee at the end of the engagement, following the delivery of all Deliverables, including the code and the final blog post, and a 5 day review period.
### Payment method
The vendor will be given the option to be paid in Fiat money (via bank transfer), ETH, or MINA.
If the vendor chooses to be paid in ETH, the value of ETH described under the agreement will be the value in USD at NYSE closing time (4 PM EST) on the day prior to the due date (as described at https://www.coingecko.com).
If the vendor chooses to be paid in MINA, the value of MINA described under the agreement will be either:
- the value in USD at NYSE closing time (4 PM EST) on the day prior to the due date (as described at https://www.coingecko.com), if there exists a reputable exchange with a publicly accessible market for the MINA tokens;
- or the implied value in USD from Mina Tokens' latest private funding round, if there does not exist a reputable exchange with a publicly accessible market for the MINA tokens.
## Selection criteria
The selected vendor will have significant expertise in the areas necessary to meet the needs and requirements set forth in this RfP. Particularly:
- Expertise in applied cryptography and cryptographic systems, specifically STARKs and SNARKs
- Expertise in low level, optimised code
- Experience with EVM
## Bidding instructions
Upon reception of this request, interested vendors are expected to confirm receipt and intention to bid on the engagement.
In this confirmation, they should explain what they need from us in order to get started. As well as bring attention to areas in which they feel they do not have significant expertise. We will use this information to try to provide appropriate entrance material for the engagement.
Proposals must be submitted before *March 31st, 2021 at 5pm PST*. We expect to take 1 week to deliberate and respond.
Please send initial confirmations, and proposals (in PDF format) to the following address: rfp@ethereum.org
_Feel free to send us any questions you may have: rfp@ethereum.org_