square

Engine.square(ciphertext, relinearization_key)
Returns the square of the input ciphertext. Consumes a level.
  • Input:
    • Ciphertext
    • RelinearizationKey, optional
      • If provided, the resulting ciphertext undergoes relinearization. This is recommended to facilitate subsequent operations.
  • Output:
    • Ciphertext
from desilofhe import Engine

engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
relinearization_key = engine.create_relinearization_key(secret_key)

message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)

squared = engine.square(ciphertext, relinearization_key)
Engine.square(ciphertext, evaluation_key)
Returns the square of the input ciphertext. The result is relinearized using the relinearization key bundled in the evaluation key. Consumes a level.
  • Input:
    • Ciphertext
    • EvaluationKey, optional
      • If provided, the resulting ciphertext undergoes relinearization. This is recommended to facilitate subsequent operations.
  • Output:
    • Ciphertext

Warning

  • The matrix form does not yet support this operation.
from desilofhe import Engine

engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
evaluation_key = engine.create_evaluation_key(secret_key)

message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)

squared = engine.square(ciphertext, evaluation_key)