encode
Engine.encode(array, level)- Encodes a message into a plaintext format for encryption.
The message is encoded in segments of length
Engine.slot_count. If the message length is not divisible by the slot count, the remaining slots are padded with zeros during encoding.
- Input:
- array: A Python list or a numpy ndarray. Supported data types include int, double, and complex double.
- level:
int, 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, 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.