Просмотр исходного кода

contract/dao: removed coin blind from hashes

aggstam 3 лет назад
Родитель
Сommit
2196f32c02

+ 0 - 4
src/contract/dao/proof/dao-exec.zk

@@ -29,9 +29,7 @@ witness "DaoExec" {
 
 
 	# Outputs + Inputs
 	# Outputs + Inputs
 	Base user_serial,
 	Base user_serial,
-	Base user_coin_blind,
 	Base dao_serial,
 	Base dao_serial,
-	Base dao_coin_blind,
 	Base input_value,
 	Base input_value,
 	Scalar input_value_blind,
 	Scalar input_value_blind,
 
 
@@ -74,7 +72,6 @@ circuit "DaoExec" {
 		user_serial,
 		user_serial,
 		user_spend_hook,
 		user_spend_hook,
 		user_data,
 		user_data,
-		user_coin_blind,
 	);
 	);
 	constrain_instance(coin_0);
 	constrain_instance(coin_0);
 
 
@@ -88,7 +85,6 @@ circuit "DaoExec" {
 		dao_serial,
 		dao_serial,
 		dao_spend_hook,
 		dao_spend_hook,
 		dao_bulla,
 		dao_bulla,
-		dao_coin_blind,
 	);
 	);
 	constrain_instance(coin_1);
 	constrain_instance(coin_1);
 
 

+ 0 - 2
src/contract/dao/proof/dao-propose-burn.zk

@@ -11,7 +11,6 @@ witness "DaoProposeInput" {
 	Base user_data,
 	Base user_data,
 	Base value,
 	Base value,
 	Base token,
 	Base token,
-	Base coin_blind,
 	Scalar value_blind,
 	Scalar value_blind,
 	Base token_blind,
 	Base token_blind,
 	Uint32 leaf_pos,
 	Uint32 leaf_pos,
@@ -46,7 +45,6 @@ circuit "DaoProposeInput" {
 		serial,
 		serial,
 		spend_hook,
 		spend_hook,
 		user_data,
 		user_data,
-		coin_blind
 	);
 	);
 
 
 	# Merkle root
 	# Merkle root

+ 0 - 2
src/contract/dao/proof/dao-vote-burn.zk

@@ -11,7 +11,6 @@ witness "DaoVoteInput" {
 	Base user_data,
 	Base user_data,
 	Base value,
 	Base value,
 	Base gov_token_id,
 	Base gov_token_id,
-	Base coin_blind,
 	Scalar value_blind,
 	Scalar value_blind,
 	Base gov_token_blind,
 	Base gov_token_blind,
 	Uint32 leaf_pos,
 	Uint32 leaf_pos,
@@ -43,7 +42,6 @@ circuit "DaoVoteInput" {
 		serial,
 		serial,
 		spend_hook,
 		spend_hook,
 		user_data,
 		user_data,
-		coin_blind,
 	);
 	);
 
 
 	# Merkle root
 	# Merkle root

+ 2 - 8
src/contract/dao/src/client/exec.rs

@@ -42,9 +42,7 @@ pub struct DaoExecCall {
     pub yes_vote_blind: pallas::Scalar,
     pub yes_vote_blind: pallas::Scalar,
     pub all_vote_blind: pallas::Scalar,
     pub all_vote_blind: pallas::Scalar,
     pub user_serial: pallas::Base,
     pub user_serial: pallas::Base,
-    pub user_coin_blind: pallas::Base,
     pub dao_serial: pallas::Base,
     pub dao_serial: pallas::Base,
-    pub dao_coin_blind: pallas::Base,
     pub input_value: u64,
     pub input_value: u64,
     pub input_value_blind: pallas::Scalar,
     pub input_value_blind: pallas::Scalar,
     pub hook_dao_exec: pallas::Base,
     pub hook_dao_exec: pallas::Base,
@@ -96,7 +94,7 @@ impl DaoExecCall {
             self.proposal.blind,
             self.proposal.blind,
         ]);
         ]);
 
 
-        let coin_0 = poseidon_hash::<8>([
+        let coin_0 = poseidon_hash::<7>([
             proposal_dest_x,
             proposal_dest_x,
             proposal_dest_y,
             proposal_dest_y,
             proposal_amount,
             proposal_amount,
@@ -104,10 +102,9 @@ impl DaoExecCall {
             self.user_serial,
             self.user_serial,
             user_spend_hook,
             user_spend_hook,
             user_data,
             user_data,
-            self.user_coin_blind,
         ]);
         ]);
 
 
-        let coin_1 = poseidon_hash::<8>([
+        let coin_1 = poseidon_hash::<7>([
             dao_pub_x,
             dao_pub_x,
             dao_pub_y,
             dao_pub_y,
             change,
             change,
@@ -115,7 +112,6 @@ impl DaoExecCall {
             self.dao_serial,
             self.dao_serial,
             self.hook_dao_exec,
             self.hook_dao_exec,
             dao_bulla,
             dao_bulla,
-            self.dao_coin_blind,
         ]);
         ]);
 
 
         let yes_vote_commit = pedersen_commitment_u64(self.yes_vote_value, self.yes_vote_blind);
         let yes_vote_commit = pedersen_commitment_u64(self.yes_vote_value, self.yes_vote_blind);
@@ -150,9 +146,7 @@ impl DaoExecCall {
             Witness::Scalar(Value::known(self.all_vote_blind)),
             Witness::Scalar(Value::known(self.all_vote_blind)),
             // outputs + inputs
             // outputs + inputs
             Witness::Base(Value::known(self.user_serial)),
             Witness::Base(Value::known(self.user_serial)),
-            Witness::Base(Value::known(self.user_coin_blind)),
             Witness::Base(Value::known(self.dao_serial)),
             Witness::Base(Value::known(self.dao_serial)),
-            Witness::Base(Value::known(self.dao_coin_blind)),
             Witness::Base(Value::known(input_value)),
             Witness::Base(Value::known(input_value)),
             Witness::Scalar(Value::known(self.input_value_blind)),
             Witness::Scalar(Value::known(self.input_value_blind)),
             // misc
             // misc

+ 2 - 11
src/contract/dao/tests/integration.rs

@@ -171,7 +171,6 @@ async fn integration_test() -> Result<()> {
             token_id: xdrk_token_id,
             token_id: xdrk_token_id,
             public: dao_th.dao_kp.public,
             public: dao_th.dao_kp.public,
             serial: pallas::Base::random(&mut OsRng),
             serial: pallas::Base::random(&mut OsRng),
-            coin_blind: pallas::Base::random(&mut OsRng),
             spend_hook,
             spend_hook,
             user_data,
             user_data,
         }],
         }],
@@ -224,7 +223,7 @@ async fn integration_test() -> Result<()> {
     // Check the actual coin received is valid before accepting it
     // Check the actual coin received is valid before accepting it
 
 
     let coords = dao_th.dao_kp.public.inner().to_affine().coordinates().unwrap();
     let coords = dao_th.dao_kp.public.inner().to_affine().coordinates().unwrap();
-    let coin = poseidon_hash::<8>([
+    let coin = poseidon_hash::<7>([
         *coords.x(),
         *coords.x(),
         *coords.y(),
         *coords.y(),
         pallas::Base::from(treasury_note.value),
         pallas::Base::from(treasury_note.value),
@@ -232,7 +231,6 @@ async fn integration_test() -> Result<()> {
         treasury_note.serial,
         treasury_note.serial,
         treasury_note.spend_hook,
         treasury_note.spend_hook,
         treasury_note.user_data,
         treasury_note.user_data,
-        treasury_note.coin_blind,
     ]);
     ]);
     assert_eq!(coin, dao_recv_coin.coin.inner());
     assert_eq!(coin, dao_recv_coin.coin.inner());
 
 
@@ -345,7 +343,7 @@ async fn integration_test() -> Result<()> {
             assert_eq!(note.user_data, pallas::Base::from(0));
             assert_eq!(note.user_data, pallas::Base::from(0));
 
 
             let (pub_x, pub_y) = key.public.xy();
             let (pub_x, pub_y) = key.public.xy();
-            let coin = poseidon_hash::<8>([
+            let coin = poseidon_hash::<7>([
                 pub_x,
                 pub_x,
                 pub_y,
                 pub_y,
                 pallas::Base::from(note.value),
                 pallas::Base::from(note.value),
@@ -353,7 +351,6 @@ async fn integration_test() -> Result<()> {
                 note.serial,
                 note.serial,
                 note.spend_hook,
                 note.spend_hook,
                 note.user_data,
                 note.user_data,
-                note.coin_blind,
             ]);
             ]);
             assert_eq!(coin, recv_coin.coin.inner());
             assert_eq!(coin, recv_coin.coin.inner());
 
 
@@ -789,9 +786,7 @@ async fn integration_test() -> Result<()> {
     let user_data_blind = pallas::Base::random(&mut OsRng);
     let user_data_blind = pallas::Base::random(&mut OsRng);
 
 
     let user_serial = pallas::Base::random(&mut OsRng);
     let user_serial = pallas::Base::random(&mut OsRng);
-    let user_coin_blind = pallas::Base::random(&mut OsRng);
     let dao_serial = pallas::Base::random(&mut OsRng);
     let dao_serial = pallas::Base::random(&mut OsRng);
-    let dao_coin_blind = pallas::Base::random(&mut OsRng);
     let input_value = treasury_note.value;
     let input_value = treasury_note.value;
     let input_value_blind = pallas::Scalar::random(&mut OsRng);
     let input_value_blind = pallas::Scalar::random(&mut OsRng);
     let xfer_signature_secret = SecretKey::random(&mut OsRng);
     let xfer_signature_secret = SecretKey::random(&mut OsRng);
@@ -831,7 +826,6 @@ async fn integration_test() -> Result<()> {
                 //public: user_keypair.public,
                 //public: user_keypair.public,
                 public: receiver_keypair.public,
                 public: receiver_keypair.public,
                 serial: user_serial,
                 serial: user_serial,
-                coin_blind: user_coin_blind,
                 spend_hook: pallas::Base::from(0),
                 spend_hook: pallas::Base::from(0),
                 user_data: pallas::Base::from(0),
                 user_data: pallas::Base::from(0),
             },
             },
@@ -841,7 +835,6 @@ async fn integration_test() -> Result<()> {
                 token_id: xdrk_token_id,
                 token_id: xdrk_token_id,
                 public: dao_th.dao_kp.public,
                 public: dao_th.dao_kp.public,
                 serial: dao_serial,
                 serial: dao_serial,
-                coin_blind: dao_coin_blind,
                 spend_hook,
                 spend_hook,
                 user_data,
                 user_data,
             },
             },
@@ -866,9 +859,7 @@ async fn integration_test() -> Result<()> {
         yes_vote_blind: total_yes_vote_blind,
         yes_vote_blind: total_yes_vote_blind,
         all_vote_blind: total_all_vote_blind,
         all_vote_blind: total_all_vote_blind,
         user_serial,
         user_serial,
-        user_coin_blind,
         dao_serial,
         dao_serial,
-        dao_coin_blind,
         input_value,
         input_value,
         input_value_blind,
         input_value_blind,
         hook_dao_exec: spend_hook,
         hook_dao_exec: spend_hook,

+ 1 - 1
src/contract/test-harness/src/vks.rs

@@ -48,7 +48,7 @@ use darkfi_serial::{deserialize, serialize};
 use log::debug;
 use log::debug;
 
 
 /// Update this if any circuits are changed
 /// Update this if any circuits are changed
-const VKS_HASH: &str = "4c9b94adf8aba19add503d76d154e2bdc5c49cfd19ab1f1f0c0c058862cadf67";
+const VKS_HASH: &str = "e5dcc83e82020f26d6b4479051332de04c200cfb77dae45c26b8252f499149cf";
 
 
 fn vks_path() -> Result<PathBuf> {
 fn vks_path() -> Result<PathBuf> {
     let output = Command::new("git").arg("rev-parse").arg("--show-toplevel").output()?.stdout;
     let output = Command::new("git").arg("rev-parse").arg("--show-toplevel").output()?.stdout;