mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 07:08:05 -05:00
removed errors that were overwritten by cargo fmt... and ran cargo fmt :)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use bellman::{groth16, Circuit, ConstraintSystem, SynthesisError};
|
||||
use sapvi::bls_extensions::BlsStringConversion;
|
||||
use std::rc::Rc;
|
||||
use std::{cell::RefCell, collections::HashMap};
|
||||
use std::time::Instant;
|
||||
use std::{cell::RefCell, collections::HashMap};
|
||||
// use fnv::FnvHashMap;
|
||||
use itertools::Itertools;
|
||||
|
||||
|
||||
@@ -84,13 +84,14 @@ impl model::Vertex for InstanceRaw {
|
||||
attributes: &[
|
||||
wgpu::VertexAttribute {
|
||||
offset: 0,
|
||||
// While our vertex shader only uses locations 0, and 1 now, in later tutorials we'll
|
||||
// be using 2, 3, and 4, for Vertex. We'll start at slot 5 not conflict with them later
|
||||
// While our vertex shader only uses locations 0, and 1 now, in later tutorials
|
||||
// we'll be using 2, 3, and 4, for Vertex. We'll start at
|
||||
// slot 5 not conflict with them later
|
||||
shader_location: 5,
|
||||
format: wgpu::VertexFormat::Float4,
|
||||
},
|
||||
// A mat4 takes up 4 vertex slots as it is technically 4 vec4s. We need to define a slot
|
||||
// for each vec4. We don't have to do this in code though.
|
||||
// A mat4 takes up 4 vertex slots as it is technically 4 vec4s. We need to define a
|
||||
// slot for each vec4. We don't have to do this in code though.
|
||||
wgpu::VertexAttribute {
|
||||
offset: mem::size_of::<[f32; 4]>() as wgpu::BufferAddress,
|
||||
shader_location: 6,
|
||||
|
||||
@@ -1,24 +1,10 @@
|
||||
extern crate clap;
|
||||
use async_executor::Executor;
|
||||
use async_native_tls::TlsAcceptor;
|
||||
use async_std::sync::Mutex;
|
||||
use easy_parallel::Parallel;
|
||||
use http_types::{Request, Response, StatusCode};
|
||||
use log::*;
|
||||
use sapvi::rpc::adapter::RpcAdapter;
|
||||
use sapvi::rpc::jsonserver;
|
||||
use sapvi::rpc::jsonserver::RpcInterface;
|
||||
use sapvi::rpc::options::ProgramOptions;
|
||||
use sapvi::{net, Result};
|
||||
use serde_json::json;
|
||||
use smol::Async;
|
||||
use std::net::SocketAddr;
|
||||
use std::net::TcpListener;
|
||||
use sapvi::rpc::options::ProgramOptions;
|
||||
use easy_parallel::Parallel;
|
||||
use sapvi::rpc::jsonserver;
|
||||
use sapvi::Result;
|
||||
use sapvi::rpc::adapter::RpcAdapter;
|
||||
use std::sync::Arc;
|
||||
|
||||
/*
|
||||
@@ -153,8 +139,8 @@ async fn start2(executor: Arc<Executor<'_>>, options: ProgramOptions) -> Result<
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// let connection_slots = if let Some(connection_slots) = app.value_of("CONNECT_SLOTS") {
|
||||
// connection_slots.parse()?
|
||||
// let connection_slots = if let Some(connection_slots) =
|
||||
// app.value_of("CONNECT_SLOTS") { connection_slots.parse()?
|
||||
// } else {
|
||||
// 0
|
||||
// };
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
use bellman::groth16;
|
||||
use bitvec::{order::Lsb0, view::AsBits};
|
||||
use bls12_381::Bls12;
|
||||
use ff::{Field, PrimeField};
|
||||
use group::Curve;
|
||||
use group::Group;
|
||||
use rand::rngs::OsRng;
|
||||
use std::path::Path;
|
||||
|
||||
@@ -75,10 +72,12 @@ impl MemoryState {
|
||||
if let Some((note, secret)) = self.try_decrypt_note(enc_note) {
|
||||
// We need to keep track of the witness for this coin.
|
||||
// This allows us to prove inclusion of the coin in the merkle tree with ZK.
|
||||
// Just as we update the merkle tree with every new coin, so we do the same with the witness.
|
||||
// Just as we update the merkle tree with every new coin, so we do the same with
|
||||
// the witness.
|
||||
|
||||
// Derive the current witness from the current tree.
|
||||
// This is done right after we add our coin to the tree (but before any other coins are added)
|
||||
// This is done right after we add our coin to the tree (but before any other
|
||||
// coins are added)
|
||||
|
||||
// Make a new witness for this coin
|
||||
let witness = IncrementalWitness::from_tree(&self.tree);
|
||||
@@ -167,7 +166,8 @@ fn main() {
|
||||
|
||||
// Step 2: wallet1 receive's payment from the cashier
|
||||
|
||||
// Wallet1 is receiving tx, and for every new coin it finds, it adds to its merkle tree
|
||||
// Wallet1 is receiving tx, and for every new coin it finds, it adds to its
|
||||
// merkle tree
|
||||
{
|
||||
// Here we simulate 5 fake random coins, adding them to our tree.
|
||||
let tree = &mut state.tree;
|
||||
|
||||
@@ -14,9 +14,10 @@ pub fn sapling_ka_agree(esk: &jubjub::Fr, pk_d: &jubjub::ExtendedPoint) -> jubju
|
||||
// ExtendedPoint::mul_by_cofactor in the jubjub crate.
|
||||
|
||||
// ExtendedPoint::multiply currently just implements double-and-add,
|
||||
// so using wNAF is a concrete speed improvement (as it operates over a window of bits
|
||||
// instead of individual bits).
|
||||
// We want that to be fast because it's in the hot path for trial decryption of notes on chain.
|
||||
// so using wNAF is a concrete speed improvement (as it operates over a window
|
||||
// of bits instead of individual bits).
|
||||
// We want that to be fast because it's in the hot path for trial decryption of
|
||||
// notes on chain.
|
||||
let mut wnaf = group::Wnaf::new();
|
||||
wnaf.scalar(esk).base(*pk_d).clear_cofactor()
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//! Implementation of a Merkle tree of commitments used to prove the existence of notes.
|
||||
//! Implementation of a Merkle tree of commitments used to prove the existence
|
||||
//! of notes.
|
||||
|
||||
//use byteorder::{LittleEndian, ReadBytesExt};
|
||||
use std::collections::VecDeque;
|
||||
@@ -45,8 +46,8 @@ impl<Node: Hashable> PathFiller<Node> {
|
||||
|
||||
/// A Merkle tree of note commitments.
|
||||
///
|
||||
/// The depth of the Merkle tree is fixed at 32, equal to the depth of the Sapling
|
||||
/// commitment tree.
|
||||
/// The depth of the Merkle tree is fixed at 32, equal to the depth of the
|
||||
/// Sapling commitment tree.
|
||||
#[derive(Clone)]
|
||||
pub struct CommitmentTree<Node: Hashable> {
|
||||
left: Option<Node>,
|
||||
@@ -187,11 +188,12 @@ impl<Node: Hashable> CommitmentTree<Node> {
|
||||
}
|
||||
}
|
||||
|
||||
/// An updatable witness to a path from a position in a particular [`CommitmentTree`].
|
||||
/// An updatable witness to a path from a position in a particular
|
||||
/// [`CommitmentTree`].
|
||||
///
|
||||
/// Appending the same commitments in the same order to both the original
|
||||
/// [`CommitmentTree`] and this `IncrementalWitness` will result in a witness to the path
|
||||
/// from the target position to the root of the updated tree.
|
||||
/// [`CommitmentTree`] and this `IncrementalWitness` will result in a witness to
|
||||
/// the path from the target position to the root of the updated tree.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
@@ -227,8 +229,8 @@ pub struct IncrementalWitness<Node: Hashable> {
|
||||
}
|
||||
|
||||
impl<Node: Hashable> IncrementalWitness<Node> {
|
||||
/// Creates an `IncrementalWitness` for the most recent commitment added to the given
|
||||
/// [`CommitmentTree`].
|
||||
/// Creates an `IncrementalWitness` for the most recent commitment added to
|
||||
/// the given [`CommitmentTree`].
|
||||
pub fn from_tree(tree: &CommitmentTree<Node>) -> IncrementalWitness<Node> {
|
||||
IncrementalWitness {
|
||||
tree: tree.clone(),
|
||||
@@ -401,7 +403,8 @@ impl<Node: Hashable> IncrementalWitness<Node> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A path from a position in a particular commitment tree to the root of that tree.
|
||||
/// A path from a position in a particular commitment tree to the root of that
|
||||
/// tree.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct MerklePath<Node: Hashable> {
|
||||
pub auth_path: Vec<(Node, bool)>,
|
||||
@@ -484,7 +487,8 @@ impl<Node: Hashable> MerklePath<Node> {
|
||||
}
|
||||
*/
|
||||
|
||||
/// Returns the root of the tree corresponding to this path applied to `leaf`.
|
||||
/// Returns the root of the tree corresponding to this path applied to
|
||||
/// `leaf`.
|
||||
pub fn root(&self, leaf: Node) -> Node {
|
||||
self.auth_path
|
||||
.iter()
|
||||
|
||||
@@ -180,7 +180,7 @@ fn main() {
|
||||
// .map(|_| Scalar::random(&mut OsRng))
|
||||
// .collect::<Vec<_>>();
|
||||
|
||||
let mut constants = Vec::new();
|
||||
let constants = Vec::new();
|
||||
/*
|
||||
for const_str in mimc_constants() {
|
||||
let bytes = from_slice!(&hex::decode(const_str).unwrap(), 32);
|
||||
@@ -258,11 +258,13 @@ fn main() {
|
||||
}
|
||||
let proving_avg = total_proving / SAMPLES;
|
||||
//let proving_avg =
|
||||
// proving_avg.subsec_nanos() as f64 / 1_000_000_000f64 + (proving_avg.as_secs() as f64);
|
||||
// proving_avg.subsec_nanos() as f64 / 1_000_000_000f64 +
|
||||
// (proving_avg.as_secs() as f64);
|
||||
|
||||
let verifying_avg = total_verifying / SAMPLES;
|
||||
//let verifying_avg =
|
||||
// verifying_avg.subsec_nanos() as f64 / 1_000_000_000f64 + (verifying_avg.as_secs() as f64);
|
||||
// verifying_avg.subsec_nanos() as f64 / 1_000_000_000f64 +
|
||||
// (verifying_avg.as_secs() as f64);
|
||||
|
||||
println!("Average proving time: {:?} seconds", proving_avg);
|
||||
println!("Average verifying time: {:?} seconds", verifying_avg);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::rpc::options::ProgramOptions;
|
||||
use crate::rpc::adapter::RpcAdapter;
|
||||
use crate::{net, serial, Error, Result};
|
||||
use crate::rpc::options::ProgramOptions;
|
||||
use crate::{net, Error, Result};
|
||||
use async_executor::Executor;
|
||||
use async_native_tls::TlsAcceptor;
|
||||
use async_std::sync::Mutex;
|
||||
@@ -74,7 +74,7 @@ pub async fn listen(
|
||||
pub async fn start(
|
||||
executor: Arc<Executor<'_>>,
|
||||
options: ProgramOptions,
|
||||
adapter: Arc<RpcAdapter>,
|
||||
_adapter: Arc<RpcAdapter>,
|
||||
) -> Result<()> {
|
||||
let p2p = net::P2p::new(options.network_settings);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use std::net::SocketAddr;
|
||||
use crate::{net, Result};
|
||||
use std::net::SocketAddr;
|
||||
|
||||
pub struct ProgramOptions {
|
||||
pub network_settings: net::Settings,
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ pub fn deserialize<T: Decodable>(data: &[u8]) -> Result<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Deserialize an object from a vector, but will not report an error if said deserialization
|
||||
/// doesn't consume the entire vector.
|
||||
/// Deserialize an object from a vector, but will not report an error if said
|
||||
/// deserialization doesn't consume the entire vector.
|
||||
pub fn deserialize_partial<T: Decodable>(data: &[u8]) -> Result<(T, usize)> {
|
||||
let mut decoder = Cursor::new(data);
|
||||
let rv = Decodable::decode(&mut decoder)?;
|
||||
|
||||
@@ -2,8 +2,6 @@ use bellman::groth16;
|
||||
use bls12_381::Bls12;
|
||||
use ff::Field;
|
||||
use rand::rngs::OsRng;
|
||||
use std::collections::HashMap;
|
||||
use std::io;
|
||||
|
||||
use super::{
|
||||
partial::{PartialTransaction, PartialTransactionClearInput, PartialTransactionInput},
|
||||
|
||||
@@ -8,9 +8,8 @@ use std::io;
|
||||
|
||||
use self::partial::{PartialTransactionClearInput, PartialTransactionInput};
|
||||
use crate::crypto::{
|
||||
note::EncryptedNote,
|
||||
schnorr, verify_mint_proof,
|
||||
verify_spend_proof, MintRevealedValues, SpendRevealedValues,
|
||||
note::EncryptedNote, schnorr, verify_mint_proof, verify_spend_proof, MintRevealedValues,
|
||||
SpendRevealedValues,
|
||||
};
|
||||
use crate::error::Result;
|
||||
use crate::impl_vec;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
use bellman::groth16;
|
||||
use bls12_381::Bls12;
|
||||
use ff::Field;
|
||||
use rand::rngs::OsRng;
|
||||
use std::collections::HashMap;
|
||||
use std::io;
|
||||
|
||||
use super::{Transaction, TransactionClearInput, TransactionInput, TransactionOutput};
|
||||
@@ -63,7 +60,7 @@ impl Encodable for PartialTransactionClearInput {
|
||||
len += self.signature_public.encode(&mut s)?;
|
||||
Ok(len)
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Decodable for PartialTransactionClearInput {
|
||||
fn decode<D: io::Read>(mut d: D) -> Result<Self> {
|
||||
Ok(Self {
|
||||
|
||||
Reference in New Issue
Block a user