New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix BLS12 G2PreparedGadget's AllocVar with a divisive twist #77
Conversation
Do you mean BLS12-377 (type D) here? |
Yes. Thanks for catching this. |
Thanks for the fix! I'm surprised this doesn't result in a cyclic dependency, as ark-bls12-377 itself depends on LGTM otherwise. |
Good idea. Then my plan is as follows: drop the test from this PR and make a new PR in |
Sounds good! |
Changes have been made. A separate PR will be created in |
Description
When working in Aleo's new Marlin implementation, we need gadgets for SonicPC, in which one needs to prepare a G2 element on BLS12-377.
It appears that the following two allocated variables are different:
AllocVar
on aG2Prepared
prepare_g2
on aG2Var
This seems to be because the
AllocVar
onG2Prepared
is specific to a BLS12 pairing where G2 has a multiplicative twist (i.e.,TwistType::M
). And the same conversion does not work for a divisive twist.The case for the multiplicative twist:
mul_014
over(a, bx, cy)
mul_014
over(a/c, b/c x, y)
The case for the divisive twist:
mul_034
over(ay, bx, c)
mul_034
over(y, a/c x, 1)
but it should be(y, b/a x, c/a)
There are multiple ways to fix: let the native follow the constraint, let the constraint follow the native, or let the
AllocVar
take care of the conversion. This PR does the last one, by makingAllocVar
implementation ofG2PreparedVar
aware of such difference.We did not discover this bug before because we commonly use BLS12-381 (type-M), but not BLS12-377 (type-D).
This is related to https://github.com/AleoHQ/snarkVM/pull/317
One question: do we want to keep the tests in this PR? They require additional dev dependencies since
ark-test-curves
does not have BLS12-377 or G2 of BLS12-381.Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
Pending
section inCHANGELOG.md
Files changed
in the Github PR explorer