Carlos Pérez
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: recursion, IPA, cost, estimation --- # Cost estimations for IPA wrapped with KZG style systems As done by Polygon with Fri/Starks and Groth-16, would be nice to know how worth would it be to use IPA for complex and ammortization friendly situations, projects or schemes, and verify the final proof (Decider) with a KZG-based proving system such as TurboPlonk or similar. Enabling then succint constant and sub-linear verification times. This is particularly useful for projects like the ZKEVMs, rollups, Proof of Validity of a chain etc.. Where we might have no constraints or limitations for the prover but we have a restricted envoiroment where we must verify the proofs (like the EVM). ## How we got here? Well, the first impression that we had was that why not using [Pluto-Eris](https://github.com/daira/pluto-eris) curves which have a cycle (so we can recurse with them) and where `Pluto` in particular has a Pairing too? - The curves have a larger field-size than Bls12-381. (446 bits to be exact). This will imply slower operations for all algorithms such as: ECDSA, ECDH... - Proof sizes will become bigger. Same with SRSs, key pairs etc.. Prover requirements in terms of computation and memory will also increase accordingly. - More importantly, there's no formalisation yet for Triton (the curve that operates on the Pairing field $G_t$). - Also, there's still no implementation for the pairing itself. See: https://github.com/arkworks-rs/curves/pull/54 **So, at least for now [Pasta curves](https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/) seems a much better option**. Even it lacks the pairing and that is really painful, it has other attractive properties such as the ones noted in the Pasta curves blogpost[^1] - Unlike with the Tweedle curves, both Pallas and Vesta have low-degree isogenies (both of degree 3) from curves with a nonzero j-invariant. This is useful when hashing to the curve using the “simplified SWU” algorithm, and perhaps for other not-yet-known purposes. - They have the same 2-adicity, 32, unlike the Tweedle curves that had 2-adicity of 33 and 34. This simplifies implementations and may assist in square root performance (used for point decompression and internally to Halo 2) due to a new algorithm recently discovered; 32 is more convenient for this algorithm. - They are both constructed over 255-bit prime fields. This gives 126-bit security against Pollard rho attacks, and allows the compressed representation of points to be an even 32 bytes. - Both moduli have sparse bit representations in order to improve the performance of Montgomery reduction and other common operations. - They both support an endomorphism that can be used to improve performance of scalar multiplication, similar to that available for secp256k1. This is even more useful after the recent expiry of related patents. - They have the same curve equation, $y2=x3+5y^2 = x^3 + 5y2=x3+5$. For curves using this cycle construction it is also the case that an x-coordinate of zero is not valid, which allows a convenient representation of all zeroes for the point at infinity. - Both fields do not have 5-order, 7-order, etc. multiplicative subgroups, so that exponentiation by these small primes is a permutation — a crucial requirement for algebraic hash functions such as Rescue and Poseidon. Aside from these, there are other factors that influence this line of thought: - Pasta curves have been in production in Zcash **since Nu5**[^2] without any kind of issues and no reported vulnerabilities after multiple security audits. - Halo2 proving system with [it's slightly modified IPA version with a custom accomulator scheme](https://zcash.github.io/halo2/background/recursion.html) has also been tested for some time without any issues and has passed several security audits. - They both have rust implementations[^3],[^4] which are actively mantained and used widely across the ecosystem. ## The idea per se. We have a Virtual Machine(VM) which serves as a way to execute all the state changes performed on a blockchain to which we want to add support for KZG-based proof verification (pariring checks). We also have an application like a Rollup or similar which consistently aggregates proofs for Txs, Blocks or whatever. And from time to time, wants to commit this to a big chain like Ethereum, Cardano, Zcash etc.. The application uses Halo2 with IPA and the modified accumulation scheme. On that way, it is capable of aggregating proofs until the decider needs to be validated. ###### NOTE: For context, from a really high level prespective, with the Halo2 IPA version, when aggregating proofs and recursing, we only aggregate the sub-linear time checks. ###### The linear part of the proof verification which is O(N) usually called `Decider` corresponds to the latest verification performed which indeed verifies all the other ones. So what that means is that in the Plonk/Groth-16 proof, we will need to verify the IPA Decider (linear part of the accomulation scheme argument). **This implies that we need to construct a circuit for Halo2 that verifies a Multiscalar Multiplication/Multiexp** of N items where $N = next\_pow\_two(IPA\_PROOF\_CONSTRAINTS + 1)$ ###### Notice we don't discard here the possibility of using IPA/halo2 verifier with Pasta curves directly in the VM. By simply computing using the [halo2_cost_estimation tool](https://github.com/zcash/halo2/blob/912003138f6711a289548086da8229c323ca7d7a/halo2_proofs/examples/cost-model.rs#L274-L291) it's easy to see that until we don't surpass the 2^24 constraints aprox, the speed verification isn't critical. We've checked this by estimating 2^16 and 2^20 Degree circuits with maximum gate degree of 4 (which is decent enough) and 3 advice columns. **2^16 constraints** <details> ``` cargo run --release --example cost-model -- -a 0,1 -a 0 -a-0,-1,1 -f 0 -g 4 16 Finished release [optimized] target(s) in 0.05s Running `target/release/examples/cost-model -a 0,1 -a 0 -a-0,-1,1 -f 0 -g 4 16` Circuit { k: 16, max_deg: 4, advice_columns: 3, lookups: 0, permutations: [], column_queries: 7, point_sets: 3, estimator: Estimator, } Proof size: 1760 bytes Verification: at least 91.174ms ``` </details> --- **2^20 constraints** <details> ``` cargo run --release --example cost-model -- -a 0,1 -a 0 -a-0,-1,1 -f 0 -g 4 20 Compiling ff v0.13.0 Compiling group v0.13.0 Compiling pasta_curves v0.5.0 Compiling halo2_proofs v0.2.0 (/home/kr0/Desktop/HDD/dev/halo/halo2_proofs) Finished release [optimized] target(s) in 5.60s Running `target/release/examples/cost-model -a 0,1 -a 0 -a-0,-1,1 -f 0 -g 4 20` Circuit { k: 20, max_deg: 4, advice_columns: 3, lookups: 0, permutations: [], column_queries: 7, point_sets: 3, estimator: Estimator, } Proof size: 2016 bytes Verification: at least 1176.901ms ``` </details> :::warning That, is only possible if the VM works directly in the field of these curves of course. Otherwise, bignum arithmetic or field simulation is required which may blowup the gas costs. (There's alternatives to that such as precompiles or host functions. But this is another discussion). ::: ## Wrapping up the Decider into KZG Based on the results obtained in [ZKEVM Community Edition](https://github.com/privacy-scaling-explorations/zkevm-circuits) the [pippenger implementation of multiscalar multiplication](https://hackmd.io/ncuKqRXzR-Cw-Au2fGzsMg) necessary to execute the decider takes 19k constraints per term in the MSM. This result is obtained using wrong field arithmetic to emulate non-native curves. We could expect a better ratio of constraint/MSM term when using a bigger wrapper curves such as Bls12-381. :::danger In any case, 19k $\approx 2^{14}$ so the verifier circuit for a moderate sized cicuit of $2^{16}$ constraints would go up to $2^{30}$ which is already problematic for the prover. Even if prover resources are unlimited, Bls curves can only fit circuits with up to $2^{32}$ constraints. ::: Further reasoning and exploration has to be done here but requires us to take a deeper look to https://github.com/zcash/halo2/issues/249 & Aggregation strategies. For example, there might be a smart way on which we can accumulate differently so that we take a bit more penalty during recursion but at the same time, we get benefits when we need to prove the `Decider`. ## Questions for the future - What other accomulation schemes can we apply alternatively that benefit this usecase? - Are there any provers actually digesting 2^30 constraints and being performant enough to be used in production? Some helpful threads to pull from and adquire knowledge are: - https://github.com/zcash/halo2/issues/249 - https://github.com/zcash/halo2/pull/529. (Specially https://github.com/zcash/halo2/pull/529/commits/fb7fde91a5ba671a56f8fd89ca35d6beb89dcf42) ## References [^1]: https://electriccoin.co/blog/the-pasta-curves-for-halo-2-and-beyond/ [^2]: https://z.cash/upgrade/nu5/ [^3]: https://github.com/zcash/pasta_curves [^4]: https://github.com/zcash/halo2

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully