Is there a built in method to perform vector - matrix multiplication?

Hi all,

I was wondering if there is a built in function to carry out multiplication of an encrypted m dimensional vector with a plain m times n matrix in OpenFHE? If that is not the case, is there an algorithm I can implement myself?
I am using the CKKS scheme by the way, and a lot of implementations I found were about quadratic matrices, which is not what I need.

Thanks in advance!

Currently, there is no supported homomorphic matrix-vector multiplication in OpenFHE that is exposed to the end user. We are planning to release a library for homomorphic matrix arithmetic (including matrix-vector multiplication) in the near future.

If you want to implement this functionality yourself, check out this paper, in particular, Section 4.3 on “Matrix-Vector Multiplication”. For a visual illustration of this algorithm check out Figure 6 in this paper.

Related to this, an OpenFHE user released an implementation of vector-matrix multiplication in OpenFHE in this post which could be useful to you. Note that we did not use this implementation and it is not part of OpenFHE, use it at your own discretion.

Thanks a lot, that was really helpful!

We are planning to release a library for homomorphic matrix arithmetic (including matrix-vector multiplication) in the near future.

Hello @Caesar are there any updates in this direction?

Hi @bazzilic,

Unfortunately, OpenFHE still does not support vector-matrix multiplication as an out-of-the-box API. However, you can achieve that by performing element-wise operations on vectors and matrices. OpenFHE includes functions for some common vector operations such as:

  1. EvalInnerProduct
  2. EvalSum
  3. EvalSumCols
  4. EvalSumRows

These can be helpful to implement your vector-matrix multiplication.
P.S. The code for the above functions can be found here.

1 Like