I have a simple program that uses BFV and for testing purposes I would like for a selected security level (e.g HEStd_128_classic
) to increase the Ring Dimension. I can already do this with the snippet found below, but I had the following question:
Does increasing the Ring Dimension affect (in a negative manner) the resulted security level of the selected parameters? As far as I understand, the HomomorphicEncryption.org guideline present lower limits to achieve a given security level. Does this mean that I can safely increase the Ring Dimension and even get a more robust parameter selection?
Additionally, could you possibly point me to any resources that I can read about this and I could reference them if I made such claims?
Find here the snippet:
import openfhe as fhe
# Set the parameters
parameters = fhe.CCParamsBFVRNS()
parameters.SetPlaintextModulus(5767169)
parameters.SetMultiplicativeDepth(1)
parameters.SetSecurityLevel(fhe.HEStd_128_classic)
parameters.SetRingDim(262144)
crypto_context = fhe.GenCryptoContext(parameters)
crypto_context.Enable(fhe.PKESchemeFeature.PKE)
crypto_context.Enable(fhe.PKESchemeFeature.KEYSWITCH)
crypto_context.Enable(fhe.PKESchemeFeature.LEVELEDSHE)
crypto_context.Enable(fhe.ADVANCEDSHE)
# Print the parameters
q = crypto_context.GetModulus()
q_bitlength = int(q).bit_length()
print("Plaintext Modulus = ", 5767169)
print("Ciphertext modulus bitsize (log2 q) = ", q_bitlength )
print("Ring Dimension (m) = ", crypto_context.GetRingDimension() )
# Generate keys
key_pair = crypto_context.KeyGen()
crypto_context.EvalMultKeyGen(key_pair.secretKey)
# Generate data of length equal to the Ring Dimension
data = [i for i in range(262144)]
# Encrypt
data_packed = crypto_context.MakePackedPlaintext(data)
data_encrypted = crypto_context.Encrypt(key_pair.publicKey, data_packed)
# Evaluate
result_encrypted = crypto_context.EvalAdd(data_encrypted, data_encrypted)
# Decrypt and unpack
result_decrypted = crypto_context.Decrypt(result_encrypted, key_pair.secretKey)
result_decrypted.SetLength(262144)
unpacked_result = result_decrypted.GetPackedValue()
# Print the results
print(unpacked_result[0:100])
print(len(unpacked_result))
Thank you!