New host function for bn254 G1 MSM #1826
Replies: 2 comments 2 replies
-
|
Since we are struggling to get Ultrahonk to respect the budget, that sounds like a great idea. There is also the idea to have Ultrahonk directly added as a host function if this is the target. In the end if we really want to target ZK applications it could make sense and be a security guarantee to have this available as a function vs making a cross contract call. Because even if that does reduces the cost to just move that function, running a proof is still very expensive and limits what can be done around the proof in a single invocation. Moving to a full host function could open more use cases. |
Beta Was this translation helpful? Give feedback.
-
|
Should we just go ahead and implement the rest of the bn254 functions outlined here? https://github.com/orgs/stellar/discussions/1772#discussioncomment-14481047 Waiting for a hard requirement on individual operations seems fairly inefficient. We want to appeal to projects building ZK systems so having rich set of operations that make ZK doable and cheaper on Stellar is a big plus. If the cost of implementation is reasonable and they use the same dependency anyway then I think we should go for it. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In https://github.com/orgs/stellar/discussions/1772#discussioncomment-14489791 we added three host functions for bn254 in protocol 25.
These functions provides sufficient curve support (in parity with Ethereum). However in some use cases, the contract cost is still much higher than the current Soroban's cpu limit (100M instructions). Here we propose a few more host functions that can enable greater performance improvements. The targeted use case is Noir's Ultrahonk verifier contract (and the underneath lib), for which we will base our analysis on.
G1 MSM - in Ultrahonk msm operation takes up a big portion of cpu cost in proof verification.
As a rough estimate using bls12-381 G1 calibrated budget numbers:
So more than 3x cpu saving by switching to an msm host function. The main cost saving comes from less internal conversions (converting from Montgomery form).
Fr arithmetic - i.e. modulo {add, sub, mul, exp, inv}. UltraHonk verification contains Fiat-Shamir, sumcheck and other routines which perform heavy guest side arithmetic on
Fr(a 32-bytes-scalar modulo bn254 curve subgroup order).Without these, contracts will need to implement them, or import external libs (e.g. arkworks), which is more expensive and bloats code side. Ethereum supports native modulo arithmetic operations (
ADDMODandMULMODas opcodes;modexpas a precompile).Here is an ultrahonk verifier contract prototype with the above host functions (env), the contract performance has been significantly improved.
cc @yugocabrio @Savio-Sou
Beta Was this translation helpful? Give feedback.
All reactions