encode

Engine.encode(message, level)
Encodes a message into a plaintext format for encryption. The maximum size that can be encoded at once is determined by Engine.slot_count. If the message length exceeds this size, an error is raised. If it is smaller, the message is padded with zeros during encoding.
  • Input:
    • message: A Python list or numpy array. Data types supported include int, double, and complex double.
    • level: optional
      • Specifies the maximum multiplication level for encoding. Lower levels reduce space usage but also reduce the maximum multiplication depth.
  • Output:
    • Plaintext
from desilofhe import Engine

engine = Engine()

message = [1, 2, 3]
encoded = engine.encode(message)
from desilofhe import Engine

engine = Engine()

message = [1, 2, 3]
encoded = engine.encode(message, level=3)

Typically, the encrypt function handles encoding automatically. Pre-encoding a message can improve efficiency when the same message is reused across multiple operations, as it avoids redundant encoding.