serengil/LightPHE

add homomorphic operation support for encrypted tensors

Closed this issue · 1 comments

  • Encrypt & decrypt tensors with float items
  • Homomorphic operations such add addition, element-wise multiplication, scalar multiplication and xor
  • Homomorphic multiplication (dot product) will not work because it requires addition and multiplication meanwhile and this cannot be done with PHE.
  • Tensor should be 1D vectors and all items must be int or float. We will handle multi-dimensional vectors (tensors) in a separate PR.

To encrypt & decrypt floats, we may adopt one of these approaches:

Option 1: Store Dividend and Divisor Separately

Pros:

Exact Representation: This method allows you to exactly represent the original value without loss of precision. You store the dividend and divisor separately, allowing for precise arithmetic operations during decryption.

Cons:

Increased Storage: Storing both the dividend and divisor separately may require more storage compared to the second option, where you only need to store a single integer.

Complexity: Managing two separate values might add complexity to your implementation. You need to make sure that the operations are performed correctly during encryption and decryption.

Option 2: Multiply and Divide by a Fixed Factor

Pros:

Simplicity: This method is simpler to implement, as you only need to multiply and divide by a fixed factor. This reduces the complexity of your code.

Reduced Storage: You only need to store a single integer value, which can save storage space compared to storing both the dividend and divisor separately.

Cons:

Loss of Precision: Multiplying and dividing by a fixed factor can lead to a loss of precision. If your fixed factor is not large enough, you may encounter rounding errors during encryption and decryption.

Limited Range: Depending on the fixed factor, you might have a limited range for the values you can represent in your encrypted tensor.

Closed after PR - #16