-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix logQ(P) estimation used for finding the minimum ring dimension #796
Conversation
yspolyakov
commented
Jun 10, 2024
•
edited
Loading
edited
- Added EstimateLogP and EstimateMultipartyFloodingLogQ
- Updated the logic for BGV, BFV, and CKKS to use these methods prior to checking (finding) the ring dimension based on the LWE security tables
|
||
while (nRLWE(logqCeil) > n) { | ||
n = 2 * n; | ||
logq = logqBFV(n); | ||
k = static_cast<int32_t>(std::ceil((std::ceil(logq / std::log(2)) + 1.0) / dcrtBits)); | ||
logqCeil = k * dcrtBits * std::log(2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not adding the +1 anymore? The same comment for the occurrences below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why + 1 is needed in the current version of OpenFHE. Maybe in an old version (of PALISADE), we sometimes had larger moduli (NextPrime might have been used). So in my mind, ceil(logq/dcrtBits) is sufficient and guarantees that that logq<=k*dcrtBits. Moreover, adding + 1 would cause problems in the new estimation logic (getting an extra RNS limb when it is not needed).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only minor comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic looks good to me.
705bc25
to
78b6cd4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
// Find number and size of individual special primes. | ||
uint32_t maxBits = moduliPartQ[0].GetLengthForBase(2); | ||
for (usint j = 1; j < m_numPartQ; j++) { | ||
for (uint32_t j = 1; j < m_numPartQ; j++) { | ||
uint32_t bits = moduliPartQ[j].GetLengthForBase(2); | ||
if (bits > maxBits) | ||
maxBits = bits; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint32_t bits = 0, maxBits = 0;
for (auto&& m : moduliPartQ) {
if ((bits = m.GetLengthForBase(2)) > maxBits)
maxBits = bits;
}