parazyd 3 лет назад
Родитель
Сommit
f6dadf614c
4 измененных файлов с 14 добавлено и 20 удалено
  1. 1 1
      example/less_than.rs
  2. 1 2
      src/consensus/coins.rs
  3. 10 13
      src/zk/circuit/lead_contract.rs
  4. 2 4
      src/zk/circuit/tx_contract.rs

+ 1 - 1
example/less_than.rs

@@ -1,6 +1,6 @@
 use halo2_proofs::{
     circuit::{floor_planner, Layouter, Value},
-    dev::{MockProver},
+    dev::MockProver,
     pasta::pallas,
     plonk::{Advice, Circuit, Column, ConstraintSystem, Error},
 };

+ 1 - 2
src/consensus/coins.rs

@@ -90,8 +90,7 @@ pub fn create_epoch_coins(
     info!("sigma1: {}", sigma1_fbig);
     let sigma1: pallas::Base = fbig2base(sigma1_fbig);
     info!("sigma1 base: {:?}", sigma1);
-    let sigma2_fbig =
-        (c / total_sigma).powf(two.clone()) * (field_p / two);
+    let sigma2_fbig = (c / total_sigma).powf(two.clone()) * (field_p / two);
     info!("sigma2: {}", sigma2_fbig);
     let sigma2: pallas::Base = fbig2base(sigma2_fbig);
     info!("sigma2 base: {:?}", sigma2);

+ 10 - 13
src/zk/circuit/lead_contract.rs

@@ -456,13 +456,12 @@ impl Circuit<pallas::Base> for LeadContract {
         let sn_commit: AssignedCell<pallas::Base, pallas::Base> = {
             // For derivation here, we append one 0 and one 1 to the hashed message.
             // TODO: Add these constants to ouroboros/consts.rs
-            let poseidon_message =
-                [coin1_nonce.clone(), coin1_sk_root.clone(), zero, one.clone()];
+            let poseidon_message = [coin1_nonce.clone(), coin1_sk_root.clone(), zero, one.clone()];
             let poseidon_hasher = PoseidonHash::<_, _, P128Pow5T3, ConstantLength<4>, 3, 2>::init(
                 config.poseidon_chip(),
                 layouter.namespace(|| "sn_commit poseidon init"),
             )?;
-            
+
             poseidon_hasher
                 .hash(layouter.namespace(|| "sn_commit poseidon hash"), poseidon_message)?
         };
@@ -487,7 +486,7 @@ impl Circuit<pallas::Base> for LeadContract {
                         config.poseidon_chip(),
                         layouter.namespace(|| "nullifier poseidon init"),
                     )?;
-                
+
                 poseidon_hasher
                     .hash(layouter.namespace(|| "nullifier poseidon hash"), poseidon_message)?
             };
@@ -522,7 +521,7 @@ impl Circuit<pallas::Base> for LeadContract {
                 config.poseidon_chip(),
                 layouter.namespace(|| "coin1_commit_hash poseidon init"),
             )?;
-            
+
             poseidon_hasher
                 .hash(layouter.namespace(|| "coin1_commit_hash poseidon hash"), poseidon_message)?
         };
@@ -544,7 +543,7 @@ impl Circuit<pallas::Base> for LeadContract {
                 config.poseidon_chip(),
                 layouter.namespace(|| "coin2_nonce poseidon init"),
             )?;
-            
+
             poseidon_hasher
                 .hash(layouter.namespace(|| "coin2_nonce poseidon hash"), poseidon_message)?
         };
@@ -571,7 +570,7 @@ impl Circuit<pallas::Base> for LeadContract {
                         config.poseidon_chip(),
                         layouter.namespace(|| "coin2_commitment_v poseidon init"),
                     )?;
-                
+
                 poseidon_hasher.hash(
                     layouter.namespace(|| "coin2_commitment_v poseidon hash"),
                     poseidon_message,
@@ -604,11 +603,9 @@ impl Circuit<pallas::Base> for LeadContract {
                 config.poseidon_chip(),
                 layouter.namespace(|| "lottery_commit_msg poseidon init"),
             )?;
-            
-            poseidon_hasher.hash(
-                layouter.namespace(|| "lottery_commit_msg poseidon hash"),
-                poseidon_message,
-            )?
+
+            poseidon_hasher
+                .hash(layouter.namespace(|| "lottery_commit_msg poseidon hash"), poseidon_message)?
         };
 
         let lottery_commit_v = {
@@ -631,7 +628,7 @@ impl Circuit<pallas::Base> for LeadContract {
                 config.poseidon_chip(),
                 layouter.namespace(|| "lottery_commit coords poseidon init"),
             )?;
-            
+
             poseidon_hasher.hash(
                 layouter.namespace(|| "lottery_commit coords poseidon hash"),
                 poseidon_message,

+ 2 - 4
src/zk/circuit/tx_contract.rs

@@ -554,8 +554,7 @@ impl Circuit<pallas::Base> for TxContract {
         // ========
         let _com3 = {
             let nullifier2_msg: AssignedCell<Fp, Fp> = {
-                let poseidon_message =
-                    [coin3_pk, coin3_value.clone(), coin3_nonce, one.clone()];
+                let poseidon_message = [coin3_pk, coin3_value.clone(), coin3_nonce, one.clone()];
                 let poseidon_hasher = PoseidonHash::<
                     _,
                     _,
@@ -595,8 +594,7 @@ impl Circuit<pallas::Base> for TxContract {
         // ========
         let _com4 = {
             let nullifier2_msg: AssignedCell<Fp, Fp> = {
-                let poseidon_message =
-                    [coin4_pk, coin4_value.clone(), coin4_nonce, one];
+                let poseidon_message = [coin4_pk, coin4_value.clone(), coin4_nonce, one];
                 let poseidon_hasher = PoseidonHash::<
                     _,
                     _,