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
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

exploiting_design_ntru_prime.sage 1.9KB

  1. #!/usr/bin/sage -python
  2. # -*- coding: latin-1 -*-
  3. load("../framework/instance_gen.sage")
  4. verbosity = 0
  5. report_every = None
  6. """ Example
  7. Uncomment the following to get the detailed computation
  8. """
  9. # verbosity = 2
  10. # report_every = 50
  11. for params in ['kem/sntrup653', 'kem/sntrup761', 'kem/sntrup857']:
  12. logging("Set of parameters: " + params)
  13. if params == 'kem/sntrup653':
  14. n = 653
  15. m = n
  16. q = 4621
  17. w = 288
  18. elif params == 'kem/sntrup761':
  19. n = 761
  20. m = n
  21. q = 4591
  22. w = 286
  23. elif params == 'kem/sntrup857':
  24. n = 857
  25. m = n
  26. q = 5167
  27. w = 322
  28. elif params == 'kem/ntrulpr653':
  29. n = 653
  30. m = n
  31. q = 4621
  32. w = 252
  33. elif params == 'kem/ntrulpr761':
  34. n = 761
  35. m = n
  36. q = 4591
  37. w = 250
  38. elif params == 'kem/ntrulpr857':
  39. n = 857
  40. m = n
  41. q = 5167
  42. w = 281
  43. D_f = {-1: RR(w / n / 2), 0: 1 - RR(w / n), 1: RR(w / n / 2)}
  44. D_g = {-1: RR(1 / 3), 0: RR(1 / 3), 1: RR(1 / 3)}
  45. only_predictions = True
  46. A, b, dbdd = initialize_NTRU_prime_instance(DBDD_predict_diag, n, q, m, w, D_f, D_g, verbosity=verbosity)
  47. if report_every is not None:
  48. dbdd.integrate_q_vectors(q, report_every=report_every)
  49. else:
  50. dbdd.integrate_q_vectors(q)
  51. (beta, _) = dbdd.estimate_attack()
  52. logging("Attack without hints: %3.2f bikz" % beta, style="HEADER")
  53. A, b, dbdd = initialize_NTRU_prime_instance(DBDD_predict, n, q, m, w, D_f, D_g, verbosity=verbosity)
  54. v = vec([1 if i < m else 0 for i in range(m + n)])
  55. dbdd.integrate_modular_hint(v, w, 2, True)
  56. if report_every is not None:
  57. dbdd.integrate_q_vectors(q, report_every=report_every)
  58. else:
  59. dbdd.integrate_q_vectors(q)
  60. (beta, _) = dbdd.estimate_attack()
  61. logging("Attack with hints: %3.2f bikz" % beta, style="HEADER")