· 6 years ago · Apr 24, 2019, 08:40 AM
1============================= test session starts ==============================
2platform linux -- Python 3.6.7, pytest-4.4.1, py-1.8.0, pluggy-0.9.0 -- /home/joinu/venvs/nucypher/bin/python
3cachedir: .pytest_cache
4rootdir: /home/joinu/IdeaProjects/nufhe
5plugins: ethereum-0.1.3a6
6collecting ... collected 183 items / 64 deselected / 119 selected
7
8test/test_api_high_level.py::test_context[make keys separately] FAILED [ 0%]
9test/test_api_high_level.py::test_context[make_key_pair] FAILED [ 1%]
10test/test_api_high_level.py::test_serialize_secret_key[to_file] PASSED [ 2%]
11test/test_api_high_level.py::test_serialize_cloud_key[to_file] PASSED [ 3%]
12test/test_api_high_level.py::test_serialize_ciphertext[to_file] PASSED [ 4%]
13test/test_api_high_level.py::test_serialize_secret_key[to_string] PASSED [ 5%]
14test/test_api_high_level.py::test_serialize_cloud_key[to_string] PASSED [ 5%]
15test/test_api_high_level.py::test_serialize_ciphertext[to_string] PASSED [ 6%]
16test/test_api_high_level.py::test_rngs[DeterministicRNG] FAILED [ 7%]
17test/test_api_high_level.py::test_rngs[SecureRNG] FAILED [ 8%]
18test/test_api_low_level.py::test_serialize_secret_key[to_file-ocl:0:0] PASSED [ 9%]
19test/test_api_low_level.py::test_serialize_cloud_key[to_file-ocl:0:0] PASSED [ 10%]
20test/test_api_low_level.py::test_serialize_ciphertext[to_file-ocl:0:0] PASSED [ 10%]
21test/test_api_low_level.py::test_serialize_secret_key[to_string-ocl:0:0] PASSED [ 11%]
22test/test_api_low_level.py::test_serialize_cloud_key[to_string-ocl:0:0] PASSED [ 12%]
23test/test_api_low_level.py::test_serialize_ciphertext[to_string-ocl:0:0] PASSED [ 13%]
24test/test_gates.py::test_transform_type[ocl:0:0-NTT] FAILED [ 14%]
25test/test_gates.py::test_transform_type[ocl:0:0-FFT] PASSED [ 15%]
26test/test_gates.py::test_tlwe_mask_size[ocl:0:0-mask_size=1] FAILED [ 15%]
27test/test_gates.py::test_tlwe_mask_size[ocl:0:0-mask_size=2] FAILED [ 16%]
28test/test_gates.py::test_single_kernel_bs_with_ks[bs_loop-ocl:0:0] FAILED [ 17%]
29test/test_gates.py::test_single_kernel_bs[bs_loop-ocl:0:0] FAILED [ 18%]
30test/test_gates.py::test_gate_over_view[bs_loop-ocl:0:0] FAILED [ 19%]
31test/test_gates.py::test_single_kernel_bs_with_ks[bs_kernel-ocl:0:0] SKIPPED [ 20%]
32test/test_gates.py::test_single_kernel_bs[bs_kernel-ocl:0:0] SKIPPED [ 21%]
33test/test_gates.py::test_gate_over_view[bs_kernel-ocl:0:0] SKIPPED [ 21%]
34test/test_gates.py::test_nand_gate[ocl:0:0] FAILED [ 22%]
35test/test_gates.py::test_or_gate[ocl:0:0] FAILED [ 23%]
36test/test_gates.py::test_and_gate[ocl:0:0] FAILED [ 24%]
37test/test_gates.py::test_xor_gate[ocl:0:0] FAILED [ 25%]
38test/test_gates.py::test_xnor_gate[ocl:0:0] FAILED [ 26%]
39test/test_gates.py::test_not_gate[ocl:0:0] PASSED [ 26%]
40test/test_gates.py::test_copy_gate[ocl:0:0] PASSED [ 27%]
41test/test_gates.py::test_nor_gate[ocl:0:0] FAILED [ 28%]
42test/test_gates.py::test_andny_gate[ocl:0:0] FAILED [ 29%]
43test/test_gates.py::test_andyn_gate[ocl:0:0] FAILED [ 30%]
44test/test_gates.py::test_orny_gate[ocl:0:0] FAILED [ 31%]
45test/test_gates.py::test_oryn_gate[ocl:0:0] FAILED [ 31%]
46test/test_gates.py::test_mux_gate[ocl:0:0] FAILED [ 32%]
47test/test_gates.py::test_constant_gate[ocl:0:0] PASSED [ 33%]
48test/test_gates.py::test_uint_min[ocl:0:0] FAILED [ 34%]
49test/test_lwe.py::test_lwe_keyswitch[ocl:0:0] PASSED [ 35%]
50test/test_lwe.py::test_make_lwe_keyswitch_key[ocl:0:0] PASSED [ 36%]
51test/test_lwe.py::test_lwe_encrypt[ocl:0:0] PASSED [ 36%]
52test/test_lwe.py::test_lwe_decrypt[ocl:0:0] PASSED [ 37%]
53test/test_lwe.py::test_lwe_linear[ocl:0:0-replace_result-p<0] PASSED [ 38%]
54test/test_lwe.py::test_lwe_linear[ocl:0:0-replace_result-p>0] PASSED [ 39%]
55test/test_lwe.py::test_lwe_linear[ocl:0:0-update_result-p<0] PASSED [ 40%]
56test/test_lwe.py::test_lwe_linear[ocl:0:0-update_result-p>0] PASSED [ 41%]
57test/test_lwe.py::test_lwe_linear_broadcast[ocl:0:0] PASSED [ 42%]
58test/test_lwe.py::test_lwe_noiseless_trivial_constant[ocl:0:0] PASSED [ 42%]
59test/test_lwe.py::test_lwe_noiseless_trivial[ocl:0:0] PASSED [ 43%]
60test/test_lwe.py::test_lwe_noiseless_trivial_broadcast[ocl:0:0-0] PASSED [ 44%]
61test/test_lwe.py::test_lwe_noiseless_trivial_broadcast[ocl:0:0-1] PASSED [ 45%]
62test/test_numeric_functions.py::test_t32_to_phase[ocl:0:0] PASSED [ 46%]
63test/test_polynomials.py::test_shift_torus_polynomial[ocl:0:0-minus_one] PASSED [ 47%]
64test/test_polynomials.py::test_shift_torus_polynomial[ocl:0:0-invert_powers] PASSED [ 47%]
65test/test_polynomials.py::test_shift_torus_polynomial[ocl:0:0-powers_view] PASSED [ 48%]
66test/test_tgsw.py::test_tgsw_polynomial_decomp_trf[ocl:0:0] PASSED [ 49%]
67test/test_tgsw.py::test_tlwe_transformed_add_mul_to_trf[ocl:0:0] PASSED [ 50%]
68test/test_tgsw.py::test_tgsw_transformed_external_mul[ocl:0:0] FAILED [ 51%]
69test/test_tgsw.py::test_tgsw_add_message[ocl:0:0] PASSED [ 52%]
70test/test_tlwe.py::test_tlwe_noiseless_trivial[ocl:0:0] PASSED [ 52%]
71test/test_tlwe.py::test_tlwe_extract_lwe_samples[ocl:0:0] PASSED [ 53%]
72test/test_tlwe.py::test_tlwe_encrypt_zero[ocl:0:0] PASSED [ 54%]
73test/test_transform/test_arithmetic.py::test_add[c-ocl:0:0] PASSED [ 55%]
74test/test_transform/test_arithmetic.py::test_add[cuda_asm-ocl:0:0] SKIPPED [ 56%]
75test/test_transform/test_arithmetic.py::test_add[c_from_asm-ocl:0:0] PASSED [ 57%]
76test/test_transform/test_arithmetic.py::test_sub[c-ocl:0:0] PASSED [ 57%]
77test/test_transform/test_arithmetic.py::test_sub[cuda_asm-ocl:0:0] SKIPPED [ 58%]
78test/test_transform/test_arithmetic.py::test_sub[c_from_asm-ocl:0:0] PASSED [ 59%]
79test/test_transform/test_arithmetic.py::test_mod[c-ocl:0:0] PASSED [ 60%]
80test/test_transform/test_arithmetic.py::test_mod[cuda_asm-ocl:0:0] SKIPPED [ 61%]
81test/test_transform/test_arithmetic.py::test_mod[c_from_asm-ocl:0:0] PASSED [ 62%]
82test/test_transform/test_arithmetic.py::test_mul[c-ocl:0:0] PASSED [ 63%]
83test/test_transform/test_arithmetic.py::test_mul[cuda_asm-ocl:0:0] SKIPPED [ 63%]
84test/test_transform/test_arithmetic.py::test_mul[c_from_asm-ocl:0:0] PASSED [ 64%]
85test/test_transform/test_arithmetic.py::test_pow[ocl:0:0] PASSED [ 65%]
86test/test_transform/test_arithmetic.py::test_inv_pow2[ocl:0:0] PASSED [ 66%]
87test/test_transform/test_arithmetic.py::test_lsh[c-ocl:0:0-32] PASSED [ 67%]
88test/test_transform/test_arithmetic.py::test_lsh[c-ocl:0:0-64] PASSED [ 68%]
89test/test_transform/test_arithmetic.py::test_lsh[c-ocl:0:0-96] PASSED [ 68%]
90test/test_transform/test_arithmetic.py::test_lsh[c-ocl:0:0-128] PASSED [ 69%]
91test/test_transform/test_arithmetic.py::test_lsh[c-ocl:0:0-160] PASSED [ 70%]
92test/test_transform/test_arithmetic.py::test_lsh[c-ocl:0:0-192] PASSED [ 71%]
93test/test_transform/test_arithmetic.py::test_lsh[cuda_asm-ocl:0:0-32] SKIPPED [ 72%]
94test/test_transform/test_arithmetic.py::test_lsh[cuda_asm-ocl:0:0-64] SKIPPED [ 73%]
95test/test_transform/test_arithmetic.py::test_lsh[cuda_asm-ocl:0:0-96] SKIPPED [ 73%]
96test/test_transform/test_arithmetic.py::test_lsh[cuda_asm-ocl:0:0-128] SKIPPED [ 74%]
97test/test_transform/test_arithmetic.py::test_lsh[cuda_asm-ocl:0:0-160] SKIPPED [ 75%]
98test/test_transform/test_arithmetic.py::test_lsh[cuda_asm-ocl:0:0-192] SKIPPED [ 76%]
99test/test_transform/test_arithmetic.py::test_lsh[c_from_asm-ocl:0:0-32] PASSED [ 77%]
100test/test_transform/test_arithmetic.py::test_lsh[c_from_asm-ocl:0:0-64] PASSED [ 78%]
101test/test_transform/test_arithmetic.py::test_lsh[c_from_asm-ocl:0:0-96] PASSED [ 78%]
102test/test_transform/test_arithmetic.py::test_lsh[c_from_asm-ocl:0:0-128] PASSED [ 79%]
103test/test_transform/test_arithmetic.py::test_lsh[c_from_asm-ocl:0:0-160] PASSED [ 80%]
104test/test_transform/test_arithmetic.py::test_lsh[c_from_asm-ocl:0:0-192] PASSED [ 81%]
105test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-global_mem-no_conversion-forward] PASSED [ 82%]
106test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-global_mem-no_conversion-inverse] PASSED [ 83%]
107test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-global_mem-poly_conversion-forward] PASSED [ 84%]
108test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-global_mem-poly_conversion-inverse] PASSED [ 84%]
109test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-constant_mem-no_conversion-forward] PASSED [ 85%]
110test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-constant_mem-no_conversion-inverse] PASSED [ 86%]
111test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-constant_mem-poly_conversion-forward] PASSED [ 87%]
112test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-NTT-constant_mem-poly_conversion-inverse] PASSED [ 88%]
113test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-global_mem-no_conversion-forward] PASSED [ 89%]
114test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-global_mem-no_conversion-inverse] PASSED [ 89%]
115test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-global_mem-poly_conversion-forward] PASSED [ 90%]
116test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-global_mem-poly_conversion-inverse] PASSED [ 91%]
117test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-constant_mem-no_conversion-forward] PASSED [ 92%]
118test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-constant_mem-no_conversion-inverse] PASSED [ 93%]
119test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-constant_mem-poly_conversion-forward] PASSED [ 94%]
120test/test_transform/test_computation.py::test_transform_correctness[ocl:0:0-FFT-constant_mem-poly_conversion-inverse] PASSED [ 94%]
121test/test_transform/test_computation.py::test_polynomial_multiplication[ocl:0:0-NTT] PASSED [ 95%]
122test/test_transform/test_computation.py::test_polynomial_multiplication[ocl:0:0-FFT] PASSED [ 96%]
123test/test_transform/test_ntt_cpu.py::test_ntt PASSED [ 97%]
124test/test_transform/test_ntt_cpu.py::test_find_generator PASSED [ 98%]
125test/test_transform/test_ntt_cpu.py::test_repr PASSED [ 99%]
126test/test_transform/test_ntt_cpu.py::test_gnum_to_i32 PASSED [100%]
127
128=================================== FAILURES ===================================
129______________________ test_context[make keys separately] ______________________
130
131make_pair = False
132
133 @pytest.mark.parametrize('make_pair', [False, True], ids=["make keys separately", "make_key_pair"])
134 def test_context(make_pair):
135
136 size = 32
137 bits1 = [random.choice([False, True]) for i in range(size)]
138 bits2 = [random.choice([False, True]) for i in range(size)]
139 reference = [not (b1 and b2) for b1, b2 in zip(bits1, bits2)]
140
141 ctx = nufhe.Context()
142
143 if make_pair:
144 secret_key, cloud_key = ctx.make_key_pair()
145 else:
146 secret_key = ctx.make_secret_key()
147 cloud_key = ctx.make_cloud_key(secret_key)
148
149 ciphertext1 = ctx.encrypt(secret_key, bits1)
150 ciphertext2 = ctx.encrypt(secret_key, bits2)
151
152 vm = ctx.make_virtual_machine(cloud_key)
153 result = vm.gate_nand(ciphertext1, ciphertext2)
154 result_bits = ctx.decrypt(secret_key, result)
155
156> assert all(result_bits == reference)
157E AssertionError: assert False
158E + where False = all(array([False,...False, False]) == [False, True, ...e, False, ...]
159E -array([False, True, False, False, True, True, False, True, True,\n
160E - True, True, True, False, True, False, True, True, True,\n
161E - False, False, True, False, False, True, False, False, False,\n
162E - True, False, False, False, False])
163E +[False, True, False, False, False, False, False, False, False, True, True, False, True, True, True, True, True, True, True, False, True, True, False, False, True, False, False, False, True, False, True, False]
164E Full diff:
165E - array([False, True, False, False, True, True, False, True, True,...
166E
167E ...Full output truncated (36 lines hidden), use '-vv' to show)
168
169test/test_api_high_level.py:50: AssertionError
170_________________________ test_context[make_key_pair] __________________________
171
172make_pair = True
173
174 @pytest.mark.parametrize('make_pair', [False, True], ids=["make keys separately", "make_key_pair"])
175 def test_context(make_pair):
176
177 size = 32
178 bits1 = [random.choice([False, True]) for i in range(size)]
179 bits2 = [random.choice([False, True]) for i in range(size)]
180 reference = [not (b1 and b2) for b1, b2 in zip(bits1, bits2)]
181
182 ctx = nufhe.Context()
183
184 if make_pair:
185 secret_key, cloud_key = ctx.make_key_pair()
186 else:
187 secret_key = ctx.make_secret_key()
188 cloud_key = ctx.make_cloud_key(secret_key)
189
190 ciphertext1 = ctx.encrypt(secret_key, bits1)
191 ciphertext2 = ctx.encrypt(secret_key, bits2)
192
193 vm = ctx.make_virtual_machine(cloud_key)
194 result = vm.gate_nand(ciphertext1, ciphertext2)
195 result_bits = ctx.decrypt(secret_key, result)
196
197> assert all(result_bits == reference)
198E AssertionError: assert False
199E + where False = all(array([False,...False, False]) == [True, True, T...se, True, ...]
200E -array([False, True, True, True, True, False, True, True, False,\n
201E - True, True, True, True, False, False, False, False, False,\n
202E - True, True, False, False, False, True, False, False, False,\n
203E - True, False, True, False, False])
204E +[True, True, True, False, False, True, True, False, True, True, True, True, True, True, False, True, True, True, True, False, True, False, False, False, True, False, True, True, False, True, True, False]
205E Full diff:
206E - array([False, True, True, True, True, False, True, True, False,...
207E
208E ...Full output truncated (36 lines hidden), use '-vv' to show)
209
210test/test_api_high_level.py:50: AssertionError
211_________________________ test_rngs[DeterministicRNG] __________________________
212
213rng_cls = <class 'nufhe.random_numbers.DeterministicRNG'>
214
215 @pytest.mark.parametrize('rng_cls', [nufhe.DeterministicRNG, nufhe.SecureRNG])
216 def test_rngs(rng_cls):
217
218 size = 32
219 bits1 = [random.choice([False, True]) for i in range(size)]
220 bits2 = [random.choice([False, True]) for i in range(size)]
221 reference = [not (b1 and b2) for b1, b2 in zip(bits1, bits2)]
222
223 rng = rng_cls()
224 ctx = nufhe.Context(rng=rng)
225 secret_key, cloud_key = ctx.make_key_pair()
226
227 ciphertext1 = ctx.encrypt(secret_key, bits1)
228 ciphertext2 = ctx.encrypt(secret_key, bits2)
229
230 vm = ctx.make_virtual_machine(cloud_key)
231 result = vm.gate_nand(ciphertext1, ciphertext2)
232 result_bits = ctx.decrypt(secret_key, result)
233
234> assert all(result_bits == reference)
235E AssertionError: assert False
236E + where False = all(array([ True,...False, True]) == [True, True, T...ue, True, ...]
237E -array([ True, True, False, True, False, False, False, False, False,\n
238E - True, False, True, True, True, True, False, True, True,\n
239E - True, False, False, False, True, False, False, True, False,\n
240E - True, False, False, False, True])
241E +[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True, True, True, True, True, False, True, True, True, True, True, True]
242E Full diff:
243E - array([ True, True, False, True, False, False, False, False, False,...
244E
245E ...Full output truncated (36 lines hidden), use '-vv' to show)
246
247test/test_api_high_level.py:132: AssertionError
248_____________________________ test_rngs[SecureRNG] _____________________________
249
250rng_cls = <class 'nufhe.random_numbers.SecureRNG'>
251
252 @pytest.mark.parametrize('rng_cls', [nufhe.DeterministicRNG, nufhe.SecureRNG])
253 def test_rngs(rng_cls):
254
255 size = 32
256 bits1 = [random.choice([False, True]) for i in range(size)]
257 bits2 = [random.choice([False, True]) for i in range(size)]
258 reference = [not (b1 and b2) for b1, b2 in zip(bits1, bits2)]
259
260 rng = rng_cls()
261 ctx = nufhe.Context(rng=rng)
262 secret_key, cloud_key = ctx.make_key_pair()
263
264 ciphertext1 = ctx.encrypt(secret_key, bits1)
265 ciphertext2 = ctx.encrypt(secret_key, bits2)
266
267 vm = ctx.make_virtual_machine(cloud_key)
268 result = vm.gate_nand(ciphertext1, ciphertext2)
269 result_bits = ctx.decrypt(secret_key, result)
270
271> assert all(result_bits == reference)
272E AssertionError: assert False
273E + where False = all(array([ True,... True, True]) == [False, True, ...ue, True, ...]
274E -array([ True, True, True, True, True, False, False, True, True,\n
275E - False, False, False, False, False, False, True, True, True,\n
276E - False, True, True, True, False, True, True, True, True,\n
277E - False, False, True, True, True])
278E +[False, True, True, False, True, True, True, True, True, True, True, True, True, False, False, True, False, True, True, True, True, True, False, True, False, True, True, False, True, True, False, True]
279E Full diff:
280E - array([ True, True, True, True, True, False, False, True, True,...
281E
282E ...Full output truncated (36 lines hidden), use '-vv' to show)
283
284test/test_api_high_level.py:132: AssertionError
285_______________________ test_transform_type[ocl:0:0-NTT] _______________________
286
287thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
288transform_type = 'NTT'
289
290 def test_transform_type(thread, transform_type):
291 if not transform_supported(thread.device_params, transform_type):
292 pytest.skip()
293 rng = DeterministicRNG()
294 key_pair = make_key_pair(thread, rng, transform_type=transform_type)
295> check_gate(thread, key_pair, 2, gate_nand, nand_ref)
296
297test/test_gates.py:93:
298_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
299
300thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
301key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850e1d86a0>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850e1d8908>)
302num_arguments = 2, nufhe_func = <function gate_nand at 0x7f850fbd19d8>
303reference_func = <function nand_ref at 0x7f850fa7ebf8>, shape = (32,)
304performance_test = False
305perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e1d83c8>
306
307 def check_gate(
308 thread, key_pair, num_arguments, nufhe_func, reference_func,
309 shape=32, performance_test=False, perf_params=None):
310
311 if not isinstance(shape, tuple):
312 shape = (shape,)
313
314 secret_key, cloud_key = key_pair
315
316 if perf_params is None:
317 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
318
319 rng = DeterministicRNG()
320
321 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
322 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
323
324 reference = reference_func(*plaintexts)
325
326 params = cloud_key.params
327 answer = empty_ciphertext(thread, params, shape)
328
329 if performance_test:
330
331 # warm-up
332 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
333 thread.synchronize()
334
335 # test
336 times = []
337 for i in range(10):
338 t_start = time.time()
339 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
340 thread.synchronize()
341 times.append(time.time() - t_start)
342 times = numpy.array(times)
343
344 else:
345 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
346 times = None
347
348 answer_bits = decrypt(thread, secret_key, answer)
349
350> assert (answer_bits == reference).all()
351E AssertionError: assert False
352E + where False = <built-in method all of numpy.ndarray object at 0x7f850e0c0f80>()
353E + where <built-in method all of numpy.ndarray object at 0x7f850e0c0f80> = array([False,... True, True]) == array([ True, ... True, True])
354E -array([False, False, True, True, False, True, False, True, False,\n
355E - True, False, False, True, False, True, True, False, True,\n
356E - True, False, True, False, False, True, True, False, False,\n
357E - True, False, False, True, True])
358E +array([ True, True, True, True, True, True, True, True, True,\n
359E + True, True, True, True, False, True, True, True, True,\n
360E + True, True, True, True, True, True, True, False, True,\n...
361E
362E ...Full output truncated (11 lines hidden), use '-vv' to show.all
363
364test/test_gates.py:83: AssertionError
365___________________ test_tlwe_mask_size[ocl:0:0-mask_size=1] ___________________
366
367thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>, tlwe_mask_size = 1
368
369 @pytest.mark.parametrize('tlwe_mask_size', [1, 2], ids=['mask_size=1', 'mask_size=2'])
370 def test_tlwe_mask_size(thread, tlwe_mask_size):
371 rng = DeterministicRNG()
372 secret_key, cloud_key = make_key_pair(thread, rng, tlwe_mask_size=tlwe_mask_size)
373> check_gate(thread, (secret_key, cloud_key), 2, gate_nand, nand_ref)
374
375test/test_gates.py:100:
376_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
377
378thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
379key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f853407ac50>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f85340845c0>)
380num_arguments = 2, nufhe_func = <function gate_nand at 0x7f850fbd19d8>
381reference_func = <function nand_ref at 0x7f850fa7ebf8>, shape = (32,)
382performance_test = False
383perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f853407a518>
384
385 def check_gate(
386 thread, key_pair, num_arguments, nufhe_func, reference_func,
387 shape=32, performance_test=False, perf_params=None):
388
389 if not isinstance(shape, tuple):
390 shape = (shape,)
391
392 secret_key, cloud_key = key_pair
393
394 if perf_params is None:
395 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
396
397 rng = DeterministicRNG()
398
399 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
400 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
401
402 reference = reference_func(*plaintexts)
403
404 params = cloud_key.params
405 answer = empty_ciphertext(thread, params, shape)
406
407 if performance_test:
408
409 # warm-up
410 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
411 thread.synchronize()
412
413 # test
414 times = []
415 for i in range(10):
416 t_start = time.time()
417 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
418 thread.synchronize()
419 times.append(time.time() - t_start)
420 times = numpy.array(times)
421
422 else:
423 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
424 times = None
425
426 answer_bits = decrypt(thread, secret_key, answer)
427
428> assert (answer_bits == reference).all()
429E AssertionError: assert False
430E + where False = <built-in method all of numpy.ndarray object at 0x7f850e02a710>()
431E + where <built-in method all of numpy.ndarray object at 0x7f850e02a710> = array([ True,... True, True]) == array([ True, ... True, True])
432E -array([ True, True, True, False, True, False, True, True, False,\n
433E - True, False, True, True, False, True, False, False, False,\n
434E - True, False, True, True, True, False, False, False, True,\n
435E - False, True, False, True, True])
436E +array([ True, True, True, False, True, True, True, True, False,\n
437E + True, True, False, False, True, True, False, False, True,\n
438E + True, False, False, True, True, True, True, True, True,\n...
439E
440E ...Full output truncated (10 lines hidden), use '-vv' to show.all
441
442test/test_gates.py:83: AssertionError
443___________________ test_tlwe_mask_size[ocl:0:0-mask_size=2] ___________________
444
445thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>, tlwe_mask_size = 2
446
447 @pytest.mark.parametrize('tlwe_mask_size', [1, 2], ids=['mask_size=1', 'mask_size=2'])
448 def test_tlwe_mask_size(thread, tlwe_mask_size):
449 rng = DeterministicRNG()
450 secret_key, cloud_key = make_key_pair(thread, rng, tlwe_mask_size=tlwe_mask_size)
451> check_gate(thread, (secret_key, cloud_key), 2, gate_nand, nand_ref)
452
453test/test_gates.py:100:
454_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
455
456thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
457key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850e0337f0>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2cff60>)
458num_arguments = 2, nufhe_func = <function gate_nand at 0x7f850fbd19d8>
459reference_func = <function nand_ref at 0x7f850fa7ebf8>, shape = (32,)
460performance_test = False
461perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e0630b8>
462
463 def check_gate(
464 thread, key_pair, num_arguments, nufhe_func, reference_func,
465 shape=32, performance_test=False, perf_params=None):
466
467 if not isinstance(shape, tuple):
468 shape = (shape,)
469
470 secret_key, cloud_key = key_pair
471
472 if perf_params is None:
473 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
474
475 rng = DeterministicRNG()
476
477 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
478 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
479
480 reference = reference_func(*plaintexts)
481
482 params = cloud_key.params
483 answer = empty_ciphertext(thread, params, shape)
484
485 if performance_test:
486
487 # warm-up
488 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
489 thread.synchronize()
490
491 # test
492 times = []
493 for i in range(10):
494 t_start = time.time()
495 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
496 thread.synchronize()
497 times.append(time.time() - t_start)
498 times = numpy.array(times)
499
500 else:
501 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
502 times = None
503
504 answer_bits = decrypt(thread, secret_key, answer)
505
506> assert (answer_bits == reference).all()
507E AssertionError: assert False
508E + where False = <built-in method all of numpy.ndarray object at 0x7f850e02ed50>()
509E + where <built-in method all of numpy.ndarray object at 0x7f850e02ed50> = array([False,...False, False]) == array([ True, ... True, True])
510E -array([False, True, True, True, False, True, False, False, False,\n
511E - False, True, False, False, False, False, True, True, True,\n
512E - False, True, True, True, True, True, False, False, False,\n
513E - True, True, False, False, False])
514E +array([ True, True, True, False, True, True, True, True, True,\n
515E + True, False, True, False, True, True, True, False, True,\n
516E + False, True, True, True, True, True, False, True, True,\n...
517E
518E ...Full output truncated (13 lines hidden), use '-vv' to show.all
519
520test/test_gates.py:83: AssertionError
521________________ test_single_kernel_bs_with_ks[bs_loop-ocl:0:0] ________________
522
523thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
524key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
525single_kernel_bootstrap = False
526
527 def test_single_kernel_bs_with_ks(thread, key_pair, single_kernel_bootstrap):
528 # Test a gate that employs a bootstrap with keyswitch
529 secret_key, cloud_key = key_pair
530
531 if (single_kernel_bootstrap
532 and not single_kernel_bootstrap_supported(secret_key.params, thread.device_params)):
533 pytest.skip()
534
535 perf_params = PerformanceParameters(
536 secret_key.params, single_kernel_bootstrap=single_kernel_bootstrap)
537 perf_params = perf_params.for_device(thread.device_params)
538> check_gate(thread, key_pair, 2, gate_nand, nand_ref, perf_params=perf_params)
539
540test/test_gates.py:114:
541_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
542
543thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
544key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
545num_arguments = 2, nufhe_func = <function gate_nand at 0x7f850fbd19d8>
546reference_func = <function nand_ref at 0x7f850fa7ebf8>, shape = (32,)
547performance_test = False
548perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e033c50>
549
550 def check_gate(
551 thread, key_pair, num_arguments, nufhe_func, reference_func,
552 shape=32, performance_test=False, perf_params=None):
553
554 if not isinstance(shape, tuple):
555 shape = (shape,)
556
557 secret_key, cloud_key = key_pair
558
559 if perf_params is None:
560 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
561
562 rng = DeterministicRNG()
563
564 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
565 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
566
567 reference = reference_func(*plaintexts)
568
569 params = cloud_key.params
570 answer = empty_ciphertext(thread, params, shape)
571
572 if performance_test:
573
574 # warm-up
575 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
576 thread.synchronize()
577
578 # test
579 times = []
580 for i in range(10):
581 t_start = time.time()
582 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
583 thread.synchronize()
584 times.append(time.time() - t_start)
585 times = numpy.array(times)
586
587 else:
588 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
589 times = None
590
591 answer_bits = decrypt(thread, secret_key, answer)
592
593> assert (answer_bits == reference).all()
594E AssertionError: assert False
595E + where False = <built-in method all of numpy.ndarray object at 0x7f850e039c10>()
596E + where <built-in method all of numpy.ndarray object at 0x7f850e039c10> = array([False,...False, False]) == array([False, ... True, True])
597E -array([False, True, True, False, True, True, False, False, False,\n
598E - True, True, False, True, True, True, False, False, False,\n
599E - False, False, False, False, False, True, False, True, True,\n
600E - False, False, True, False, False])
601E +array([False, False, False, True, True, False, False, False, True,\n
602E + True, True, True, False, True, True, False, True, True,\n
603E + True, True, True, False, True, False, True, True, True,\n...
604E
605E ...Full output truncated (13 lines hidden), use '-vv' to show.all
606
607test/test_gates.py:83: AssertionError
608____________________ test_single_kernel_bs[bs_loop-ocl:0:0] ____________________
609
610thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
611key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
612single_kernel_bootstrap = False
613
614 def test_single_kernel_bs(thread, key_pair, single_kernel_bootstrap):
615 # Test a gate that employs separate calls to bootstrap and keyswitch
616 secret_key, cloud_key = key_pair
617
618 if (single_kernel_bootstrap
619 and not single_kernel_bootstrap_supported(secret_key.params, thread.device_params)):
620 pytest.skip()
621
622 perf_params = PerformanceParameters(
623 secret_key.params, single_kernel_bootstrap=single_kernel_bootstrap)
624 perf_params = perf_params.for_device(thread.device_params)
625> check_gate(thread, key_pair, 3, gate_mux, mux_ref, perf_params=perf_params)
626
627test/test_gates.py:128:
628_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
629
630thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
631key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
632num_arguments = 3, nufhe_func = <function gate_mux at 0x7f850fbbb158>
633reference_func = <function mux_ref at 0x7f850e54d2f0>, shape = (32,)
634performance_test = False
635perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e03eb70>
636
637 def check_gate(
638 thread, key_pair, num_arguments, nufhe_func, reference_func,
639 shape=32, performance_test=False, perf_params=None):
640
641 if not isinstance(shape, tuple):
642 shape = (shape,)
643
644 secret_key, cloud_key = key_pair
645
646 if perf_params is None:
647 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
648
649 rng = DeterministicRNG()
650
651 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
652 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
653
654 reference = reference_func(*plaintexts)
655
656 params = cloud_key.params
657 answer = empty_ciphertext(thread, params, shape)
658
659 if performance_test:
660
661 # warm-up
662 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
663 thread.synchronize()
664
665 # test
666 times = []
667 for i in range(10):
668 t_start = time.time()
669 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
670 thread.synchronize()
671 times.append(time.time() - t_start)
672 times = numpy.array(times)
673
674 else:
675 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
676 times = None
677
678 answer_bits = decrypt(thread, secret_key, answer)
679
680> assert (answer_bits == reference).all()
681E AssertionError: assert False
682E + where False = <built-in method all of numpy.ndarray object at 0x7f850df4f490>()
683E + where <built-in method all of numpy.ndarray object at 0x7f850df4f490> = array([ True,...False, False]) == array([ True, ...False, False])
684E -array([ True, False, False, False, False, True, False, True, False,\n
685E - True, False, True, False, True, True, True, True, False,\n
686E - False, False, False, True, True, False, True, False, True,\n
687E - True, True, True, False, False])
688E +array([ True, True, True, False, True, False, True, True, True,\n
689E + False, True, True, False, True, False, True, False, False,\n
690E + True, True, False, True, True, False, False, True, True,\n...
691E
692E ...Full output truncated (10 lines hidden), use '-vv' to show.all
693
694test/test_gates.py:83: AssertionError
695_____________________ test_gate_over_view[bs_loop-ocl:0:0] _____________________
696
697thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
698key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
699single_kernel_bootstrap = False
700
701 def test_gate_over_view(thread, key_pair, single_kernel_bootstrap):
702
703 secret_key, cloud_key = key_pair
704 params = cloud_key.params
705
706 if (single_kernel_bootstrap
707 and not single_kernel_bootstrap_supported(params, thread.device_params)):
708 pytest.skip()
709
710 perf_params = PerformanceParameters(params, single_kernel_bootstrap=single_kernel_bootstrap)
711 perf_params = perf_params.for_device(thread.device_params)
712
713 nufhe_func = gate_nand
714 reference_func = nand_ref
715 num_arguments = 2
716
717 rng = DeterministicRNG()
718
719 shape = (5, 8)
720
721 # FIXME: negative steps are supported as well, but the current stable PyCUDA
722 # has a bug where in that case it calculates strides incorrectly.
723 # It is fixed in the trunk, so we must add some negative steps here as soon as it is released.
724 slices1 = (slice(3, 5), slice(1, 7, 2))
725 slices2 = (slice(1, 3), slice(2, 8, 2))
726 result_slices = (slice(2, 4), slice(0, 6, 2))
727
728 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
729 pt1 = plaintexts[0][slices1]
730 pt2 = plaintexts[1][slices2]
731
732 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
733 ct1 = ciphertexts[0][slices1]
734 ct2 = ciphertexts[1][slices2]
735
736 reference = reference_func(pt1, pt2)
737
738 answer = empty_ciphertext(thread, params, shape)
739 answer_view = answer[result_slices]
740
741 nufhe_func(thread, cloud_key, answer_view, ct1, ct2, perf_params=perf_params)
742
743 answer_bits = decrypt(thread, secret_key, answer)
744 answer_bits_view = answer_bits[result_slices]
745
746> assert (answer_bits_view == reference).all()
747E AssertionError: assert False
748E + where False = <built-in method all of numpy.ndarray object at 0x7f850df4f530>()
749E + where <built-in method all of numpy.ndarray object at 0x7f850df4f530> = array([[False...alse, False]]) == array([[ True,...True, True]])
750E -array([[False, False, False],\n
751E - [False, False, False]])
752E +array([[ True, True, True],\n
753E + [ True, True, True]])
754E Full diff:
755E - array([[False, False, False],
756E - [False, False, False]])...
757E
758E ...Full output truncated (3 lines hidden), use '-vv' to show.all
759
760test/test_gates.py:559: AssertionError
761___________________________ test_nand_gate[ocl:0:0] ____________________________
762
763thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
764key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
765
766 def test_nand_gate(thread, key_pair):
767> check_gate(thread, key_pair, 2, gate_nand, nand_ref)
768
769test/test_gates.py:179:
770_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
771
772thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
773key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
774num_arguments = 2, nufhe_func = <function gate_nand at 0x7f850fbd19d8>
775reference_func = <function nand_ref at 0x7f850fa7ebf8>, shape = (32,)
776performance_test = False
777perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f85340c6f98>
778
779 def check_gate(
780 thread, key_pair, num_arguments, nufhe_func, reference_func,
781 shape=32, performance_test=False, perf_params=None):
782
783 if not isinstance(shape, tuple):
784 shape = (shape,)
785
786 secret_key, cloud_key = key_pair
787
788 if perf_params is None:
789 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
790
791 rng = DeterministicRNG()
792
793 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
794 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
795
796 reference = reference_func(*plaintexts)
797
798 params = cloud_key.params
799 answer = empty_ciphertext(thread, params, shape)
800
801 if performance_test:
802
803 # warm-up
804 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
805 thread.synchronize()
806
807 # test
808 times = []
809 for i in range(10):
810 t_start = time.time()
811 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
812 thread.synchronize()
813 times.append(time.time() - t_start)
814 times = numpy.array(times)
815
816 else:
817 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
818 times = None
819
820 answer_bits = decrypt(thread, secret_key, answer)
821
822> assert (answer_bits == reference).all()
823E AssertionError: assert False
824E + where False = <built-in method all of numpy.ndarray object at 0x7f850df4f800>()
825E + where <built-in method all of numpy.ndarray object at 0x7f850df4f800> = array([ True,... True, True]) == array([ True, ... True, True])
826E -array([ True, True, False, True, False, True, True, False, True,\n
827E - False, False, False, False, False, True, True, True, True,\n
828E - True, True, False, True, False, True, False, False, False,\n
829E - True, True, True, True, True])
830E +array([ True, False, True, True, True, True, True, True, False,\n
831E + True, False, False, True, True, True, True, True, True,\n
832E + True, True, True, True, False, True, False, False, True,\n...
833E
834E ...Full output truncated (10 lines hidden), use '-vv' to show.all
835
836test/test_gates.py:83: AssertionError
837____________________________ test_or_gate[ocl:0:0] _____________________________
838
839thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
840key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
841
842 def test_or_gate(thread, key_pair):
843> check_gate(thread, key_pair, 2, gate_or, or_ref)
844
845test/test_gates.py:183:
846_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
847
848thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
849key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
850num_arguments = 2, nufhe_func = <function gate_or at 0x7f850fbd1a60>
851reference_func = <function or_ref at 0x7f850fa7ec80>, shape = (32,)
852performance_test = False
853perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f85340c6048>
854
855 def check_gate(
856 thread, key_pair, num_arguments, nufhe_func, reference_func,
857 shape=32, performance_test=False, perf_params=None):
858
859 if not isinstance(shape, tuple):
860 shape = (shape,)
861
862 secret_key, cloud_key = key_pair
863
864 if perf_params is None:
865 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
866
867 rng = DeterministicRNG()
868
869 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
870 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
871
872 reference = reference_func(*plaintexts)
873
874 params = cloud_key.params
875 answer = empty_ciphertext(thread, params, shape)
876
877 if performance_test:
878
879 # warm-up
880 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
881 thread.synchronize()
882
883 # test
884 times = []
885 for i in range(10):
886 t_start = time.time()
887 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
888 thread.synchronize()
889 times.append(time.time() - t_start)
890 times = numpy.array(times)
891
892 else:
893 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
894 times = None
895
896 answer_bits = decrypt(thread, secret_key, answer)
897
898> assert (answer_bits == reference).all()
899E AssertionError: assert False
900E + where False = <built-in method all of numpy.ndarray object at 0x7f850e261e40>()
901E + where <built-in method all of numpy.ndarray object at 0x7f850e261e40> = array([ True,... True, False]) == array([False, ... True, True])
902E -array([ True, False, False, True, True, False, True, True, True,\n
903E - False, False, False, True, False, False, False, False, False,\n
904E - False, False, True, False, True, False, True, True, True,\n
905E - False, False, True, True, False])
906E +array([False, False, False, False, True, True, True, False, True,\n
907E + False, True, True, True, False, False, True, True, True,\n
908E + True, True, False, True, False, True, True, False, True,\n...
909E
910E ...Full output truncated (11 lines hidden), use '-vv' to show.all
911
912test/test_gates.py:83: AssertionError
913____________________________ test_and_gate[ocl:0:0] ____________________________
914
915thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
916key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
917
918 def test_and_gate(thread, key_pair):
919> check_gate(thread, key_pair, 2, gate_and, and_ref)
920
921test/test_gates.py:187:
922_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
923
924thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
925key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
926num_arguments = 2, nufhe_func = <function gate_and at 0x7f850fbd1ae8>
927reference_func = <function and_ref at 0x7f850fa7ed08>, shape = (32,)
928performance_test = False
929perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850c2cf278>
930
931 def check_gate(
932 thread, key_pair, num_arguments, nufhe_func, reference_func,
933 shape=32, performance_test=False, perf_params=None):
934
935 if not isinstance(shape, tuple):
936 shape = (shape,)
937
938 secret_key, cloud_key = key_pair
939
940 if perf_params is None:
941 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
942
943 rng = DeterministicRNG()
944
945 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
946 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
947
948 reference = reference_func(*plaintexts)
949
950 params = cloud_key.params
951 answer = empty_ciphertext(thread, params, shape)
952
953 if performance_test:
954
955 # warm-up
956 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
957 thread.synchronize()
958
959 # test
960 times = []
961 for i in range(10):
962 t_start = time.time()
963 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
964 thread.synchronize()
965 times.append(time.time() - t_start)
966 times = numpy.array(times)
967
968 else:
969 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
970 times = None
971
972 answer_bits = decrypt(thread, secret_key, answer)
973
974> assert (answer_bits == reference).all()
975E AssertionError: assert False
976E + where False = <built-in method all of numpy.ndarray object at 0x7f850e1c63a0>()
977E + where <built-in method all of numpy.ndarray object at 0x7f850e1c63a0> = array([ True,... True, True]) == array([ True, ...False, False])
978E -array([ True, False, False, False, False, True, False, True, True,\n
979E - False, True, False, False, False, True, True, False, True,\n
980E - False, True, True, False, False, False, True, True, True,\n
981E - True, False, False, True, True])
982E +array([ True, True, False, True, False, False, True, False, True,\n
983E + False, False, False, False, False, False, False, True, False,\n
984E + False, False, True, True, True, False, False, False, False,\n...
985E
986E ...Full output truncated (13 lines hidden), use '-vv' to show.all
987
988test/test_gates.py:83: AssertionError
989____________________________ test_xor_gate[ocl:0:0] ____________________________
990
991thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
992key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
993
994 def test_xor_gate(thread, key_pair):
995> check_gate(thread, key_pair, 2, gate_xor, xor_ref)
996
997test/test_gates.py:191:
998_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
999
1000thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1001key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1002num_arguments = 2, nufhe_func = <function gate_xor at 0x7f850fbd1b70>
1003reference_func = <function xor_ref at 0x7f850fa7ed90>, shape = (32,)
1004performance_test = False
1005perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f853404abe0>
1006
1007 def check_gate(
1008 thread, key_pair, num_arguments, nufhe_func, reference_func,
1009 shape=32, performance_test=False, perf_params=None):
1010
1011 if not isinstance(shape, tuple):
1012 shape = (shape,)
1013
1014 secret_key, cloud_key = key_pair
1015
1016 if perf_params is None:
1017 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1018
1019 rng = DeterministicRNG()
1020
1021 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1022 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1023
1024 reference = reference_func(*plaintexts)
1025
1026 params = cloud_key.params
1027 answer = empty_ciphertext(thread, params, shape)
1028
1029 if performance_test:
1030
1031 # warm-up
1032 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1033 thread.synchronize()
1034
1035 # test
1036 times = []
1037 for i in range(10):
1038 t_start = time.time()
1039 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1040 thread.synchronize()
1041 times.append(time.time() - t_start)
1042 times = numpy.array(times)
1043
1044 else:
1045 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1046 times = None
1047
1048 answer_bits = decrypt(thread, secret_key, answer)
1049
1050> assert (answer_bits == reference).all()
1051E AssertionError: assert False
1052E + where False = <built-in method all of numpy.ndarray object at 0x7f850e0fc620>()
1053E + where <built-in method all of numpy.ndarray object at 0x7f850e0fc620> = array([False,...False, True]) == array([False, ...False, False])
1054E -array([False, True, False, True, True, False, False, True, False,\n
1055E - False, True, True, True, True, True, True, True, False,\n
1056E - False, False, False, True, True, False, True, True, True,\n
1057E - True, True, True, False, True])
1058E +array([False, False, False, True, False, True, False, True, True,\n
1059E + False, True, False, False, False, False, True, True, False,\n
1060E + True, False, True, True, True, False, False, True, False,\n...
1061E
1062E ...Full output truncated (13 lines hidden), use '-vv' to show.all
1063
1064test/test_gates.py:83: AssertionError
1065___________________________ test_xnor_gate[ocl:0:0] ____________________________
1066
1067thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1068key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1069
1070 def test_xnor_gate(thread, key_pair):
1071> check_gate(thread, key_pair, 2, gate_xnor, xnor_ref)
1072
1073test/test_gates.py:195:
1074_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1075
1076thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1077key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1078num_arguments = 2, nufhe_func = <function gate_xnor at 0x7f850fbd1bf8>
1079reference_func = <function xnor_ref at 0x7f850fa7ee18>, shape = (32,)
1080performance_test = False
1081perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850c31cb00>
1082
1083 def check_gate(
1084 thread, key_pair, num_arguments, nufhe_func, reference_func,
1085 shape=32, performance_test=False, perf_params=None):
1086
1087 if not isinstance(shape, tuple):
1088 shape = (shape,)
1089
1090 secret_key, cloud_key = key_pair
1091
1092 if perf_params is None:
1093 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1094
1095 rng = DeterministicRNG()
1096
1097 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1098 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1099
1100 reference = reference_func(*plaintexts)
1101
1102 params = cloud_key.params
1103 answer = empty_ciphertext(thread, params, shape)
1104
1105 if performance_test:
1106
1107 # warm-up
1108 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1109 thread.synchronize()
1110
1111 # test
1112 times = []
1113 for i in range(10):
1114 t_start = time.time()
1115 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1116 thread.synchronize()
1117 times.append(time.time() - t_start)
1118 times = numpy.array(times)
1119
1120 else:
1121 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1122 times = None
1123
1124 answer_bits = decrypt(thread, secret_key, answer)
1125
1126> assert (answer_bits == reference).all()
1127E AssertionError: assert False
1128E + where False = <built-in method all of numpy.ndarray object at 0x7f850e1821c0>()
1129E + where <built-in method all of numpy.ndarray object at 0x7f850e1821c0> = array([False,...False, False]) == array([ True, ... True, False])
1130E -array([False, True, False, False, False, False, True, False, True,\n
1131E - True, False, True, True, False, False, True, False, False,\n
1132E - False, True, True, False, True, True, False, False, True,\n
1133E - False, False, False, False, False])
1134E +array([ True, True, False, True, False, False, True, False, True,\n
1135E + False, True, False, True, True, False, True, False, True,\n
1136E + False, True, False, False, False, True, False, False, True,\n...
1137E
1138E ...Full output truncated (13 lines hidden), use '-vv' to show.all
1139
1140test/test_gates.py:83: AssertionError
1141____________________________ test_nor_gate[ocl:0:0] ____________________________
1142
1143thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1144key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1145
1146 def test_nor_gate(thread, key_pair):
1147> check_gate(thread, key_pair, 2, gate_nor, nor_ref)
1148
1149test/test_gates.py:207:
1150_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1151
1152thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1153key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1154num_arguments = 2, nufhe_func = <function gate_nor at 0x7f850fbd1e18>
1155reference_func = <function nor_ref at 0x7f850e54d048>, shape = (32,)
1156performance_test = False
1157perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850c2cb7f0>
1158
1159 def check_gate(
1160 thread, key_pair, num_arguments, nufhe_func, reference_func,
1161 shape=32, performance_test=False, perf_params=None):
1162
1163 if not isinstance(shape, tuple):
1164 shape = (shape,)
1165
1166 secret_key, cloud_key = key_pair
1167
1168 if perf_params is None:
1169 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1170
1171 rng = DeterministicRNG()
1172
1173 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1174 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1175
1176 reference = reference_func(*plaintexts)
1177
1178 params = cloud_key.params
1179 answer = empty_ciphertext(thread, params, shape)
1180
1181 if performance_test:
1182
1183 # warm-up
1184 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1185 thread.synchronize()
1186
1187 # test
1188 times = []
1189 for i in range(10):
1190 t_start = time.time()
1191 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1192 thread.synchronize()
1193 times.append(time.time() - t_start)
1194 times = numpy.array(times)
1195
1196 else:
1197 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1198 times = None
1199
1200 answer_bits = decrypt(thread, secret_key, answer)
1201
1202> assert (answer_bits == reference).all()
1203E AssertionError: assert False
1204E + where False = <built-in method all of numpy.ndarray object at 0x7f850e0eb260>()
1205E + where <built-in method all of numpy.ndarray object at 0x7f850e0eb260> = array([False,...False, True]) == array([False, ...False, False])
1206E -array([False, True, False, True, False, False, True, True, True,\n
1207E - False, False, False, False, False, True, True, True, False,\n
1208E - True, True, False, True, True, True, False, False, False,\n
1209E - False, False, False, False, True])
1210E +array([False, False, False, False, True, False, False, True, False,\n
1211E + False, False, False, True, False, True, False, False, True,\n
1212E + False, True, False, False, False, True, False, True, True,\n...
1213E
1214E ...Full output truncated (15 lines hidden), use '-vv' to show.all
1215
1216test/test_gates.py:83: AssertionError
1217___________________________ test_andny_gate[ocl:0:0] ___________________________
1218
1219thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1220key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1221
1222 def test_andny_gate(thread, key_pair):
1223> check_gate(thread, key_pair, 2, gate_andny, andny_ref)
1224
1225test/test_gates.py:211:
1226_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1227
1228thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1229key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1230num_arguments = 2, nufhe_func = <function gate_andny at 0x7f850fbd1ea0>
1231reference_func = <function andny_ref at 0x7f850e54d0d0>, shape = (32,)
1232performance_test = False
1233perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850c2c8400>
1234
1235 def check_gate(
1236 thread, key_pair, num_arguments, nufhe_func, reference_func,
1237 shape=32, performance_test=False, perf_params=None):
1238
1239 if not isinstance(shape, tuple):
1240 shape = (shape,)
1241
1242 secret_key, cloud_key = key_pair
1243
1244 if perf_params is None:
1245 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1246
1247 rng = DeterministicRNG()
1248
1249 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1250 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1251
1252 reference = reference_func(*plaintexts)
1253
1254 params = cloud_key.params
1255 answer = empty_ciphertext(thread, params, shape)
1256
1257 if performance_test:
1258
1259 # warm-up
1260 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1261 thread.synchronize()
1262
1263 # test
1264 times = []
1265 for i in range(10):
1266 t_start = time.time()
1267 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1268 thread.synchronize()
1269 times.append(time.time() - t_start)
1270 times = numpy.array(times)
1271
1272 else:
1273 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1274 times = None
1275
1276 answer_bits = decrypt(thread, secret_key, answer)
1277
1278> assert (answer_bits == reference).all()
1279E AssertionError: assert False
1280E + where False = <built-in method all of numpy.ndarray object at 0x7f850e0ec2b0>()
1281E + where <built-in method all of numpy.ndarray object at 0x7f850e0ec2b0> = array([False,... True, True]) == array([False, ... True, False])
1282E -array([False, False, False, False, False, True, False, False, False,\n
1283E - True, False, True, False, False, False, True, False, True,\n
1284E - True, True, True, True, False, True, True, True, True,\n
1285E - False, True, False, True, True])
1286E +array([False, False, False, False, False, False, True, True, False,\n
1287E + False, False, False, False, False, False, False, False, False,\n
1288E + True, False, True, False, False, False, True, False, False,\n...
1289E
1290E ...Full output truncated (17 lines hidden), use '-vv' to show.all
1291
1292test/test_gates.py:83: AssertionError
1293___________________________ test_andyn_gate[ocl:0:0] ___________________________
1294
1295thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1296key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1297
1298 def test_andyn_gate(thread, key_pair):
1299> check_gate(thread, key_pair, 2, gate_andyn, andyn_ref)
1300
1301test/test_gates.py:215:
1302_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1303
1304thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1305key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1306num_arguments = 2, nufhe_func = <function gate_andyn at 0x7f850fbd1f28>
1307reference_func = <function andyn_ref at 0x7f850e54d158>, shape = (32,)
1308performance_test = False
1309perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e1bfe80>
1310
1311 def check_gate(
1312 thread, key_pair, num_arguments, nufhe_func, reference_func,
1313 shape=32, performance_test=False, perf_params=None):
1314
1315 if not isinstance(shape, tuple):
1316 shape = (shape,)
1317
1318 secret_key, cloud_key = key_pair
1319
1320 if perf_params is None:
1321 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1322
1323 rng = DeterministicRNG()
1324
1325 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1326 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1327
1328 reference = reference_func(*plaintexts)
1329
1330 params = cloud_key.params
1331 answer = empty_ciphertext(thread, params, shape)
1332
1333 if performance_test:
1334
1335 # warm-up
1336 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1337 thread.synchronize()
1338
1339 # test
1340 times = []
1341 for i in range(10):
1342 t_start = time.time()
1343 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1344 thread.synchronize()
1345 times.append(time.time() - t_start)
1346 times = numpy.array(times)
1347
1348 else:
1349 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1350 times = None
1351
1352 answer_bits = decrypt(thread, secret_key, answer)
1353
1354> assert (answer_bits == reference).all()
1355E AssertionError: assert False
1356E + where False = <built-in method all of numpy.ndarray object at 0x7f850e147080>()
1357E + where <built-in method all of numpy.ndarray object at 0x7f850e147080> = array([False,...False, False]) == array([False, ...False, False])
1358E -array([False, True, False, True, True, False, True, False, True,\n
1359E - False, False, True, False, True, True, True, True, False,\n
1360E - True, False, True, True, True, False, False, False, False,\n
1361E - True, True, True, False, False])
1362E +array([False, False, False, True, False, False, False, True, True,\n
1363E + False, False, False, False, False, False, False, False, False,\n
1364E + False, True, True, False, True, False, False, False, False,\n...
1365E
1366E ...Full output truncated (13 lines hidden), use '-vv' to show.all
1367
1368test/test_gates.py:83: AssertionError
1369___________________________ test_orny_gate[ocl:0:0] ____________________________
1370
1371thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1372key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1373
1374 def test_orny_gate(thread, key_pair):
1375> check_gate(thread, key_pair, 2, gate_orny, orny_ref)
1376
1377test/test_gates.py:219:
1378_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1379
1380thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1381key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1382num_arguments = 2, nufhe_func = <function gate_orny at 0x7f850fbbb048>
1383reference_func = <function orny_ref at 0x7f850e54d1e0>, shape = (32,)
1384performance_test = False
1385perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f853409cf28>
1386
1387 def check_gate(
1388 thread, key_pair, num_arguments, nufhe_func, reference_func,
1389 shape=32, performance_test=False, perf_params=None):
1390
1391 if not isinstance(shape, tuple):
1392 shape = (shape,)
1393
1394 secret_key, cloud_key = key_pair
1395
1396 if perf_params is None:
1397 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1398
1399 rng = DeterministicRNG()
1400
1401 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1402 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1403
1404 reference = reference_func(*plaintexts)
1405
1406 params = cloud_key.params
1407 answer = empty_ciphertext(thread, params, shape)
1408
1409 if performance_test:
1410
1411 # warm-up
1412 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1413 thread.synchronize()
1414
1415 # test
1416 times = []
1417 for i in range(10):
1418 t_start = time.time()
1419 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1420 thread.synchronize()
1421 times.append(time.time() - t_start)
1422 times = numpy.array(times)
1423
1424 else:
1425 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1426 times = None
1427
1428 answer_bits = decrypt(thread, secret_key, answer)
1429
1430> assert (answer_bits == reference).all()
1431E AssertionError: assert False
1432E + where False = <built-in method all of numpy.ndarray object at 0x7f850e160300>()
1433E + where <built-in method all of numpy.ndarray object at 0x7f850e160300> = array([False,...False, False]) == array([False, ... True, True])
1434E -array([False, False, True, True, True, True, True, False, True,\n
1435E - True, False, False, False, False, False, True, True, False,\n
1436E - True, True, True, False, False, True, True, True, False,\n
1437E - False, False, True, False, False])
1438E +array([False, True, False, True, True, True, True, True, True,\n
1439E + True, True, True, False, True, True, True, True, True,\n
1440E + True, True, False, True, True, False, True, True, True,\n...
1441E
1442E ...Full output truncated (17 lines hidden), use '-vv' to show.all
1443
1444test/test_gates.py:83: AssertionError
1445___________________________ test_oryn_gate[ocl:0:0] ____________________________
1446
1447thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1448key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1449
1450 def test_oryn_gate(thread, key_pair):
1451> check_gate(thread, key_pair, 2, gate_oryn, oryn_ref)
1452
1453test/test_gates.py:223:
1454_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1455
1456thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1457key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1458num_arguments = 2, nufhe_func = <function gate_oryn at 0x7f850fbbb0d0>
1459reference_func = <function oryn_ref at 0x7f850e54d268>, shape = (32,)
1460performance_test = False
1461perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e1a0198>
1462
1463 def check_gate(
1464 thread, key_pair, num_arguments, nufhe_func, reference_func,
1465 shape=32, performance_test=False, perf_params=None):
1466
1467 if not isinstance(shape, tuple):
1468 shape = (shape,)
1469
1470 secret_key, cloud_key = key_pair
1471
1472 if perf_params is None:
1473 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1474
1475 rng = DeterministicRNG()
1476
1477 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1478 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1479
1480 reference = reference_func(*plaintexts)
1481
1482 params = cloud_key.params
1483 answer = empty_ciphertext(thread, params, shape)
1484
1485 if performance_test:
1486
1487 # warm-up
1488 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1489 thread.synchronize()
1490
1491 # test
1492 times = []
1493 for i in range(10):
1494 t_start = time.time()
1495 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1496 thread.synchronize()
1497 times.append(time.time() - t_start)
1498 times = numpy.array(times)
1499
1500 else:
1501 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1502 times = None
1503
1504 answer_bits = decrypt(thread, secret_key, answer)
1505
1506> assert (answer_bits == reference).all()
1507E AssertionError: assert False
1508E + where False = <built-in method all of numpy.ndarray object at 0x7f850e0ebd50>()
1509E + where <built-in method all of numpy.ndarray object at 0x7f850e0ebd50> = array([False,...False, True]) == array([ True, ... True, False])
1510E -array([False, False, True, False, True, False, False, False, False,\n
1511E - False, False, False, True, True, False, False, True, True,\n
1512E - True, True, True, True, False, False, False, True, False,\n
1513E - False, False, True, False, True])
1514E +array([ True, True, True, True, True, True, True, True, False,\n
1515E + True, True, True, True, True, True, True, True, False,\n
1516E + True, True, True, False, True, True, True, True, False,\n...
1517E
1518E ...Full output truncated (11 lines hidden), use '-vv' to show.all
1519
1520test/test_gates.py:83: AssertionError
1521____________________________ test_mux_gate[ocl:0:0] ____________________________
1522
1523thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1524key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1525
1526 def test_mux_gate(thread, key_pair):
1527> check_gate(thread, key_pair, 3, gate_mux, mux_ref)
1528
1529test/test_gates.py:227:
1530_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1531
1532thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1533key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1534num_arguments = 3, nufhe_func = <function gate_mux at 0x7f850fbbb158>
1535reference_func = <function mux_ref at 0x7f850e54d2f0>, shape = (32,)
1536performance_test = False
1537perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e1ab208>
1538
1539 def check_gate(
1540 thread, key_pair, num_arguments, nufhe_func, reference_func,
1541 shape=32, performance_test=False, perf_params=None):
1542
1543 if not isinstance(shape, tuple):
1544 shape = (shape,)
1545
1546 secret_key, cloud_key = key_pair
1547
1548 if perf_params is None:
1549 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1550
1551 rng = DeterministicRNG()
1552
1553 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1554 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1555
1556 reference = reference_func(*plaintexts)
1557
1558 params = cloud_key.params
1559 answer = empty_ciphertext(thread, params, shape)
1560
1561 if performance_test:
1562
1563 # warm-up
1564 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1565 thread.synchronize()
1566
1567 # test
1568 times = []
1569 for i in range(10):
1570 t_start = time.time()
1571 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1572 thread.synchronize()
1573 times.append(time.time() - t_start)
1574 times = numpy.array(times)
1575
1576 else:
1577 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1578 times = None
1579
1580 answer_bits = decrypt(thread, secret_key, answer)
1581
1582> assert (answer_bits == reference).all()
1583E AssertionError: assert False
1584E + where False = <built-in method all of numpy.ndarray object at 0x7f850e0e7990>()
1585E + where <built-in method all of numpy.ndarray object at 0x7f850e0e7990> = array([ True,... True, True]) == array([ True, ... True, True])
1586E -array([ True, True, True, False, False, False, False, False, False,\n
1587E - True, True, False, False, True, False, True, True, False,\n
1588E - False, False, True, False, True, False, True, False, True,\n
1589E - False, True, False, True, True])
1590E +array([ True, True, True, False, False, True, True, True, True,\n
1591E + True, True, False, False, False, False, True, False, False,\n
1592E + True, True, False, False, True, True, True, False, False,\n...
1593E
1594E ...Full output truncated (15 lines hidden), use '-vv' to show.all
1595
1596test/test_gates.py:83: AssertionError
1597____________________________ test_uint_min[ocl:0:0] ____________________________
1598
1599thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1600key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1601
1602 def test_uint_min(thread, key_pair):
1603> check_gate(thread, key_pair, 2, uint_min, uint_min_ref, shape=(4, 16))
1604
1605test/test_gates.py:249:
1606_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
1607
1608thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1609key_pair = (<nufhe.api_low_level.NuFHESecretKey object at 0x7f850c2dad68>, <nufhe.api_low_level.NuFHECloudKey object at 0x7f850c2da208>)
1610num_arguments = 2, nufhe_func = <function uint_min at 0x7f850fa7e7b8>
1611reference_func = <function uint_min_ref at 0x7f850e54d378>, shape = (4, 16)
1612performance_test = False
1613perf_params = <nufhe.performance.PerformanceParametersForDevice object at 0x7f850e196320>
1614
1615 def check_gate(
1616 thread, key_pair, num_arguments, nufhe_func, reference_func,
1617 shape=32, performance_test=False, perf_params=None):
1618
1619 if not isinstance(shape, tuple):
1620 shape = (shape,)
1621
1622 secret_key, cloud_key = key_pair
1623
1624 if perf_params is None:
1625 perf_params = PerformanceParameters(secret_key.params).for_device(thread.device_params)
1626
1627 rng = DeterministicRNG()
1628
1629 plaintexts = get_plaintexts(rng, num_arguments, shape=shape)
1630 ciphertexts = [encrypt(thread, rng, secret_key, plaintext) for plaintext in plaintexts]
1631
1632 reference = reference_func(*plaintexts)
1633
1634 params = cloud_key.params
1635 answer = empty_ciphertext(thread, params, shape)
1636
1637 if performance_test:
1638
1639 # warm-up
1640 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1641 thread.synchronize()
1642
1643 # test
1644 times = []
1645 for i in range(10):
1646 t_start = time.time()
1647 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1648 thread.synchronize()
1649 times.append(time.time() - t_start)
1650 times = numpy.array(times)
1651
1652 else:
1653 nufhe_func(thread, cloud_key, answer, *ciphertexts, perf_params)
1654 times = None
1655
1656 answer_bits = decrypt(thread, secret_key, answer)
1657
1658> assert (answer_bits == reference).all()
1659E AssertionError: assert False
1660E + where False = <built-in method all of numpy.ndarray object at 0x7f850e02e8f0>()
1661E + where <built-in method all of numpy.ndarray object at 0x7f850e02e8f0> = array([[ True...True, True]]) == array([[ True,...alse, True]])
1662E -array([[ True, True, False, True, False, True, False, False, False,\n
1663E - True, False, False, False, True, True, True],\n
1664E - [ True, False, False, True, False, False, True, True, False,\n
1665E - True, False, False, True, True, True, False],\n
1666E - [ True, False, False, False, True, False, False, False, True,\n
1667E - True, True, True, False, False, False, True],\n
1668E - [ True, True, False, False, False, True, False, False, True,\n...
1669E
1670E ...Full output truncated (37 lines hidden), use '-vv' to show.all
1671
1672test/test_gates.py:83: AssertionError
1673_________________ test_tgsw_transformed_external_mul[ocl:0:0] __________________
1674
1675thread = <reikna.cluda.ocl.Thread object at 0x7f850c2da940>
1676
1677 def test_tgsw_transformed_external_mul(thread):
1678
1679 shape = (2, 3)
1680 params = NuFHEParameters(transform_type='NTT')
1681 perf_params = PerformanceParameters(params).for_device(thread.device_params)
1682 tgsw_params = params.tgsw_params
1683
1684 decomp_length = tgsw_params.decomp_length
1685 mask_size = tgsw_params.tlwe_params.mask_size
1686 polynomial_degree = tgsw_params.tlwe_params.polynomial_degree
1687
1688 transform_type = tgsw_params.tlwe_params.transform_type
1689 transform = get_transform(transform_type)
1690 tlength = transform.transformed_length(polynomial_degree)
1691 tdtype = transform.transformed_dtype()
1692
1693 accum_shape = shape + (mask_size + 1, polynomial_degree)
1694 bk_len = 10
1695 bootstrap_key_shape = (bk_len, mask_size + 1, decomp_length, mask_size + 1, tlength)
1696 bk_row_idx = 2
1697
1698 bootstrap_key = get_test_array(bootstrap_key_shape, 'ff_number')
1699 accum = get_test_array(accum_shape, Torus32, (-1000, 1000))
1700
1701 bootstrap_key_dev = thread.to_device(bootstrap_key)
1702 accum_dev = thread.to_device(accum)
1703 thread.synchronize()
1704
1705 test = TGswTransformedExternalMul(tgsw_params, shape, bk_len, perf_params).compile(thread)
1706 ref = TGswTransformedExternalMulReference(tgsw_params, shape, bk_len, perf_params)
1707
1708 test(accum_dev, bootstrap_key_dev, bk_row_idx)
1709 accum_test = accum_dev.get()
1710
1711 ref(accum, bootstrap_key, bk_row_idx)
1712
1713> assert (accum == accum_test).all()
1714E AssertionError: assert False
1715E + where False = <built-in method all of numpy.ndarray object at 0x7f850e281d50>()
1716E + where <built-in method all of numpy.ndarray object at 0x7f850e281d50> = array([[[[ 6..., dtype=int32) == array([[[[ 60..., dtype=int32)
1717E -array([[[[ 608422728, -205701094, 836500344, ..., 26035336,\n
1718E - 2017054279, 1906929977],\n
1719E - [ 96106735, -2141508318, 289102684, ..., -701123111,\n
1720E - 331224497, 1938410292]],\n
1721E -\n
1722E - [[-1640341242, 1535210485, -40004054, ..., 2047264407,\n
1723E - 1126360347, 1275384060],\n...
1724E
1725E ...Full output truncated (85 lines hidden), use '-vv' to show.all
1726
1727test/test_tgsw.py:154: AssertionError
1728=============================== warnings summary ===============================
1729test/test_gates.py::test_uint_min[ocl:0:0]
1730 /home/joinu/venvs/nucypher/lib/python3.6/site-packages/nufhe/operators_integer.py:44: FutureWarning: arrays to stack must be passed as a "sequence" type such as list or tuple. Support for non-sequence iterables such as generators is deprecated as of NumPy 1.16 and will raise an error in the future.
1731 res = numpy.vstack(_uint_to_bits(x, itemsize) for x in xs.flatten())
1732
1733-- Docs: https://docs.pytest.org/en/latest/warnings.html
1734= 23 failed, 83 passed, 13 skipped, 64 deselected, 1 warnings in 72.28 seconds =