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.

51 lines
1.3 KiB

  1. /*
  2. # withdraw.circom
  3. WARNING: WIP, very initial version of the miksi circuit
  4. +--------+
  5. PUB_coinCode+------->+ |
  6. | | +----+
  7. PUB_amount+--------->+Poseidon+------->+ == +<-----+PUB_commitment
  8. | | +----+
  9. PRI_secret+--------->+ |
  10. +--------+
  11. +----+
  12. PUB_address+--->+ != +<---+0
  13. +----+
  14. */
  15. include "../node_modules/circomlib/circuits/babyjub.circom";
  16. include "../node_modules/circomlib/circuits/comparators.circom";
  17. include "../node_modules/circomlib/circuits/poseidon.circom";
  18. include "../node_modules/circomlib/circuits/bitify.circom";
  19. include "../node_modules/circomlib/circuits/smt/smtverifier.circom";
  20. include "../node_modules/circomlib/circuits/smt/smtprocessor.circom";
  21. template Withdraw() {
  22. signal input coinCode;
  23. signal input amount;
  24. signal input commitment;
  25. signal private input secret;
  26. signal input address;
  27. component hash = Poseidon(3, 6, 8, 57);
  28. hash.inputs[0] <== coinCode;
  29. hash.inputs[1] <== amount;
  30. hash.inputs[2] <== secret;
  31. component eq = IsEqual();
  32. eq.in[0] <== hash.out;
  33. eq.in[1] <== commitment;
  34. eq.out === 1;
  35. component z = IsZero();
  36. z.in <== address;
  37. z.out === 0;
  38. }
  39. component main = Withdraw();