From a78c405e565b673ee5ac653778946065606d9370 Mon Sep 17 00:00:00 2001 From: Dragan Pilipovic Date: Thu, 9 Nov 2023 00:56:22 +0100 Subject: [PATCH 1/2] week 13, 14, 15, and 16 updates --- development-updates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/development-updates.md b/development-updates.md index 5f171f94..4771995a 100644 --- a/development-updates.md +++ b/development-updates.md @@ -141,7 +141,7 @@ The actual project development is the main part of the program. Post your regula | [chirag-bgh](https://github.com/chirag-bgh) | [Update 5](https://hackmd.io/@Fe7vJwlNTJ69yVhRS6wYBw/ByN7Fa3T2) | [Update 6](https://hackmd.io/@Fe7vJwlNTJ69yVhRS6wYBw/SkVvm6B16) | [Update 7](https://hackmd.io/f06gFDIFQSW5fKSRRh4Y5g) | [Update 8](https://hackmd.io/VyJPZQs-T_qPXSI_Z9JKYw) | [Update 9](https://hackmd.io/@Fe7vJwlNTJ69yVhRS6wYBw/rkHsfWDeT) | | | | | | | | | | [Chirag](https://github.com/Chirag018) | [Update 5](https://hackmd.io/@4qrn7Ta7TIGVc_JyYsNbcg/rkxzuP_p2) | [Update 6](https://hackmd.io/@4qrn7Ta7TIGVc_JyYsNbcg/BkF3_gUJ6) | [Update 7](https://hackmd.io/@4qrn7Ta7TIGVc_JyYsNbcg/ByGpuxIkp) | [Update 8](https://hackmd.io/@4qrn7Ta7TIGVc_JyYsNbcg/rkG0ueIkp) | | [Update 9 + 10](https://hackmd.io/@4qrn7Ta7TIGVc_JyYsNbcg/SyxotZRyT) | | | | | | | | | [Daniel](https://github.com/danielrachi) | [Week 5](https://hackmd.io/@danielrachi/HJ_O59ZTn) | [Week 6](https://hackmd.io/@danielrachi/rkhc27c62) | [Week 7](https://hackmd.io/@danielrachi/B1Q4E9mCn) | [Week 8](https://hackmd.io/@danielrachi/SkVIUwi03) | | [Week 9+10](https://hackmd.io/@danielrachi/S1DyJpexT) | | [Week 11+12](https://hackmd.io/@danielrachi/rJ2zj0ZZ6) | | [Week 13+14](https://hackmd.io/@danielrachi/Hk6H1mezp) | | [Week 15+16](https://hackmd.io/@danielrachi/B1W0pxXXT) | | -| [Dragan](https://github.com/dragan2234) | | [Update 5-6](https://hackmd.io/sCuCAHPRTgiGjiH1Pc6pWw) | [Update 7](https://hackmd.io/hCIZ39qYTSmAJh3vriSwWQ) | [Update 8](https://hackmd.io/MnUdmAzuS72f433d51S6eQ) | [Update 9](https://hackmd.io/S_Awuvt-Sd6TIp8Z5RpmOQ) | [Update 10](https://hackmd.io/_DZz3ZsOSC-3_m26r8sFGw) | [Update 11](https://hackmd.io/@gagadrupal/B15c0F5x6) | [Update 12](https://hackmd.io/gqzdBFSAT3u-j757DF7Ycw?view) | | | | | | +| [Dragan](https://github.com/dragan2234) | | [Update 5-6](https://hackmd.io/sCuCAHPRTgiGjiH1Pc6pWw) | [Update 7](https://hackmd.io/hCIZ39qYTSmAJh3vriSwWQ) | [Update 8](https://hackmd.io/MnUdmAzuS72f433d51S6eQ) | [Update 9](https://hackmd.io/S_Awuvt-Sd6TIp8Z5RpmOQ) | [Update 10](https://hackmd.io/_DZz3ZsOSC-3_m26r8sFGw) | [Update 11](https://hackmd.io/@gagadrupal/B15c0F5x6) | [Update 12](https://hackmd.io/gqzdBFSAT3u-j757DF7Ycw?view) |[Update 13](https://hackmd.io/xcU9_FrMSkm7xspAwDHAzg) |[Update 14](https://hackmd.io/5w2C_L_NQSC9-CFCg4jmUA) |[Update 15](https://hackmd.io/M7ZNAPktRGSgg-yW1pwFrQ) |[Update 16](https://hackmd.io/l5iQp0H5TzqI5zwpcoC3ow) | | | [Eitan](https://github.com/eserilev) | | [Update 6](https://hackmd.io/@uncle-bill/r1ZGv_da2) | | [Update 8](https://hackmd.io/@uncle-bill/BJn1XkaTh) | | [Update 10](https://hackmd.io/@uncle-bill/HJkEt-JxT) | | | | | | | | | [Ella](https://github.com/0xfmoi) | [Update 5](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 6](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 7](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 8](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 9](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 10](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 11](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 12](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 13](https://hackmd.io/@xfmoi/B1ep19FKh) | [Update 14](https://hackmd.io/@xfmoi/B1ep19FKh) | | | | | [Eniko](github.com/eenagy) | | [Week 6-7](https://hackmd.io/mjmU7GoESAuvAVsz_t_M0Q) | | [Week 7-8](https://hackmd.io/qEevjVa0RS6A-kIxhFhJCQ) | | [Week 10-11](https://hackmd.io/2YUZDR2yRYC81PPl1lGDKw) | | | | | | | | From 9affbac914e7594e6d96ecf6afd4dd4d99044d5b Mon Sep 17 00:00:00 2001 From: Dragan Pilipovic Date: Thu, 9 Nov 2023 00:57:22 +0100 Subject: [PATCH 2/2] add project to repo --- projects/verkle-tries-in-circuit.md | 152 ++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 projects/verkle-tries-in-circuit.md diff --git a/projects/verkle-tries-in-circuit.md b/projects/verkle-tries-in-circuit.md new file mode 100644 index 00000000..7de0e73e --- /dev/null +++ b/projects/verkle-tries-in-circuit.md @@ -0,0 +1,152 @@ +# Verkle Tries in-circuit + +**this is a draft project-proposal, current goal of this project is to get benchmark of in-circuit pedersen hash and commitment used in verkle tries vs keccak hash used in MPT, overcomplicating things leads nowhere** + +VKT - verkle trie +MPT - merkle patricia trie + +Purpose of this document is to describe project proposal for creating a verkle trie data structure in-circuit which means execution of the state changes can be efficiently proven in zk circuit (because of the removal of main bottleneck - keccak-sha3) + +## Motivation + + +![](https://hackmd.io/_uploads/Skmxpp8h2.png) + +In order to make ethereum became more scalable, decentralized and secure new data structure for storage is proposed: Verkle Trie. More on that here: +https://verkle.info/ + + *(not sure if VKT adds more security to Ethereum, i guess MPT is more secure than VKT because of the quantum security of keccak vs ECC, but still we should be good for next 5-10 years (there are no quantum computers yet)) - at least that's my understanding for now* +EDIT: + *there are "functional commitements" which are post-quantum safe, additively homomorphic but they require some kind of trusted setup, i'm learning if this can be efficient in-circuit, here's the paper: https://eprint.iacr.org/2022/1368.pdf* + +*Comment from Lev (https://github.com/Lev-Stambler/CP22-function-commitment) on his work on this functional commitment and his answer:* +- *The problem with this paper is that it forces one to uses boolean fields rather than larger arithmetic ones. This comes at a substantial blow up to the overall circuit, not to mention there is a constant blowup (something like each boolean is represented by ~1_000 bits).* + + +2 reasons the transition is happening from MPT to VKT is because it will help ethereum reach weak statelessness and help onboard more validators(**more decentralisation**), but also because it is much cheaper and easier to prove verkle trie than merkle trie in circuit for zk rollups(**more scalability**), which means it should be easier to have type 1 zk-evm (because of the removal of keccak and having eliptic curve operations (pedersen commitment + IPA)) - that should be much eaiser to verify in zk-circuit. + +I've asked in Ethereum R&D discord "verkle-trie-migration" question if anyone is already working on VKT in-circuit and seems there is no such project, so I think it make sense working on it. Zhang Zhuo (https://github.com/lispc/) from Scroll team already offered help. + + +I've got this idea while reading the bandersnatch eliptic curve paper: https://eprint.iacr.org/2021/1152.pdf and doing the small hackathon project. + +So the curve is chosen to be friendly for zk-snarks and efficient for scalar multiplication and pedersen commitments should be efficient in-circuit. Goal of this project is to learn about all these things and benchmark against MPT primitives(keccak mainly) in-circuit implementation. For example proving time. + +## Project description + + +High overview of things that we need: +- bandersnatch eliptic curve with GLV endomophism for faster scalar multiplication(GLV probably doesn't make sense to have it in-circuit): https://eprint.iacr.org/2021/1152.pdf +- banderwagon subgroup: https://hackmd.io/@6iQDuIePQjyYBqDChYw_jg/BJ2-L6Nzc +- pedersen commitment + IPA (inner product argument) -- https://dankradfeist.de/ethereum/2021/07/27/inner-product-arguments.html +- verkle trie structure (inner, extension and suffix, leaf nodes) with 256 children and logic for adding, editing and deleting key-values (computing commitments to every parent node up to the root node and final IPA proof): https://notes.ethereum.org/@vbuterin/verkle_tree_eip + +Since Ethereum PSE team is working on ZKEVM type 1 using halo2 library, I would like to learn more about this and start writing circuits for VKT. So far I have written small projects like: +https://github.com/dragan2234/fibosquared-halo2 + +Also, for the first iteration I think we could only have VKT circuit working correctly without integration with zkevm project. Then we would benchmark against MPT circuit. Example of benchmark: +- VKT vs MPT witness calcuation for inserting, deleting and updating 1 value: proving time + +Since development of MPT circuit for zkevm project lasted 2 years, this project is not an easy task to do but still shouldn't be that complicated. Any output by the end of the cohort should be useful. + +Helpful links: + +- Axioms framework for buliding ECC in-circuit: https://github.com/axiom-crypto/halo2-lib#halo2-ecc +- https://verkle.info/ +- https://verkle.dev/ -- this website is currently in progress but it should have some + + +## Specification + +TBD. + + +## Roadmap + +- implement bandersnatch eliptic curve +- implement scalar mul +- implement banderwagon +- implement pedersen commitment +- implement ipa_multiproof +- implement VKT structure + +## Possible challenges + +- personally beginner with VKT, MPT and halo2-lib + +update on challenges: +- so bandersnatch curve is chosen with bls12-381 in mind because base field of bandersnatch == scalar field of bls12-381. Reason for that is to be snark-friendly, but ethereum uses bn254 for precompiles and most of the rollups also use bn254 in the prover for kzg commitments +- there is no rollup using bls12-381, at least from my investigation +- only proof system using bls12-381 that I realized so far is marlin +- I don't know hard is having a fork of proof system like plonk + kzg but with bls12-381 and having halo2 api working over that backend +- Does it maybe make sense having verkle tries on Grumpkin curve which is analog to bandersnatch but for bn254? Aztec uses this curve, maybe there are more differences but they also do pedersen commitments, so should be the same. But i think that's not type 1 compatibility because curve is different and pedersen hashes will be different. But still it would be a good for benchmarking pedersen commitment in-circuit vs keccak in-circuit + + +update 2 on challenges: +- there is currently no proof system and rollup using bls12-381 curve. Halo2 is the most flexible proof system, and there is a PR waiting to be finalized so bls12-381 could be "easily" merged to proof system using halo2 repos: https://github.com/privacy-scaling-explorations/halo2curves/pull/38 + +update 3: +- General idea: merging this repo: https://github.com/crate-crypto/rust-verkle to http://github.com/paradigmxyz/reth and then to https://github.com/risc0/zeth +- This seems to be easiest way of having zkEVM type 1 with Verkle Tries and measuring how would that improve performance/proving time +- Project idea: take rust code of keccak and pedersen commitment **specified in VKT** and benchmark it with risc0 technology. Shouldn't be too hard to do this and understand improvement + +update 4: +comment from https://github.com/asanso whether banderwagon would be effcient in-circuit: Yes, it would give similar benchamarks as bandersnatch r1cs contraints benchmarks from https://github.com/zhenfeizhang/bandersnatch#examples "Examples" section. + +Benchmarks: +bandersnatch: +cs for base var: 5 +cs for scalar var: 256 +cs for mul : 2869 +cs for result var : 27 +cs for equality : 20 +total constraints : 3177 + +jubjub: +cs for base var: 21 +cs for scalar var: 256 +cs for mul : 3325 +cs for result var : 21 +cs for equality : 2 + +bandersnatch with the glv: +cs for setup: 16 +cs for endomorphism var: 6 +cs for scalar decomposition var: 405 +cs for msm: 2176 +cs for result var : 16 +cs for equality : 2 +total constraints : 2621 + + +- Maybe it would make sense benchmarking banderwagon like this too + + +## Goal of the project + +- Learn about cryptography and data structure used in verkle tries and writing circuits using halo2 library. +- Benchmark VKT vs MPT in-circuit and make some conclusions about efficency of VKT in-circuit because EVM-compatible L2 solutions will need this. + +## Collaborators + +### Fellows +There are few people interested in this, and not all of them from the EPF program. I will add everyone here when we kickstart. + +### Mentors + +- Ignacio Hagopian + +## Resources + +- Axioms framework for buliding ECC in-circuit: https://github.com/axiom-crypto/halo2-lib#halo2-ecc +- https://learn.0xparc.org/halo2/ - tutorial for writing circuits using halo2 lib +- https://verkle.info/ +- https://verkle.dev/ – this website is currently in progress but it should have some useful docs over the time + + + +MORE UPDATES(will clean up the whole file later): + +- there is this repo maybe useful since it's bls12-381: https://github.com/ZK-Garage/plonk +- purpose of this project is to get benchmark of in-circuit pedersen hash, overcomplicating things leads nowhere +- How to make kakarot zkevm become type 1 with verkle tries: https://hackmd.io/CmCJxFBkT7u-bIQ9Y7tKyQ \ No newline at end of file