venumML.venumpy.small_glwe
Represents an encrypted ciphertext in the cryptographic scheme.
This class allows for homomorphic operations (addition, subtraction, multiplication) on ciphertexts and supports serialization to/from JSON format.
Attributes
- _raw_cipher (object): The underlying raw ciphertext from the bindings.
- _context (object): The context in which the ciphertext was created (either public or secret).
Initializes a new ciphertext from a raw ciphertext and context.
Parameters
- raw_cipher (object): The raw ciphertext object from the bindings.
- context (object): The context associated with the ciphertext.
Serializes the ciphertext into a JSON format.
Returns
- str: A JSON string representation of the ciphertext.
Deserializes a JSON representation of a ciphertext.
Parameters
- context (object): The context to associate with the deserialized Ciphertext.
- cipher_json (str): The JSON string representing the ciphertext.
Returns
- Ciphertext: A new Ciphertext object.
Represents a general cryptographic context.
Provides methods to serialize and manage the precision of computations.
Attributes
- _raw_ctx (object): The raw context object from the bindings.
Serializes the context into a JSON format.
Returns
- str: A JSON string representation of the context.
Represents a secret cryptographic context, used for key generation and decryption.
Attributes
- _raw_ctx (object): The underlying raw secret context from the bindings.
Initializes a new secret context.
Parameters
- bits_of_security (int, optional): The bits of security for the cryptographic context (default is 128).
- generate (bool, optional): Whether to generate a new secret context (default is True).
Encrypts a plaintext value using this secret context.
Parameters
- plaintext (object): The value to encrypt.
Returns
- Ciphertext: The encrypted value as a Ciphertext object.
Decrypts a ciphertext using this secret context.
Parameters
- ciphertext (Ciphertext): The Ciphertext object to decrypt.
Returns
- object: The decrypted value.
Converts this secret context into a public context.
Returns
- PublicContext: A new PublicContext object.
Deserializes a secret context from a JSON string.
Parameters
- ctx_json (str): The JSON string representing the secret context.
Returns
- SecretContext: A new SecretContext object.
Deserializes a secret context from byte representation.
Parameters
- ctx_bytes (bytes): The bytes representing the secret context.
Returns
- SecretContext: A new SecretContext object.
Inherited Members
Represents a public cryptographic context, used for encryption.
A PublicContext
is generated from a SecretContext
and allows for
encryption operations, but not decryption.
Attributes
- _raw_ctx (object): The raw public context object from the bindings.
Initializes a new public context.
Parameters
- generate (bool, optional): Whether to generate a new public context (default is False).
Encrypts the provided plaintext values.
Parameters
- plaintext (object): The value to encrypt.
Raises
- Exception: Raised because public encryption is currently not supported.
Returns
- None
Decrypts the provided ciphertext.
Raises
- Exception: Raised because public decryption is currently not supported.
Returns
- None
Deserializes a public context from a JSON string.
Parameters
- ctx_json (str): The JSON string representing the public context.
Returns
- PublicContext: A new PublicContext object.
Deserializes a public context from byte representation.
Parameters
- ctx_bytes (bytes): The bytes representing the public context.
Returns
- PublicContext: A new PublicContext object.