Background reading Fully Homomorphic Encryption

Define the workload

The data owner encrypts [1.5, −2, 0.25]. The evaluator holds public weights [2, 0.5, 4]. The reference result is 3 − 1 + 1 = 3. The evaluator loads a context serialized without the secret key, computes the dot product, and returns a serialized ciphertext for the owner to decrypt.

Run the example

Download the Python example. Use a Python environment with a compatible TenSEAL wheel.

python -m pip install tenseal==0.3.18
python ckks-dot-product.py

The example uses polynomial modulus degree 8192, coefficient modulus bit sizes [60, 40, 40, 60], and scale 2⁴⁰. The dot product multiplies slots by the plaintext weights and sums them with rotations and additions. Galois keys enable the rotations. This computation uses one multiplication level and requires no bootstrapping.

Read the measured result

Run it again and compare the absolute error and ciphertext sizes. Encryption is randomized and timing varies. Look for a result near 3 and an error below the example’s 10⁻⁴ tolerance. The script also reports three coefficient modulus primes in the input ciphertext and two in the result. Try multiplying encrypted_result by 2 after timing the dot product. Expect one prime left and a decrypted value close to 6. TenSEAL documentation and examples.