Fork of the official github repository of the framework Leaky-LWE-Estimator, a Sage Toolkit to attack and estimate the hardness of LWE with Side Information. https://github.com/lducas/leaky-LWE-Estimator
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

  1. import time
  2. from multiprocessing import Process, Queue
  3. return_queue = Queue()
  4. def test_process(i, return_queue):
  5. time.sleep(4 * i + 1)
  6. return_queue.put(3 * i + 2)
  7. def map_drop(nb, threads, f, aargs, max_drop=0):
  8. processes = []
  9. def ff(i, args, return_queue):
  10. for trial in range(10):
  11. r = f(i + 2**16 * trial, args)
  12. return_queue.put(r)
  13. return
  14. # except:
  15. # pass
  16. # print "FAILED 10 TIMES"
  17. for i in range(threads):
  18. process = Process(target=ff, args=(i, aargs, return_queue))
  19. processes.append(process)
  20. process.start()
  21. ret = []
  22. for i in range(threads, nb + threads):
  23. ret.append(return_queue.get()) # this is blocking
  24. if len(ret) == nb:
  25. break
  26. if i < nb + max_drop:
  27. process = Process(target=ff, args=(i, aargs, return_queue))
  28. processes.append(process)
  29. process.start()
  30. for process in processes:
  31. if process.is_alive():
  32. process.terminate()
  33. if len(ret) != nb:
  34. print(len(ret), nb)
  35. raise ValueError("Something went wrong.")
  36. return ret