Hallo,

i use your project for research and evaluate ckks. I don’t understand the connection between batch_size, ring dimension and array of values

If i want to encrypt 10 values of array, i should set batch_size to 16, because number of slots cannot be smaller than value vector size. Is it right?

Second question, if i change my batch_size to 16, 32, my ring dimension doesnt change (ring dimension: 16384). Why?

What is mention of batch_size

Why do not change my ring dimension. Can i change ring dimension without changing batch_size?

How can i encrypt many values of encoded vector

In CKKS, a ciphertext can encrypt up to ring_dim/2 values. For efficiency reasons, if the application requires fewer than ring_dim/2 values, one can work in a subring whose size is specified by batch_size.

As a rule, array_to_encrypt_size <= batch_size <= ring_dim/2. The ring dimension is determined first by the security level specified and by the ciphertext modulus (determined by the number and size of moduli). If your specified batch_size (number of values you want to encrypt) is less than the half of this determined ring dimension, then nothing changes. Otherwise, the ring dimension will increase to be able to support the batch_size specified.

@andreea.alexandru

I thought that batch_size define ring_dim, like

batch_size * 2 = ring_dim

How can i change security level and ciphertext modulus or can self set ring dimension?

What is your goal? To get a smaller ring dimension for a fixed security level and fixed batch size? Set the multiplicative depth to the lowest value you need for your computation, and set the firstModSize and scalingModSize to lower values than the default ones.

Please search the forum for this, as there are many discussions on choices for the CKKS parameters.

i wanted to vary ring dimension and security level to compare execution time of ckks

One question, if i set parameters like array_to_encrypt_size <= batch_size, i get unknown values at the end of endcrypted array. Should i change something?

i set:

batch_size = int(32768/2)

RingDimValue=32768

parameters.SetSecurityLevel(HEStd_NotSet);

parameters.SetRingDim( yourRingDimValue );

Output:

Results of homomorphic computations:

x1 = (0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, -6.99408e-12, -3.16094e-12, 1.33607e-12, 6.05779e-12, -2.50286e-12, -5.07379e-12, 3.38626e-12, -3.95326e-12, 1.13897e-11, -2.70856e-15, -4.80819e-12, 1.54104e-13, 5.91013e-13, -4.87261e-12, 1.71532e-12, -4.56572e-13, 7.63633e-12, 4.14733e-12, 6.18406e-12, 9.93665e-13, -4.38816e-12, -4.22277e-12, -1.51131e-12, -3.74516e-12, -4.21287e-12, …

A plaintext/ciphertext in CKKS encodes a vector. The expected behavior is to fill the plaintext vector up to the batch size with zeroes. This is what you observe. CKKS is an approximate scheme, so 0 is approximated by the small numbers that you see.

Can i set the value of batch_size flexibel, without a concrete value

When the batch size is set to 0, it corresponds to full packing, i.e., the number of slots is automatically set to ring_dim/2. If one sets it to a non-zero (a power of two), this custom value is used.