Tensor Classes
Base Tensor
- class openfhe_numpy.tensor.tensor.BaseTensor[source]
-
- abstractmethod clone(data=None)[source]
- Return type:
BaseTensor[TypeVar(Template)]- Parameters:
data (Template)
- class openfhe_numpy.tensor.tensor.PackedArrayInformation(data, original_shape, ndim, batch_size, shape, order)[source]
Bases:
object- Parameters:
- class openfhe_numpy.tensor.tensor.FHETensor(data, original_shape, batch_size, new_shape, order=0)[source]
Bases:
BaseTensor[Template],Generic[Template]Concrete base class for tensors in FHE computation.
- Parameters:
data (
Union[list,ndarray,PackedArrayInformation]) – Underlying encrypted or encoded of a packed encoding array.original_shape (
Tuple[int,int]) – Shape before any padding.batch_size (
int) – Total number of packed slots.new_shape (
Tuple[int,int]) – Since the shape may change after some operations, we need to store the new information.order (
int) – Packing order: only support row-major or column-major.
- __init__(data, original_shape, batch_size, new_shape, order=0)[source]
- Overloads:
self, data (TPL), original_shape (Tuple[int, int]), batch_size (int), new_shape (Tuple[int, int]), order (int) → None
self, info (PackedArrayInformation) → None
- Parameters:
- Return type:
None
- extra
- property size
- property dtype
- property data: Template
Underlying encrypted/plaintext payload.
- property T
- clone(data=None)[source]
Copy the tensor, optionally replacing the data payload.
- Return type:
BaseTensor[TypeVar(Template)]- Parameters:
data (Template | None)
Ciphertext Array
- class openfhe_numpy.tensor.ctarray.CTArray(data, original_shape, batch_size, new_shape, order=0)[source]
Bases:
FHETensor[Ciphertext]Encrypted tensor class for OpenFHE ciphertexts. Represents encrypted matrices or vectors.
- Parameters:
- tensor_priority = 10
- property crypto_context
Get the underlying crypto context
- property zeros
Get the zeros ciphertext
- decrypt(secret_key, unpack_type=UnpackType.ORIGINAL, new_shape=None)[source]
Decrypt the ciphertext and format the output.
- Parameters:
secret_key (
PrivateKey) – Secret key for decryption.unpack_type (
UnpackType) –RAW: raw data, no reshape
ORIGINAL: reshape to original dimensions
ROUND: reshape and round to integers (not support now)
AUTO: auto-detect best format (not support now)
new_shape (
Union[Tuple[int,...],int,None]) – Custom shape for the output array. If None, uses original shape.
- Returns:
The decrypted data, formatted by ‘unpack_type’.
- Return type:
- gen_sum_row_key(secret_key)[source]
- Return type:
EvalKey- Parameters:
secret_key (openfhe.PrivateKey)
- extra
Plaintext Array
- class openfhe_numpy.tensor.ptarray.PTArray(data, original_shape, batch_size, new_shape, order=0)[source]
Bases:
FHETensor[Plaintext]Concrete tensor class for OpenFHE plaintexts.
- Parameters:
- encrypt(crypto_context, public_key)[source]
- Parameters:
crypto_context (openfhe.CryptoContext)
public_key (openfhe.PublicKey)
- extra