Skip to content

Fix BGV ring dimension underestimation with NOISE_FLOODING_MULTIPARTY + HYBRID on 128-bit builds#1158

Merged
yspolyakov merged 4 commits into
devfrom
1157-fix-bgv-ring-dimension
Apr 7, 2026
Merged

Fix BGV ring dimension underestimation with NOISE_FLOODING_MULTIPARTY + HYBRID on 128-bit builds#1158
yspolyakov merged 4 commits into
devfrom
1157-fix-bgv-ring-dimension

Conversation

@dsuponitskiy
Copy link
Copy Markdown
Collaborator

@dsuponitskiy dsuponitskiy commented Mar 26, 2026

BUG
We estimate P from estimated Q before the flooding primes are added. After that, the actual value of P is calculated from the actual Q in PrecomputeCRTTables(). In some 128-bit cases this made the real QP bigger than expected and failed generating a cryptocontext.

FIXES

  • Makes the P estimate include the flooding primes (this bug affected BGV and BFV)
  • Adds a check to compare estimated vs actual sizeP in PrecomputeCRTTables() and triggers an exception if there is a mismatch
  • Fixes another bug (affecting FIXEDMANUAL for BGV), which was detected by the new checking mechanism. An extra bit was added to an estimate of Q for FIXEDMANUAL, which caused a mismatch in the size limbs in P.

@dsuponitskiy dsuponitskiy added this to the Release 1.5.1 milestone Mar 26, 2026
@dsuponitskiy dsuponitskiy self-assigned this Mar 26, 2026
@dsuponitskiy dsuponitskiy added the bug Something isn't working label Mar 26, 2026
@dsuponitskiy dsuponitskiy requested a review from yspolyakov March 27, 2026 13:19
Comment thread src/pke/lib/scheme/bgvrns/bgvrns-parametergeneration.cpp
@yspolyakov yspolyakov marked this pull request as draft March 27, 2026 19:37
Comment thread src/pke/lib/scheme/bgvrns/bgvrns-parametergeneration.cpp
… with NOISE_FLOODING_MULTIPARTY + HYBRID on 128-bit builds
@dsuponitskiy dsuponitskiy force-pushed the 1157-fix-bgv-ring-dimension branch from efd0d94 to d33c011 Compare April 6, 2026 10:49
Comment thread src/pke/include/schemerns/rns-cryptoparameters.h Outdated
Comment thread src/pke/include/schemerns/rns-cryptoparameters.h Outdated
Comment thread src/pke/lib/schemerns/rns-cryptoparameters.cpp Outdated
Comment thread src/pke/lib/schemerns/rns-cryptoparameters.cpp Outdated
@dsuponitskiy dsuponitskiy force-pushed the 1157-fix-bgv-ring-dimension branch from aa1640f to ee3c301 Compare April 6, 2026 19:43
@dsuponitskiy dsuponitskiy marked this pull request as ready for review April 7, 2026 14:34
@yspolyakov yspolyakov merged commit c5b4e36 into dev Apr 7, 2026
19 checks passed
@dsuponitskiy dsuponitskiy deleted the 1157-fix-bgv-ring-dimension branch April 7, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix BGV ring dimension underestimation with NOISE_FLOODING_MULTIPARTY + HYBRID on 128-bit builds

3 participants