diff --git a/README.md b/README.md index 6a1214d3e..9a559d3e7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## Connect to DarkFi IRC -Follow the [installation instructions](https://darkrenaissance.github.io/darkfi/misc/ircd.html#installation) +Follow the [installation instructions](https://darkrenaissance.github.io/darkfi/misc/ircd/ircd.html) for the P2P IRC daemon. ## Build diff --git a/example/lead.rs b/example/lead.rs index 4e6f23a90..d10c2d661 100644 --- a/example/lead.rs +++ b/example/lead.rs @@ -5,7 +5,10 @@ use url::Url; use darkfi::{ consensus::ouroboros::{Epoch, EpochConsensus, Stakeholder}, - crypto::{lead_proof, leadcoin::{LeadCoin, LEAD_PUBLIC_INPUT_LEN}}, + crypto::{ + lead_proof, + leadcoin::{LeadCoin, LEAD_PUBLIC_INPUT_LEN}, + }, net::Settings, }; @@ -15,7 +18,6 @@ fn main() { let k: u32 = 13; // - let _value = 33223; //static stake value // diff --git a/src/consensus/ouroboros/epoch.rs b/src/consensus/ouroboros/epoch.rs index 2191ad4a0..0df17ecc6 100644 --- a/src/consensus/ouroboros/epoch.rs +++ b/src/consensus/ouroboros/epoch.rs @@ -1,8 +1,8 @@ use crate::{ consensus::ouroboros::{ consts::{LOTTERY_HEAD_START, RADIX_BITS}, - utils::{fbig2ibig}, - types::{Float10}, + types::Float10, + utils::fbig2ibig, EpochConsensus, }, crypto::{ @@ -299,7 +299,9 @@ impl Epoch { for (winning_idx, coin) in competing_coins.iter().enumerate() { let y_exp = [coin.root_sk.unwrap(), coin.nonce.unwrap()]; let y_exp_hash: pallas::Base = - poseidon::Hash::<_, poseidon::P128Pow5T3, poseidon::ConstantLength<2>, 3, 2>::init().hash(y_exp); + poseidon::Hash::<_, poseidon::P128Pow5T3, poseidon::ConstantLength<2>, 3, 2>::init( + ) + .hash(y_exp); let y_coordinates = pedersen_commitment_base(coin.y_mu.unwrap(), mod_r_p(y_exp_hash)) .to_affine() .coordinates() diff --git a/src/consensus/ouroboros/stakeholder.rs b/src/consensus/ouroboros/stakeholder.rs index 5a67107cb..8900c8833 100644 --- a/src/consensus/ouroboros/stakeholder.rs +++ b/src/consensus/ouroboros/stakeholder.rs @@ -14,8 +14,8 @@ use crate::{ address::Address, coin::OwnCoin, keypair::{PublicKey, SecretKey}, - leadcoin::LeadCoin, lead_proof, + leadcoin::LeadCoin, proof::{Proof, ProvingKey, VerifyingKey}, schnorr::SchnorrSecret, }, @@ -384,7 +384,7 @@ impl Stakeholder { let p = self.epoch.get_proof(sl, i, &self.get_leadprovkingkey()); // Sanity check for proof validity) info!("================= Leader proof generated successfully, veryfing... ================="); - let coin = self.epoch.get_coin(sl as usize, i); + let coin = self.epoch.get_coin(sl as usize, i); match lead_proof::verify_lead_proof(&self.get_leadverifyingkey(), &p, &coin.public_inputs()) { Ok(_) => info!("================= Proof veryfied succsessfully! ================="), Err(e) => error!("================= Error during leader proof verification: {} =================", e), diff --git a/src/crypto/leadcoin.rs b/src/crypto/leadcoin.rs index 0a4eba093..90cfb9c92 100644 --- a/src/crypto/leadcoin.rs +++ b/src/crypto/leadcoin.rs @@ -64,10 +64,8 @@ impl LeadCoin { let po_y_y = *po_y_pt.to_affine().coordinates().unwrap().y(); let y_coord_arr = [po_y_x, po_y_y]; let po_y: pallas::Base = - poseidon::Hash::<_, poseidon::P128Pow5T3, poseidon::ConstantLength<2>, 3, 2>::init( - ) - .hash(y_coord_arr); - + poseidon::Hash::<_, poseidon::P128Pow5T3, poseidon::ConstantLength<2>, 3, 2>::init() + .hash(y_coord_arr); let cm_pos = self.idx; let cm_root = { @@ -85,15 +83,8 @@ impl LeadCoin { } current }; - let public_inputs: [pallas::Base; LEAD_PUBLIC_INPUT_LEN] = [ - *po_cm.x(), - *po_cm.y(), - po_nonce, - cm_root.inner(), - *po_pk.x(), - *po_pk.y(), - po_y, - ]; + let public_inputs: [pallas::Base; LEAD_PUBLIC_INPUT_LEN] = + [*po_cm.x(), *po_cm.y(), po_nonce, cm_root.inner(), *po_pk.x(), *po_pk.y(), po_y]; public_inputs } @@ -108,7 +99,7 @@ impl LeadCoin { let lottery_msg_input = [root_sk, nonce]; let lottery_msg: pallas::Base = poseidon::Hash::<_, poseidon::P128Pow5T3, poseidon::ConstantLength<2>, 3, 2>::init() - .hash(lottery_msg_input); + .hash(lottery_msg_input); // let rho_pt: pallas::Point = pedersen_commitment_base(lottery_msg, mod_r_p(rho_mu)); LeadContract { diff --git a/src/zk/circuit/lead_contract.rs b/src/zk/circuit/lead_contract.rs index 39a4477f4..52fa5f9bc 100644 --- a/src/zk/circuit/lead_contract.rs +++ b/src/zk/circuit/lead_contract.rs @@ -9,7 +9,7 @@ use darkfi_sdk::crypto::{ use halo2_gadgets::{ ecc::{ chip::{EccChip, EccConfig}, - FixedPoint, FixedPointBaseField, ScalarFixed,NonIdentityPoint, + FixedPoint, FixedPointBaseField, NonIdentityPoint, ScalarFixed, }, poseidon::{ primitives as poseidon, Hash as PoseidonHash, Pow5Chip as PoseidonChip, @@ -126,7 +126,7 @@ pub struct LeadContract { pub sigma1: Value, pub sigma2: Value, //pub eta : Option, - pub rho : Value, + pub rho: Value, //pub h : Option, // hash of this data //pub ptr: Option, //hash of the previous block } @@ -616,7 +616,7 @@ impl Circuit for LeadContract { layouter.namespace(|| "witness rho"), self.rho.map(|x| x.to_affine()), )?; - rho_commit.constrain_equal(layouter.namespace(||""),&rho)?; + rho_commit.constrain_equal(layouter.namespace(|| ""), &rho)?; let term1 = ar_chip.mul(layouter.namespace(|| "calculate term1"), &sigma1, &coin_value.clone())?; @@ -655,19 +655,13 @@ impl Circuit for LeadContract { LEAD_COIN_COMMIT_Y_OFFSET, )?; - let ref_coin2_cm = NonIdentityPoint::new( ecc_chip.clone(), layouter.namespace(|| "witness coin2 cm"), self.coin2_commit.map(|x| x.to_affine()), )?; - - coin2_commit.constrain_equal( - layouter.namespace(||""), - &ref_coin2_cm - )?; - + coin2_commit.constrain_equal(layouter.namespace(|| ""), &ref_coin2_cm)?; /* layouter.constrain_instance( @@ -694,11 +688,9 @@ impl Circuit for LeadContract { layouter.constrain_instance(coin_pk_x.cell(), config.primary, LEAD_COIN_PK_X_OFFSET)?; layouter.constrain_instance(coin_pk_y.cell(), config.primary, LEAD_COIN_PK_Y_OFFSET)?; - layouter.assign_region(||"", - |mut region| { - region.constrain_equal(sn_commit.cell(), - coin1_sn.cell()) - } + layouter.assign_region( + || "", + |mut region| region.constrain_equal(sn_commit.cell(), coin1_sn.cell()), ); layouter.constrain_instance( @@ -707,7 +699,6 @@ impl Circuit for LeadContract { LEAD_Y_COMMIT_BASE_OFFSET, )?; - Ok(()) } }