narodnik 4 лет назад
Родитель
Сommit
20cd53cde1
1 измененных файлов с 25 добавлено и 7 удалено
  1. 25 7
      bin/daod/proof/dao-exec.zk

+ 25 - 7
bin/daod/proof/dao-exec.zk

@@ -36,6 +36,7 @@ contract "DaoExec" {
     Scalar input_value_blind,
 
     # misc
+    # TODO: make these public so we know they're the correct values
     Base dao_spend_hook,
     Base user_spend_hook,
     Base user_data,
@@ -88,6 +89,7 @@ circuit "DaoExec" {
        dao_public_x,
        dao_public_y,
        change,
+       # TODO: should be proposal_token_id
        gov_token_id,
        dao_serial,
        dao_spend_hook,
@@ -96,6 +98,9 @@ circuit "DaoExec" {
     );
     constrain_instance(coin_1);
 
+    # Create pedersen commits for win_votes, and total_votes
+    # and make public
+
     win_votes_v = ec_mul_short(win_votes, VALUE_COMMIT_VALUE);
     win_votes_r = ec_mul(win_votes_blind, VALUE_COMMIT_RANDOM);
     win_votes_commit = ec_add(win_votes_v, win_votes_r);
@@ -116,6 +121,8 @@ circuit "DaoExec" {
 	constrain_instance(total_votes_commit_x);
 	constrain_instance(total_votes_commit_y);
 
+    # Create pedersen commit for input_value and make public
+    
     input_value_v = ec_mul_short(input_value, VALUE_COMMIT_VALUE);
     input_value_r = ec_mul(input_value_blind, VALUE_COMMIT_RANDOM);
     input_value_commit = ec_add(input_value_v, input_value_r);
@@ -126,11 +133,25 @@ circuit "DaoExec" {
 	constrain_instance(input_value_x);
 	constrain_instance(input_value_y);
 
-    # Create pedersen commits for win_votes, and total_votes
-    # and make public
+    # total_votes >= dao_quorum
+    # TODO: waiting on this opcode in zkas
+    #
+    #     greater_than_or_equal(total_votes, dao_quorum)
+    #
+
+    # win_votes / total_votes >= approval_ratio_quot / approval_ratio_base
+    #
+    # The above is also equivalent to this:
+    #
+    # win_votes * approval_ratio_base >= total_votes * approval_ratio_quot
+    #
+    # TODO: waiting on this opcode in zkas
+    #
+    #     lhs = base_mul(win_votes, approval_ratio_base);
+    #     rhs = base_mul(total_votes, approval_ratio_quot);
+    #     greater_than_or_equal(lhs, rhs);
+    #
 
-    # Create pedersen commit for input_value and make public
-    
     ####
 
     # Create coin 0
@@ -141,9 +162,6 @@ circuit "DaoExec" {
     # Create the input value commit
     # Create the value commits
 
-    # Check total_votes >= dao_quorum
-    # Check win_votes / total_votes >= approval_ratio
-
     # NOTE: there is a vulnerability here where someone can create the exec
     # transaction with a bad note so it cannot be decrypted by the receiver
     # TODO: research verifiable encryption inside ZK