dao.zk 1014 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. constant "DAO" {
  2. EcFixedPoint VALUE_COMMIT_VALUE,
  3. EcFixedPoint VALUE_COMMIT_RANDOM,
  4. }
  5. contract "DAO" {
  6. Base a, # contract address
  7. Base s, # serial number
  8. Base T, # treasury balance
  9. Base B_b, # bulla blinding
  10. Uint32 leaf_pos,
  11. MerklePath W, # merkle path to DAO
  12. Base u, # output 0 value
  13. Base P_x, # output 0 addr x
  14. Base P_y, # output 0 addr y
  15. Base b_m, # output blinding
  16. Base votes,
  17. Scalar vote_blinds,
  18. Scalar output_1_blind,
  19. }
  20. circuit "DAO" {
  21. # Reveal serial number
  22. constrain_instance(s);
  23. # Poseidon hash of the Bulla
  24. bulla = poseidon_hash(a, s, T, B_b);
  25. D = calculate_merkle_root(leaf_pos, W, bulla);
  26. constrain_instance(D);
  27. # Output 0:
  28. M = poseidon_hash(u, P_x, P_y, b_m);
  29. constrain_instance(M);
  30. vcv = ec_mul_short(votes, VALUE_COMMIT_VALUE);
  31. vcr = ec_mul(vote_blinds, VALUE_COMMIT_RANDOM);
  32. vote_commit = ec_add(vcv, vcr);
  33. vote_commit_x = ec_get_x(vote_commit);
  34. vote_commit_y = ec_get_y(vote_commit);
  35. constrain_instance(vote_commit_x);
  36. constrain_instance(vote_commit_y);
  37. }