zkrunner.py~ 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ############################################################
  2. # Version that supports (de)serializastion
  3. # Archived for now
  4. ############################################################
  5. # """
  6. # Acceptable format:
  7. #
  8. # A witness or public input = [<type>, <value>]
  9. #
  10. # <type> = Base|Scalar|EcPoint
  11. #
  12. # <value> = "NUMBER|HEX_NUMBER" for Base or Scalar
  13. # = "HEX_NUMBER" for Point
  14. # """
  15. # def serialize_input(input):
  16. # input = ['Base', '42']
  17. # vartype, varserial = input
  18. # if vartype == 'Base':
  19. # return Base.from_u64(varserial)
  20. # pass
  21. #
  22. # def deserialize_input():
  23. # pass
  24. #
  25. # def make_publics(args):
  26. # print(f"make_publics: {args}")
  27. #
  28. # def prove(args):
  29. # print(f"prove: {args}")
  30. #
  31. # def verify(args):
  32. # print(f"verify: {args}")
  33. #
  34. # """
  35. # TODO:
  36. #
  37. # * Why did EcNiPoint fail to be witnessed (when building the proving key and in vm.rs)?
  38. # * This is the last opcode that is not supported by ZkRunner
  39. # * Why do the witness type and heap var type have different sets of variants?
  40. # * Need to confirm the simplications of types, i.e. Rust has more types than Python, do not have gotchas
  41. # * If we want to send publics around in a file, we need to figure out the serialization format
  42. # """
  43. # if __name__ == "__main__":
  44. # desc = "ZkRunner helps compute public inputs, and prove and verify Darkfi zero knowledge proofs."
  45. # global_parser = ArgumentParser(
  46. # prog="ZkRunner",
  47. # description=desc
  48. # )
  49. # subparsers = global_parser.add_subparsers(title="commands")
  50. #
  51. # # make_publics
  52. # m_parser = subparsers.add_parser("make-publics", help="Make public inputs",)
  53. # m_parser.add_argument(
  54. # "--witnesses",
  55. # default="witnesses.json",
  56. # help="[default: witnesses.json] Path for where the witnesses are stored"
  57. # )
  58. # m_parser.add_argument(
  59. # "--publics",
  60. # default="publics.json",
  61. # help="[default: publics.json] Path for where to store the computed public inputs for proving and verifying"
  62. # )
  63. # m_parser.set_defaults(func=make_publics)
  64. #
  65. #
  66. # # prove
  67. # p_parser = subparsers.add_parser("prove", help="Generate proving key and prove")
  68. # p_parser.add_argument(
  69. # "--witnesses",
  70. # default="witnesses.json",
  71. # help="[default: witnesses.json] Path for where the witnesses are stored"
  72. # )
  73. # p_parser.add_argument(
  74. # "--publics",
  75. # default="publics.json",
  76. # help="[default: publics.json] Path for where to store the computed public inputs for proving and verifying"
  77. # )
  78. # p_parser.add_argument(
  79. # "--proof",
  80. # default="proof.json",
  81. # help="[default: proof.json] Path for where to store the computed proof"
  82. # )
  83. # p_parser.set_defaults(func=prove)
  84. #
  85. #
  86. # # verify
  87. # v_parser = subparsers.add_parser("verify", help="Generate verifying key and verify")
  88. # v_parser.add_argument(
  89. # "--publics",
  90. # default="publics.json",
  91. # help="[default: publics.json] Path for where to store the computed public inputs for proving and verifying"
  92. # )
  93. # v_parser.add_argument(
  94. # "--proof",
  95. # default="proof.json",
  96. # help="[default: proof.json] Path for where to store the computed proof"
  97. # )
  98. # v_parser.set_defaults(func=verify)
  99. #
  100. #
  101. # args = global_parser.parse_args()
  102. # # calls the command
  103. # args.func(args)