dao-exec.zk 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. constant "DaoExec" {
  2. EcFixedPointShort VALUE_COMMIT_VALUE,
  3. EcFixedPoint VALUE_COMMIT_RANDOM,
  4. }
  5. contract "DaoExec" {
  6. # proposal params
  7. Base proposal_dest_x,
  8. Base proposal_dest_y,
  9. Base proposal_amount,
  10. Base proposal_serial,
  11. Base proposal_token_id,
  12. Base proposal_blind,
  13. # DAO params
  14. Base dao_proposer_limit,
  15. Base dao_quorum,
  16. Base dao_approval_ratio,
  17. Base gov_token_id,
  18. Base dao_public_x,
  19. Base dao_public_y,
  20. Base dao_bulla_blind,
  21. # votes
  22. Base win_votes,
  23. Base total_votes,
  24. Scalar win_votes_blind,
  25. Scalar total_votes_blind,
  26. # outputs + inputs
  27. Base user_serial,
  28. Base user_coin_blind,
  29. Base dao_serial,
  30. Base dao_coin_blind,
  31. Base input_value,
  32. Scalar input_value_blind,
  33. }
  34. circuit "DaoExec" {
  35. dao_bulla = poseidon_hash(
  36. dao_proposer_limit,
  37. dao_quorum,
  38. dao_approval_ratio,
  39. gov_token_id,
  40. dao_public_x,
  41. dao_public_y,
  42. dao_bulla_blind,
  43. # @tmp-workaround
  44. dao_bulla_blind,
  45. );
  46. # Proposal bulla is valid means DAO bulla is also valid
  47. # because of dao-propose-main.zk, already checks that when
  48. # we first create the proposal. So it is redundant here.
  49. proposal_bulla = poseidon_hash(
  50. proposal_dest_x,
  51. proposal_dest_y,
  52. proposal_amount,
  53. proposal_serial,
  54. proposal_token_id,
  55. dao_bulla,
  56. proposal_blind,
  57. # @tmp-workaround
  58. proposal_blind,
  59. );
  60. constrain_instance(proposal_bulla);
  61. # Create coin0 = hash(...) and make public
  62. # Create coin1 = hash(...) and make public
  63. # Create pedersen commits for win_votes, and total_votes
  64. # and make public
  65. # Create pedersen commit for input_value and make public
  66. ####
  67. # Create coin 0
  68. # Create coin 1
  69. # Check values of coin 0 + coin 1 == input value
  70. # Check value of coin 0 == proposal_amount
  71. # Check public key matches too
  72. # Create the input value commit
  73. # Create the value commits
  74. # Check total_votes >= dao_quorum
  75. # Check win_votes / total_votes >= approval_ratio
  76. # NOTE: there is a vulnerability here where someone can create the exec
  77. # transaction with a bad note so it cannot be decrypted by the receiver
  78. # TODO: research verifiable encryption inside ZK
  79. }