-
Notifications
You must be signed in to change notification settings - Fork 791
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
Add new EIP-2537 BLS test cases to EVM #3896
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. |
Hi @paulmillr, it seems that two tests fail, but only on Noble (pass on MCL), so the suspect is that something in
If I attempt to fix similar to the Nethermind way in 6871ec5, I now get other tests which fail. The EVM fails with an error on those tests;
The relevant error here is:
(Note: if there is an error it will output no bytes, so it will output 0x, I will harden the test runner such that it first check if there is an error in the case that no error is expected, and if there is an error raise before checking the return buffer to avoid confusion in the future) I have absolutely no idea about any of this math, so I will not start guessing how I should fix this. Would be great if you could take a look :) |
So here is the relevant code: // NOTE: check for point of infinity should happen only after all points parsed (in case they are malformed)
for (const { g1, g2 } of pairs) {
const _g2 = g2 as unknown as any
// EIP: "If any input is the infinity point, pairing result will be 1"
if (g1.equals(G1_ZERO) || (_g2.equals(G2_ZERO) as boolean)) {
return BLS_ONE_BUFFER
}
}
const FP12 = bls12_381.pairingBatch(pairs, true)
if (bls12_381.fields.Fp12.eql(FP12, bls12_381.fields.Fp12.ONE)) {
return BLS_ONE_BUFFER
} else {
return BLS_ZERO_BUFFER
} For the fix I have removed the for loop which checks the pairs, and if anything is Here is the code which seems somewhat similar in MCL (MCL passes these tests) GT = this._mcl.finalExp(GT)
if (GT.isOne() === true) {
return BLS_ONE_BUFFER
} else {
return BLS_ZERO_BUFFER
} |
Here is a thing which I want to investigate: if we run coverage on these tests (before any fix), then likely one of the lines will get flagged as yellow / partially tested. This could be used for the future to flag uncovered test cases which could then be used to find these kind of bugs / divergences. |
The thread says
So, you should filter-out infinity points from pairs and pass the result to pairingBatch:
|
Closes #3895
Adds test cases from: ethereum/EIPs#9425. We fail two:
It seems like we also have the Nethermind bug (?) described here: https://ethereum-magicians.org/t/bls12-381-pairing-consensus-issue/23019