LimbPartition::multPt: use the top limb of the current level (FIXEDMANUAL multPt with rescale was wrong below the top level) - #39
Merged
carlostriste merged 2 commits intoSep 10, 2026
Conversation
… physical top of the storage LimbPartition::multPt takes limb.back() (and p.limb.back()) for the multiply + INTT of the top limb, while the fused NTT_MULTPT launch it feeds is given limbsize = getLimbSize(*level) and base-converts from limb[limbsize - 1]. The two differ whenever the storage vector holds more limbs than the current level, which is the normal state: dropToLevel and rescale never pop limbs and polys are recycled through the auxiliary pool. Under FIXEDMANUAL, multPt(pt, rescale = true) therefore decrypts correctly only for a ciphertext at the top level and returns garbage below it. Use limb.at(limbsize - 1), as LimbPartition::rescale already does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Removed comments about limb storage and recycling in LimbPartition.
carlostriste
approved these changes
Sep 10, 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.
LimbPartition::multPttakeslimb.back()andp.limb.back()for the multiply + INTT of the top limb, while the fused NTT_MULTPT launch it feeds is givenlimbsize = getLimbSize(*level)and base-converts fromlimb[limbsize - 1]. The two differ whenever the storage vector holds more limbs than the current level, which is the normal state:dropToLevelandrescalenever pop limbs and polys are recycled through the auxiliary pool.LimbPartition::rescaleitself already useslimb.at(limbsize - 1).Effect: with
SetScalingTechnique(FIXEDMANUAL),ct.multPt(pt, true)decrypts correctly only for a ciphertext at the top level (N = 2^16, depth 25: level 24, error 3.2e-10). At levels 20, 17, 16, 15, 14, 13, 12, 10 and 5 the result is garbage (OpenFHE's decode gate fires).multPt(pt, false)followed byrescale()is correct at all levels, and FLEXIBLEAUTO is not affected. With this two-line change,multPt(pt, true)is correct at every level 5..24 (3.4e-10 .. 3.5e-9), tested on an H200.Related: #36 now also checks the plaintext limb count before the kernels, because under FIXEDMANUAL no adjustment step runs and a short plaintext was read out of bounds.
Fable 5.1 on behalf of Seyfal