How to pack several vectors into a ciphertext?for example, I set batchsize=16, I want to encrypt three vectors of length 10 and package them into a ciphertext
If your batchsize
is 16 you can’t pack 3 ciphertexts of length 10 into it. At the least you’d need 30, no?
Also, one way to do something like this might be
VECTOR_SIZE = 10;
SMALLEST_POW_2_UP = 16;
NUM_VECTORS = 3;
std::vector<T> container_vec(SMALLEST_POW_2_UP * NUM_VECTORS);
vector_of_vectors = Vector[
v1, // length 16, but the last (SMALLEST_POW_2_UP - VECTOR_SIZE) are just 0s
v2, // length 16, but the last (SMALLEST_POW_2_UP - VECTOR_SIZE) are just 0s
v3 // length 16, but the last (SMALLEST_POW_2_UP - VECTOR_SIZE) are just 0s
]
for (int i = 0; i < NUM_VECTORS; i++){
curr_vec = vector_of_vectors[i] // one of the 3
for (int j = 0; j < SMALLEST_POW_2_UP; j++){
container_vec[(i * SMALLEST_POW_2_UP) + j] = curr_vec[j]
}
}
The code isn’t valid C++ but hopefully gives you enough context for how to do what you’re asking. Bear in mind that you’ll have to keep a close eye on the indices and how you use the vectors
thanks,I understand it.