Skip to content

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 into
CAPS-UMU:mainfrom
seyfal:fix/limbpartition-multpt-top-limb
Sep 10, 2026
Merged

carlostriste merged 2 commits into
CAPS-UMU:mainfrom
seyfal:fix/limbpartition-multpt-top-limb

Conversation

@seyfal

@seyfal seyfal commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

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. LimbPartition::rescale itself already uses limb.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 by rescale() 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

… 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
carlostriste merged commit 1a681e8 into CAPS-UMU:main Sep 10, 2026
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.

2 participants