You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

  1. ## Caution, Warning
  2. Fork UNDER CONSTRUCTION! Will ask for merge soon
  3. Current implementation status:
  4. - [x] optimized gate reduction!! Reusing gates as often as possible! See the awesome results below :)
  5. - [x] extended circuit code compiler
  6. - [x] move witness calculation outside the setup phase
  7. - [x] fixed hard bugs
  8. ### Library usage
  9. Warning: not finished.
  10. Working example of gate-reduction and code parsing:
  11. ```go
  12. def do(x):
  13. e = x * 5
  14. b = e * 6
  15. c = b * 7
  16. f = c * 1
  17. d = c * f
  18. out = d * mul(d,e)
  19. def doSomethingElse(x ,k):
  20. z = k * x
  21. out = do(x) + mul(x,z)
  22. def main(x,z):
  23. out = do(z) + doSomethingElse(x,x)
  24. def mul(a,b):
  25. out = a * b
  26. ```
  27. R1CS Output:
  28. ```go
  29. [[0 0 1 0 0 0 0 0 0 0] [0 0 0 0 1 0 0 0 0 0] [0 0 0 0 1 0 0 0 0 0] [0 1 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 1 0 0] [0 0 0 0 0 0 0 1 0 0] [1 0 0 0 0 0 0 0 0 0]]
  30. [[0 0 1 0 0 0 0 0 0 0] [0 0 1 0 0 0 0 0 0 0] [0 0 0 0 0 1 0 0 0 0] [0 1 0 0 0 0 0 0 0 0] [0 1 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 1 0] [0 0 0 0 0 0 9724050000 0 1 9724050000]]
  31. [[0 0 0 0 1 0 0 0 0 0] [0 0 0 0 0 1 0 0 0 0] [0 0 0 0 0 0 1 0 0 0] [0 0 0 0 0 0 0 1 0 0] [0 0 0 0 0 0 0 0 1 0] [0 0 0 0 0 0 0 0 0 1] [0 0 0 1 0 0 0 0 0 0]]
  32. input
  33. [7 11]
  34. witness
  35. [1 7 11 1729500084900343 121 1331 161051 49 343 16807]
  36. another input
  37. [365235 11876525]
  38. witness
  39. [1 365235 11876525 2297704271284150716235246193843898764109352875 141051846075625 1675205776213312203125 236290867291438012851239954111328125 133396605225 48721109109352875 6499230557984496821593771875]
  40. ```
  41. Note that we only need 7 multiplication Gates instead of 16. The 4th witness value is the programs output. Use python script to check correctness!