OpenMined / TenSEAL

A library for doing homomorphic encryption operations on tensors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Windows 10 + python 3.8 ----- AttributeError: module 'tenseal' has no attribute 'Context'

OlivierSpinnler opened this issue · comments

Description

A clear and concise description of the bug.

How to Reproduce

import tenseal as ts

context = ts.Context(
ts.SCHEME_TYPE.CKKS,
poly_modulus_degree=8192,
coeff_mod_bit_sizes=[60, 40, 40, 60]
)
context.generate_galois_keys()
context.global_scale = 2**40

v1 = [0, 1, 2, 3, 4]
v2 = [4, 3, 2, 1, 0]

enc_v1 = ts.ckks_vector(context, v1)
enc_v2 = ts.ckks_vector(context, v2)

result = enc_v1 + enc_v2
result.decrypt() # ~ [4, 4, 4, 4, 4]

result = enc_v1.dot(enc_v2)
result.decrypt() # ~ [10]

matrix = [
[73, 0.5, 8],
[81, -5, 66],
[-100, -78, -2],
[0, 9, 17],
[69, 11, 10],
]
result = enc_v1.matmul(matrix)
result.decrypt() # ~ [157, -90, 153]

Error


AttributeError Traceback (most recent call last)
Cell In[25], line 16
13 v2 = [4, 3, 2, 1, 0]
15 # encrypted vectors
---> 16 enc_v1 = ts.ckks_vector(context, v1)
17 enc_v2 = ts.ckks_vector(context, v2)
19 result = enc_v1 + enc_v2

AttributeError: module 'tenseal' has no attribute 'Context'

Expected Behavior

Code should run because from tenSEAL's README (https://github.com/OpenMined/TenSEAL/blob/13486592953f82ca60502fd196016f815891e25a/README.md#tutorials)

Screenshots

If applicable, add screenshots to help explain your problem.

System Information

  • OS: Windows 10.
  • OS Version: latest at this date.
  • Language Version: Python 3.10.14
  • Package Manager Version: Conda + pip

Additional Context

Screenshot below:
afbeelding

restarted computer and it worked!