ZKP storage proof for Merkle Patricia Tree in ZKLLVM for building arbitratry oracles with examples
The huge problem of ZKP Oracles is the need to prove values from ETH storage using non-ZK-frendly primitives, like Keccak and RLP-encoding. We try to implement these proofs using the new modular proof system (Placholder), used in ZKLLVM form Nil.Foundation, hoping that they will be enough lightweight to be used in complicated orace scenarios, providing data like: aggregated protocol liquidity, provable optimal selection of validators, TWAPs, etc...
Existing MPT proofs are implemented inside different zkEVMs, mostly on ZK-frendly primitives, making them unusable for direct usage (we receive a real proof from Ethereum node and directly use its data for proving). In addition, MPT proofs contain not only hashing, but also binary operations, making the circuits, developed for simple Merkle trees not very efficient and this makes proving of ZK oracles difficult. ZKLLVM proof system has modular structure, combining different proving modules for different purposes (arithmetics, binary, hashing, etc...) and allows us to test different parameters of proving. We hope it helps to produce enough lightweight proofs for complicated ZK Oracles and will try to check it on this hackathon.
The resul of our work: a main building block for designing many different ZKOracles, allowing aggregation of many values, complicated maths over these values, etc... Good luck to everyone an us too :)
A lot of DeFi projects can benefit from this project by getting the ability to have an aggregated information from the chain without using any trusted parties, oracles consensus, etc....
We forked https://github.com/NilFoundation/zkllvm-template from https://github.com/NilFoundation/zkLLVM to be able to work in main.cpp, changing its logic to checking real Merkle Patricia Proof, received from Ethereum node. There are no implementations of MPT proofs in С/C++ so we need to make our own, based on multple specialized implenentations. We receive a real proof from Ethereum RPC, directly putting it in our prover with minimal changes in data and will present the verification process of such a proof in smart-contract.
Hope it will work. If we'll have any time left, we'll quickly can make some ZK oracle, for example: