BFV has no clean way to do a homomorphic dot product between two vectors (i.e., ), because the last step of a vector dot product requires summation of all slot-wise intermediate values (i.e., ). However, each slot in BFV’s batch encoding is independent from each other, which cannot be simply added up across slots (i.e., input vector elements). Instead, we need copies of the multiplied ciphertexts and properly align their slots by many rotation operations before adding them up. Meanwhile, the homomorphic input vector slot rotation scheme can be effectively used when we homomorphically multiply a plaintext matrix with an encrypted vector. Remember that given a matrix and vector (Definition A-10.3 in §A-10.3):
The result of is an -dimensional vector computed as:
Let’s define as the rotation of by positions to the left. And remember that the Hadamard dot product (Definition A-10.1 in §A-10.1) is defined as slot-wise multiplication of two vectors:
Let’s define distinct diagonal vector extracted from matrix as follows:
Then, the original matrix-to-vector multiplication formula can be equivalently constructed as follows:
, whose computation result is equivalent to . The above formula is compatible with homomorphic computation, because BFV supports Hadamard dot product between input vectors as a ciphertext-to-plaintext multiplication between their polynomial-encoded forms (§D-3.6), and BFV also supports as homomorphic input vector slot rotation (§D-3.9). After homomorphically computing the above formula, we can consider only the first (out of ) resulting input vector slots to store the result of .