-
Notifications
You must be signed in to change notification settings - Fork 1
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
correct bootstrap!
and add use of batch size in init_bootstrapping
#18
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 8 8
Lines 309 310 +1
=========================================
+ Hits 309 310 +1 ☔ View full report in Codecov by Sentry. |
Is "your" length equal to what you specify as the "batch size" when you set up the CCParams? If yes, then it should be called "capacity" 👍 If not, then we might have a third number that is neither length nor capacity 🤔 To me, capacity is the physical limit of how much data can be stored in a given ciphertext/plaintext. it is a property of the FHE scheme. The length on the other hand is purely a convenience thing: when encoding a three-value vector, doing some FHE operations with it, and then decoding the result, I want to be retrieve a three-value vector again, not one that has 3 values of usable data and 5 values of garbage. Do you understand what I mean? |
OK, can you please fix this as well (if not yet done)? |
|
It's already done in this PR |
Ohh, naming is always difficult. If I undestand correctly Yeah, as you said in your example, I would get now after decrypting not 3 values, but 8. And need to slice it by myself. |
IIUC from https://github.com/openfheorg/openfhe-development/blob/b2869aef5cf61afd364b3eaea748dcc8a7020b9c/src/pke/include/cryptocontext.h#L3244, what is expected here is the number of slots. Wouldn't this be the same as the batch size, i.e., what we call here capacity? Maybe you can ask this on the OpenFHE Discourse forum, what the relation between ring dimension, batch size, num slots and length is, before we proceed here? |
"When the number of slots is specified during MakeCKKSPackedPlaintext, that number of slots is set for a specific plaintext/ciphertext. The batch size is the global (default) setting for all ciphertexts in the cryptocontext." It seems to be, that |
Thanks for asking there - this seems to be a very helpful answer for us!
Yes, I think for SecureArithmetic.jl, we should make no difference between Maybe, just to be sure, you can ask
Example for the last question: If |
…/SecureArithmetic.jl into init_bootstrapping
bootstrap!
and add use of batch size in init_bootstrapping
I removed all unnecessary changes in this PR, that could be solved by setting appropriate I changed And also I suggest to replace |
Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
Co-authored-by: Michael Schlottke-Lakemper <[email protected]>
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.
Thanks!
It solves issue #17.
As was discussed, I add possibility to use smaller length as ring_dim//2.
New functions:
init_bootstrapping!(context::SecureContext{<:OpenFHEBackend}, private_key::PrivateKey, length::Int)
For the same purpose I added:
PlainVector(data::Vector{Float64}, length::Int, context::SecureContext{<:OpenFHEBackend})
with user-chosen length of Plaintext.I add also a duplicate for Unencrypted case, to be able to reuse the same code for unencrypted data.
Also
OpenFHE.EvalBootstrap(cc, secure_vector.data)
does not change the argumentsecure_vector.data
itself, but returns new Ciphertext, that needs to be assigned as newsecure_vector.data
.@sloede , I used
length
instead ofnum_slots
. But I'm not really sure, if it's actually length. Because if I'm using for example 40 nodes, than I neednum_slots=64
(nearest power of two). Actual length of data isBase.length(data) = 40
andcapacity = OpenFHE.GetSlots(plaintext)
is 64. May be it make sense to renamenum_slots
in functions of this PR to capacity, not length?