Repository navigation
fix for composite scaling example - #1359
Merged
Merged
Conversation
… core_tests (#1358) CompositePrimeModuliGen could run forever: when the running scaling factor collapsed, the next target prime fell below the cyclotomic order and the candidate wrapped to just under 2^64, and searches that started above the register word size walked down one candidate at a time. Throw the prime sampling error before the wrap, and start each search at the register word size, which selects the same primes. PreviousPrime now throws when its input is at or below the step instead of returning a wrapped value. Move TernaryUniformGeneratorImpl::GenerateInteger next to the static distribution it uses, which clang rejected under -Werror=undefined-var-template.
replacement, so the search cannot accept a prime already used in the same level, and throw as soon as raising a prime would cross the register word size, where the search previously walked down to the bottom of the range.
When cyclOrder divides 2^registerWordSize, as it must for any prime to fit the register word, the ceiling is 2^registerWordSize + 1, so the first candidate is the largest value that is 1 mod cyclOrder at or below the limit instead of one step above it. Otherwise the ceiling is 1 and PreviousPrime throws at once. The selected primes do not change.
dsuponitskiy
approved these changes
Sep 27, 2026
yspolyakov
approved these changes
Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1358
(1) The target prime fell below the cyclotomic order and the unsigned candidate wrapped to just under 2^64.
(2) Searches started far above the register word and walked down one candidate at a time.
(3) The raise-the-product loop crossed the register word, turned around and walked to the bottom of the range.
Validation.