Skip to content

fix: weil pairing test picks a random point that can hit a zero or pole - #255

Open
saviourmk wants to merge 1 commit into
pluto:mainfrom
saviourmk:fix/weil-pairing-random-point
Open

saviourmk wants to merge 1 commit into
pluto:mainfrom
saviourmk:fix/weil-pairing-random-point

Conversation

@saviourmk

Copy link
Copy Markdown

This PR closes #213

The failing assert is the Weil pairing value, not the Tate one. The test helper weil_pairing picks a random point S so the divisors have disjoint support, but it only rules out S = P, -Q and P-Q. The functions built in the Miller loop for f_{r,P} have their zeros and poles at multiples of P, so whenever Q+S or S happens to be a multiple of P (or -S or P-S a multiple of Q), miller_loop skips a zero and a pole together and returns the wrong value without tripping the zeros == 0 assert.

It changes the following:

S is now redrawn until Q+S and S aren't multiples of P and -S and P-S aren't multiples of Q. That covers the three cases that were excluded before. Only the test helper changes, pairing itself is fine.

To check it I ran weil_pairing 3000 times on the points from case 2. On main 9 of those runs gave the wrong value, with this change 0 did. The pairing tests and fmt pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: weil_tate_pairing fail case

1 participant