From 5b90347d46e5eb6fb5936c2bcb67bbc5b1c901b5 Mon Sep 17 00:00:00 2001 From: x Date: Wed, 8 Feb 2023 02:17:34 +0100 Subject: [PATCH 1/3] dao-exec: input value blind should be the sum of blinds used for input value commits --- bin/drk/src/rpc_dao.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/drk/src/rpc_dao.rs b/bin/drk/src/rpc_dao.rs index dc71098df..b5b98ea91 100644 --- a/bin/drk/src/rpc_dao.rs +++ b/bin/drk/src/rpc_dao.rs @@ -406,7 +406,6 @@ impl Drk { let user_coin_blind = 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_blind = pallas::Scalar::random(&mut OsRng); // TODO: FIXME: Clean this up and create an API let exec_signature_secret = SecretKey::random(&mut OsRng); @@ -414,7 +413,6 @@ impl Drk { let mut xfer_inputs = vec![]; let mut input_coins = vec![]; - let mut input_value_blinds = vec![]; let mut input_amount = 0; for coin in coins { input_amount += coin.note.value; @@ -427,6 +425,7 @@ impl Drk { let money_merkle_tree = self.get_money_tree().await?; let money_merkle_root = money_merkle_tree.root(0).unwrap(); + let mut input_value_blind = pallas::Scalar::from(0); for coin in &input_coins { let value_blind = pallas::Scalar::random(&mut OsRng); let sig_secret = SecretKey::random(&mut OsRng); @@ -444,7 +443,7 @@ impl Drk { signature_secret: sig_secret, }); - input_value_blinds.push(value_blind); + input_value_blind += value_blind; } let input_sum = input_coins.iter().map(|x| x.note.value).sum::(); From 27ff837dbc06be5ec9bef21cf649c561174a0ded Mon Sep 17 00:00:00 2001 From: x Date: Wed, 8 Feb 2023 02:18:33 +0100 Subject: [PATCH 2/3] dao-exec: temporary workaround, but serial and blind should be that used in coin 0 --- bin/drk/src/rpc_dao.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/drk/src/rpc_dao.rs b/bin/drk/src/rpc_dao.rs index b5b98ea91..cd94f0ddb 100644 --- a/bin/drk/src/rpc_dao.rs +++ b/bin/drk/src/rpc_dao.rs @@ -455,8 +455,8 @@ impl Drk { value: proposal.amount, token_id: proposal.token_id, public: proposal.recipient, - serial: user_serial, - coin_blind: user_coin_blind, + serial: proposal.serial, + coin_blind: proposal.bulla_blind, spend_hook: pallas::Base::zero(), user_data: pallas::Base::zero(), }, From c89860c9f792f6c4916052a00d69bb6e11877eeb Mon Sep 17 00:00:00 2001 From: x Date: Wed, 8 Feb 2023 02:19:00 +0100 Subject: [PATCH 3/3] dao-exec fix: approval ratio/quotient are reversed --- bin/drk/src/main.rs | 4 ++-- bin/drk/src/rpc_dao.rs | 6 ++++++ bin/drk/src/wallet_dao.rs | 4 ++-- .../darkfid-single-node/faucetd/wallet.db | Bin 24576 -> 24576 bytes 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/drk/src/main.rs b/bin/drk/src/main.rs index 8650a68ed..a12e17d83 100644 --- a/bin/drk/src/main.rs +++ b/bin/drk/src/main.rs @@ -712,8 +712,8 @@ async fn main() -> Result<()> { exit(1); } - let approval_ratio_quot = 100_u64; - let approval_ratio_base = (approval_ratio * approval_ratio_quot as f64) as u64; + let approval_ratio_base = 100_u64; + let approval_ratio_quot = (approval_ratio * approval_ratio_base as f64) as u64; let gov_token_id = TokenId::try_from(gov_token_id.as_str()).with_context(|| "Invalid Token ID")?; diff --git a/bin/drk/src/rpc_dao.rs b/bin/drk/src/rpc_dao.rs index cd94f0ddb..0f6c886e0 100644 --- a/bin/drk/src/rpc_dao.rs +++ b/bin/drk/src/rpc_dao.rs @@ -523,6 +523,7 @@ impl Drk { total_all_vote_blind += vote.all_vote_blind; let yes_vote_value = vote.vote_option as u64 * vote.all_vote_value; + eprintln!("yes_vote = {}", yes_vote_value); total_yes_vote_value += yes_vote_value; total_all_vote_value += vote.all_vote_value; @@ -533,6 +534,8 @@ impl Drk { blind_total_vote.aggregate(blind_vote); } + eprintln!("yes = {}, all = {}", total_yes_vote_value, total_all_vote_value); + let prop_t = DaoProposalInfo { dest: proposal.recipient, amount: proposal.amount, @@ -541,6 +544,9 @@ impl Drk { blind: proposal.bulla_blind, // <-- FIXME: wtf }; + // TODO: user blind weirdness in proposal + // TODO: allvote/yesvote is 11 weirdly + let dao_t = DaoInfo { proposer_limit: dao.proposer_limit, quorum: dao.quorum, diff --git a/bin/drk/src/wallet_dao.rs b/bin/drk/src/wallet_dao.rs index 89ba9e13f..6a6ef4766 100644 --- a/bin/drk/src/wallet_dao.rs +++ b/bin/drk/src/wallet_dao.rs @@ -87,7 +87,7 @@ impl fmt::Display for DaoParams { encode_base10(self.quorum, 8), self.quorum, "Approval ratio", - self.approval_ratio_base as f64 / self.approval_ratio_quot as f64, + self.approval_ratio_quot as f64 / self.approval_ratio_base as f64, "Governance Token ID", self.gov_token_id, "Public key", @@ -164,7 +164,7 @@ impl fmt::Display for Dao { encode_base10(self.quorum, 8), self.quorum, "Approval ratio", - self.approval_ratio_base as f64 / self.approval_ratio_quot as f64, + self.approval_ratio_quot as f64 / self.approval_ratio_base as f64, "Governance Token ID", self.gov_token_id, "Public key", diff --git a/contrib/localnet/darkfid-single-node/faucetd/wallet.db b/contrib/localnet/darkfid-single-node/faucetd/wallet.db index 75149d118b7e1f0cfb00b0895d18e2e805a88c4a..828a4d099bc221a2a658a9aba0845b70fd733e3f 100644 GIT binary patch delta 19 acmZoTz}Rqrae_3X{6raNM){2i3*rGnIR=R_H2M$U~13*rGl?*>8u