Skip to content

Conversation

@obliviateandsurrender
Copy link
Contributor

@obliviateandsurrender obliviateandsurrender commented Nov 12, 2025

Context: This fixes GCD and modulo computations for the ZSqrtTwo and ZOmega ring elements.

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Nov 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.42%. Comparing base (f8e540b) to head (d37a69f).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8636      +/-   ##
==========================================
- Coverage   99.43%   99.42%   -0.02%     
==========================================
  Files         587      587              
  Lines       61887    61971      +84     
==========================================
+ Hits        61538    61615      +77     
- Misses        349      356       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

(
ZOmega(-22067493351, 22078644868, 52098814989, 16270802723),
ZOmega(-21764478939, 70433513740, -5852668010, 4737137864),
73,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the same or different example from the paper? I thought that one had 72?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an example you send in the chat. I computed 73 based on its float value.

(ZOmega(d=28), ZOmega(d=12), ZOmega(d=4)),
(ZOmega(d=15), ZOmega(d=25), ZOmega(d=5)),
(ZOmega(d=81), ZOmega(d=63), ZOmega(d=9)),
(ZOmega(d=144), ZOmega(d=108), ZOmega(d=36)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add some tests for cases where a/b/c are not 0? maybe you can just find two primes A, B, and multiply some unit U in ZOmega and make it find U = gcd(AU,BU)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few of them. I can add more if you'd like.

return ZSqrtTwo(self.a % int(other), self.b % int(other))

d = abs(other)
if (s := abs(self)) < (d := abs(other)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to convince myself about this - is there any proof/reference for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no proof. I was simply trying to accommodate for the time when a < b. That's why i asked you to benchmark this separately. 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Essentially, it is a matter of convention to be honest about whether you would allow for a negative modulus.

Copy link
Contributor

@josephleekl josephleekl Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if I have a = 3*sqrt(2) , b = sqrt(2), we should have a%b = 0.

But we have abs(a) = -18, and abs(b) = -2, abs(a) < abs(b) is true, and this will return a, which I don't think is correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think abs orders the elements in ZSqrtTwo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true. I think for them it is easier to use the float values instead.

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.

3 participants