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.

44 lines
1.5 KiB

  1. ## Caution, Warning
  2. Fork UNDER CONSTRUCTION! Will ask for merge soon
  3. Current implementation status:
  4. - [x] extended circuit code compiler
  5. - [x] move witness calculation outside the setup phase
  6. - [x] fixed hard bugs
  7. ### Library usage
  8. Warning: not finished.
  9. Working example of gate-reduction and code parsing:
  10. ```go
  11. def do(x):
  12. e = x * 5
  13. b = e * 6
  14. c = b * 7
  15. f = c * 1
  16. d = c * f
  17. out = d * mul(d,e)
  18. def doSomethingElse(x ,k):
  19. z = k * x
  20. out = do(x) + mul(x,z)
  21. def main(x,z):
  22. out = do(z) + doSomethingElse(x,x)
  23. def mul(a,b):
  24. out = a * b
  25. ```
  26. R1CS Output:
  27. ```go
  28. [[0 0 210 0 0 0 0 0 0 0 0 0] [0 0 0 1 0 0 0 0 0 0 0 0] [0 0 0 1 0 0 0 0 0 0 0 0] [0 210 0 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 0 0 1 0 0 0 0 0] [0 1 0 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 0]]
  29. [[0 0 210 0 0 0 0 0 0 0 0 0] [0 0 5 0 0 0 0 0 0 0 0 0] [0 0 0 0 1 0 0 0 0 0 0 0] [0 210 0 0 0 0 0 0 0 0 0 0] [0 5 0 0 0 0 0 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 0] [0 0 0 0 0 0 0 0 0 1 0 0] [0 0 0 0 0 1 0 0 1 0 1 0]]
  30. [[0 0 0 1 0 0 0 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 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 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 0 0 0 0 0 0 0 1 0] [0 0 0 0 0 0 0 0 0 0 0 1]]
  31. input
  32. [7 11]
  33. witness
  34. [1 7 11 5336100 293485500 1566067976550000 2160900 75631500 163432108350000 49 343 1729500084900343]
  35. ```
  36. Note that we only need 9 multiplication Gates instead of 16