Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypting and operating with 2D numpy arrays (images) #212

Open
elyasgoli opened this issue Sep 1, 2023 · 3 comments
Open

Encrypting and operating with 2D numpy arrays (images) #212

elyasgoli opened this issue Sep 1, 2023 · 3 comments
Labels
HowTo How to accomplish something with Pyfhel. Candidate to a demo/example.

Comments

@elyasgoli
Copy link

elyasgoli commented Sep 1, 2023

Description
When I try Demo_3_Float_CKKS.py with a 2-dimensional numpy array, I get an error.

Code To Reproduce Error

arr_x [[1. 2. 3.]
 [4. 5. 6.]
 [7. 8. 9.]]
Traceback (most recent call last):
  File "/home/elyas/Pyfhel/examples/Try_Float_CKKS.py", line 60, in <module>
    ptxt_x = HE.encodeFrac(arr_x)   # Creates a PyPtxt plaintext with the encoded arr_x
  File "Pyfhel/Pyfhel.pyx", line 742, in Pyfhel.Pyfhel.Pyfhel.encodeFrac
ValueError: Buffer has wrong number of dimensions (expected 1, got 2)

Setup:

  • OS: Ubuntu
  • Python: 3.9.2
  • C compiler version: GCC 10.2.1 20210110
  • Pyfhel Version: most-recent
@elyasgoli elyasgoli added the bug label Sep 1, 2023
@ShokofehVS
Copy link

Hi @elyasgoli, I just want to add that there is a nice example of how encrypting and performing simple arithmetic operations over 2-D matrices in this issue.

@elyasgoli
Copy link
Author

elyasgoli commented Sep 1, 2023 via email

@AlexanderViand-Intel
Copy link

You virtually always want to flatten images before encryption, as FHE ciphertexts are effectively vectors and FHE offers SIMD operations over vectors. For advanced use cases, more complex patterns might be beneficial, but expressing your FHE computation as a vectorized computation is a good start for most applications.

@ibarrond ibarrond changed the title [up to 10 words short bug description]: [one-line error message] Encrypting and operating with 2D numpy arrays (images) Sep 2, 2023
@ibarrond ibarrond added HowTo How to accomplish something with Pyfhel. Candidate to a demo/example. and removed bug labels Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HowTo How to accomplish something with Pyfhel. Candidate to a demo/example.
Projects
None yet
Development

No branches or pull requests

4 participants