Advertisement
Nickpips

Perlin

Feb 17th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. include "../../node_modules/circomlib/circuits/comparators.circom"
  2.  
  3. template CheckPerlin() {
  4. signal input addr;
  5. signal input c;
  6. signal input k;
  7. signal private input x;
  8. signal private input y;
  9. signal private input x0;
  10. signal private input y0;
  11. signal private input x1;
  12. signal private input y1;
  13.  
  14. addr === Hash(x, y);
  15.  
  16. x1 - x0 === 1;
  17. y1 - y0 === 1;
  18.  
  19. component cxltex = LessThan(32);
  20. component cyltey = LessThan(32);
  21.  
  22. cxltex.in[0] <== x;
  23. cxltex.in[1] <== c*x0;
  24. cxltex.out === 0;
  25.  
  26. cyltey.in[0] <== y;
  27. cyltey.in[1] <== c*y0;
  28. cyltey.out === 0;
  29.  
  30. component xltcx = LessThan(32);
  31. component yltcy = LessThan(32);
  32.  
  33. xltcx.in[0] <== x;
  34. xltcx.in[1] <== c*x1;
  35. xltcx.out === 1;
  36.  
  37. yltcy.in[0] <== y;
  38. yltcy.in[1] <== c*y1;
  39. yltcy.out === 1;
  40.  
  41. signal dx00 <== x - c*x0;
  42. signal dy00 <== y - c*y0;
  43. signal x00 <== Hash(001, x0, y0);
  44. signal y00 <== Hash(002, x0, y0);
  45. signal dotproduct00 <== dx00*x00 + dy00*y00;
  46. signal weight00 <== dx00 * dy00;
  47. signal final00 <== weight00 * dotproduct00;
  48.  
  49. signal final <== final00;
  50.  
  51. component withinperlin = LessThan(32);
  52.  
  53. withinperlin.in[0] <== final;
  54. withinperlin.in[1] <== k*addr;
  55. withperlin === 1;
  56. }
  57.  
  58. component perlin = CheckPerlin();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement