encrypt
Encryption with Python Data
GLEngine.encrypt(message, secret_key, level)- Directly encrypts a list or numpy array using a secret key. If the message length exceeds this size of shape, an error is raised. If it is smaller, the message is padded with zeros during encoding.
- Input:
- message: A Python list or numpy array. Supported data types include int, double, and complex double.
- GLSecretKey
- level: optional
- Specifies the desired multiplication level. Lower levels reduce space usage but also reduce the maximum multiplication depth.
- Output:
- GLPlaintext
from desilofhe import GLEngine
engine = GLEngine()
secret_key = engine.create_secret_key()
message = np.ones(engine.shape)
ciphertext = engine.encrypt(message, secret_key)
from desilofhe import GLEngine
engine = GLEngine()
secret_key = engine.create_secret_key()
message = np.ones(engine.shape)
ciphertext = engine.encrypt(message, secret_key, level=3)
Encryption with Plaintext
Engine.encrypt(plaintext, secret_key)- Encrypts an already encoded plaintext using a secret key. The ciphertext's maximum multiplication depth will match the specified level of the plaintext.
- Input:
- GLPlaintext
- GLSecretKey
- Output:
- GLCiphertext
from desilofhe import GLEngine
engine = GLEngine()
secret_key = engine.create_secret_key()
message = np.ones(engine.shape)
plaintext = engine.encode(message)
ciphertext = engine.encrypt(plaintext, secret_key)
Using an API that combines encoding and encryption is generally faster. This function is recommended when you need to encrypt the same message multiple times or when the message is pre-encoded for other purposes.