Browse Source

cargo fmt

narodnik 5 years ago
parent
commit
9cc5b39f2a

+ 1 - 1
src/bin/dfi.rs

@@ -1,10 +1,10 @@
 extern crate clap;
 use async_executor::Executor;
-use easy_parallel::Parallel;
 use drk::rpc::adapter::RpcAdapter;
 use drk::rpc::jsonserver;
 use drk::rpc::options::ProgramOptions;
 use drk::Result;
+use easy_parallel::Parallel;
 use std::sync::Arc;
 
 /*

+ 2 - 7
src/bin/tx.rs

@@ -71,18 +71,14 @@ impl MemoryState {
         for (coin, enc_note) in update.coins.into_iter().zip(update.enc_notes.into_iter()) {
             // Add the new coins to the merkle tree
             let node = Node::from_coin(&coin);
-            self.tree
-                .append(node)
-                .expect("Append to merkle tree");
+            self.tree.append(node).expect("Append to merkle tree");
 
             // Keep track of all merkle roots that have existed
             self.merkle_roots.push(self.tree.root());
 
             // Also update all the coin witnesses
             for (_, _, _, witness) in self.own_coins.iter_mut() {
-                witness
-                    .append(node)
-                    .expect("append to witness");
+                witness.append(node).expect("append to witness");
             }
 
             if let Some((note, secret)) = self.try_decrypt_note(enc_note) {
@@ -296,4 +292,3 @@ fn main() {
         state.apply(update);
     }
 }
-

+ 5 - 2
src/circuit/spend_contract.rs

@@ -264,7 +264,9 @@ impl Circuit<bls12_381::Scalar> for SpendContract {
 
             // Line 180: conditionally_reverse left right current branch is_right
             let (left, right) = num::AllocatedNum::conditionally_reverse(
-                cs.namespace(|| "Line 180: conditionally_reverse left right current branch is_right"),
+                cs.namespace(|| {
+                    "Line 180: conditionally_reverse left right current branch is_right"
+                }),
                 &current,
                 &branch,
                 &is_right,
@@ -274,7 +276,8 @@ impl Circuit<bls12_381::Scalar> for SpendContract {
             let left = left.to_bits_le(cs.namespace(|| "Line 183: scalar_as_binary left left"))?;
 
             // Line 184: scalar_as_binary right right
-            let right = right.to_bits_le(cs.namespace(|| "Line 184: scalar_as_binary right right"))?;
+            let right =
+                right.to_bits_le(cs.namespace(|| "Line 184: scalar_as_binary right right"))?;
 
             // Line 185: alloc_binary preimage
             let mut preimage = vec![];

+ 4 - 2
src/crypto/coin.rs

@@ -1,6 +1,9 @@
 use std::io;
 
-use crate::{error::Result, serial::{Decodable, Encodable}};
+use crate::{
+    error::Result,
+    serial::{Decodable, Encodable},
+};
 
 pub struct Coin {
     pub repr: [u8; 32],
@@ -25,4 +28,3 @@ impl Decodable for Coin {
         })
     }
 }
-

+ 7 - 2
src/crypto/node.rs

@@ -5,7 +5,10 @@ use lazy_static::lazy_static;
 use std::io;
 
 use super::{coin::Coin, merkle::Hashable};
-use crate::{error::Result, serial::{Decodable, Encodable}};
+use crate::{
+    error::Result,
+    serial::{Decodable, Encodable},
+};
 
 pub const SAPLING_COMMITMENT_TREE_DEPTH: usize = 6;
 
@@ -72,7 +75,9 @@ impl Node {
     }
 
     pub fn from_coin(coin: &Coin) -> Self {
-        Self { repr: hash_coin(&coin.repr).to_repr() }
+        Self {
+            repr: hash_coin(&coin.repr).to_repr(),
+        }
     }
 }
 

+ 4 - 1
src/crypto/nullifier.rs

@@ -1,6 +1,9 @@
 use std::io;
 
-use crate::{error::Result, serial::{Decodable, Encodable}};
+use crate::{
+    error::Result,
+    serial::{Decodable, Encodable},
+};
 
 pub struct Nullifier {
     pub repr: [u8; 32],

+ 3 - 6
src/crypto/spend_proof.rs

@@ -8,11 +8,11 @@ use rand::rngs::OsRng;
 use std::io;
 use std::time::Instant;
 
-use super::node::{SAPLING_COMMITMENT_TREE_DEPTH, merkle_hash, Node};
+use super::node::{merkle_hash, Node, SAPLING_COMMITMENT_TREE_DEPTH};
+use super::nullifier::Nullifier;
 use crate::circuit::spend_contract::SpendContract;
 use crate::error::Result;
 use crate::serial::{Decodable, Encodable};
-use super::nullifier::Nullifier;
 
 pub struct SpendRevealedValues {
     pub value_commit: jubjub::SubgroupPoint,
@@ -206,10 +206,7 @@ pub fn create_spend_proof(
     merkle_path: Vec<(bls12_381::Scalar, bool)>,
     signature_secret: jubjub::Fr,
 ) -> (groth16::Proof<Bls12>, SpendRevealedValues) {
-    assert_eq!(
-        merkle_path.len(),
-        SAPLING_COMMITMENT_TREE_DEPTH
-    );
+    assert_eq!(merkle_path.len(), SAPLING_COMMITMENT_TREE_DEPTH);
     let mut branch: [_; SAPLING_COMMITMENT_TREE_DEPTH] = Default::default();
     let mut is_right: [_; SAPLING_COMMITMENT_TREE_DEPTH] = Default::default();
     for (i, (branch_i, is_right_i)) in merkle_path.iter().enumerate() {

+ 5 - 2
src/tx/builder.rs

@@ -7,7 +7,9 @@ use super::{
     partial::{PartialTransaction, PartialTransactionClearInput, PartialTransactionInput},
     Transaction, TransactionClearInput, TransactionInput, TransactionOutput,
 };
-use crate::crypto::{merkle::MerklePath, node::Node, create_mint_proof, create_spend_proof, note::Note, schnorr};
+use crate::crypto::{
+    create_mint_proof, create_spend_proof, merkle::MerklePath, node::Node, note::Note, schnorr,
+};
 use crate::serial::Encodable;
 
 pub struct TransactionBuilder {
@@ -85,7 +87,8 @@ impl TransactionBuilder {
             // make proof
 
             // TODO: Some stupid glue code. Need to sort this out
-            let auth_path: Vec<(bls12_381::Scalar, bool)> = input.merkle_path
+            let auth_path: Vec<(bls12_381::Scalar, bool)> = input
+                .merkle_path
                 .auth_path
                 .iter()
                 .map(|(node, b)| ((*node).into(), *b))