Linear algebra is a core primitive of many applications of fully homomorphic encryption, including privacy-preserving machine learning, statistical analysis, and encrypted search. Efficient homomorphic matrix-vector and matrix-matrix multiplications are therefore an essential tool, and have been intensely studied over the last fifteen years. Recent work, notably by Bae et al. and Park reduces homomorphic matrix multiplication in large dimension to the multiplication of plaintext matrices, plus a number of key switchings only linear in the dimension, enabling the use of highly efficient linear algebra primitives, such as those of the BLAS library, while limiting the homomorphic cost. These results have been extended by Cheon et al. to batches of matrix multiplications in smaller dimension. In CKKS, the corresponding algorithms rely on dedicated encodings (coefficient, SinC). Using these encodings constrains integration of these algorithms into a larger computation; in practice, one has either to perform an expensive conversion or to schedule the linear algebra within bootstrapping. Alternatively, Gentry and Lee obtain reductions in the slot encoding through a different ciphertext ring. We obtain reductions to plaintext matrix multiplication directly in the slot encoding, over the standard power-of-two CKKS ring, showing that the change of ring of Gentry and Lee is not required for this functionality. Our approach uses the cyclic algebra of the field extension $\mathbb Q(\zeta_{2N})/\mathbb Q(\mathrm{i})$ to describe endomorphisms independently of the choice of coordinates. We show that choosing a basis (which identifies endomorphisms with matrices) is exactly choosing an encoding. Algorithms written once in this language cover the functionalities of the classical encodings, for single matrices and, over subfields, for batches of smaller ones. This language also makes explicit the commutation of the secret key with the matrix, which is the key step in the product of two encrypted matrices. The resulting algorithms admit elementary descriptions, corresponding to a precise scheduling of the key switchings, which allows them to be grouped, while the algebraic framework explains their common structure across various packings. Our framework extends to products of an encrypted $d \times d$ matrix by an encrypted $d \times c$ matrix, where it allows a baby-step giant-step strategy even though both factors are encrypted. For ring degree $N$, with $c \mid d \mid N/2$, we evaluate a batch of $N/(2d)$ such products with $O(\sqrt{dc})$ key switchings in total, without any preprocessing of the encrypted inputs. In particular, an encrypted matrix-vector product requires only $O(\sqrt{d})$ key switchings.
One Algebra to Multiply Them All: Fast Homomorphic Linear Algebra in Every Encoding
A new algebraic framework performs homomorphic matrix-vector and matrix-matrix multiplication directly in the slot encoding over the standard power-of-two CKKS ring, eliminating the ciphertext-ring change that Gentry and Lee required for the same functionality. Using the cyclic algebra of the field extension Q(ζ_2N)/Q(i), the authors show that choosing a basis is exactly choosing an encoding, so algorithms written once cover the classical coefficient and SinC encodings for single matrices and, over subfields, for batches of smaller ones. For ring degree N with c | d | N/2, the framework evaluates a batch of N/(2d) encrypted d×d by d×c matrix products with O(√(dc)) key switchings in total and no preprocessing of encrypted inputs, with an encrypted matrix-vector product needing only O(√d) key switchings.
Working in the slot encoding over the standard power-of-two CKKS ring, a batch of N/(2d) encrypted d×d by d×c matrix products costs O(√(dc)) key switchings total and an encrypted matrix-vector product costs O(√d), with no preprocessing of encrypted inputs.
Run your AI side-project on zahid.host
EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.