Просмотр исходного кода

example: Delete some unnecessary examples.

parazyd 4 лет назад
Родитель
Сommit
0656ae2ca7
4 измененных файлов с 0 добавлено и 186 удалено
  1. 0 15
      Cargo.toml
  2. 0 110
      example/dao.rs
  3. 0 27
      example/tree.rs
  4. 0 34
      example/tui_ex.rs

+ 0 - 15
Cargo.toml

@@ -223,21 +223,11 @@ name = "net"
 path = "example/net.rs"
 required-features = ["async-runtime", "cli", "net"]
 
-[[example]]
-name = "tui"
-path = "example/tui_ex.rs"
-required-features = ["async-runtime", "tui"]
-
 [[example]]
 name = "tx"
 path = "example/tx.rs"
 required-features = ["node"]
 
-[[example]]
-name = "tree"
-path = "example/tree.rs"
-required-features = ["crypto"]
-
 # ZK VM Proof examples
 
 [[example]]
@@ -254,8 +244,3 @@ required-features = ["cli", "crypto", "zkas"]
 name = "burn"
 path = "proof/burn.rs"
 required-features = ["cli", "crypto", "zkas"]
-
-[[example]]
-name = "dao"
-path = "proof/dao.rs"
-required-features = ["cli", "crypto", "zkas"]

+ 0 - 110
example/dao.rs

@@ -1,110 +0,0 @@
-use bitvec::prelude::*;
-use halo2_gadgets::primitives::{
-    poseidon,
-    poseidon::{ConstantLength, P128Pow5T3},
-};
-use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree};
-use pasta_curves::{
-    arithmetic::{CurveAffine, Field, FieldExt},
-    group::{Curve, Group},
-    pallas,
-};
-use rand::rngs::OsRng;
-use simplelog::{ColorChoice::Auto, Config, LevelFilter, TermLogger, TerminalMode::Mixed};
-
-use darkfi::{
-    crypto::{
-        keypair::Keypair,
-        merkle_node::MerkleNode,
-        schnorr::SchnorrSecret,
-        util::{mod_r_p, pedersen_commitment_scalar},
-    },
-    Result,
-};
-
-fn main() -> Result<()> {
-    let loglevel = match option_env!("RUST_LOG") {
-        Some("debug") => LevelFilter::Debug,
-        Some("trace") => LevelFilter::Trace,
-        Some(_) | None => LevelFilter::Info,
-    };
-    TermLogger::init(loglevel, Config::default(), Mixed, Auto)?;
-
-    /*
-    let bincode = include_bytes!("../proof/dao.zk.bin");
-    let zkbin = ZkBinary::decode(bincode)?;
-    */
-
-    // Contract address
-    let a = pallas::Base::random(&mut OsRng);
-    // Money in treasury
-    let t = pallas::Base::from(666);
-    // Serial number
-    let s = pallas::Base::random(&mut OsRng);
-    // Bulla blind
-    let b_b = pallas::Base::random(&mut OsRng);
-
-    let message = [a, t, s, b_b];
-    let hasher = poseidon::Hash::init(P128Pow5T3, ConstantLength::<4>);
-    let bulla = hasher.hash(message);
-
-    // Merkle tree of DAOs
-    let mut tree = BridgeTree::<MerkleNode, 32>::new(100);
-    let dao0 = pallas::Base::random(&mut OsRng);
-    let dao2 = pallas::Base::random(&mut OsRng);
-    tree.append(&MerkleNode(dao0));
-    tree.witness();
-    tree.append(&MerkleNode(bulla));
-    tree.witness();
-    tree.append(&MerkleNode(dao2));
-    tree.witness();
-
-    let (leaf_pos, merkle_path) = tree.authentication_path(&MerkleNode(bulla)).unwrap();
-    let leaf_pos: u64 = leaf_pos.into();
-    let leaf_pos = leaf_pos as u32;
-
-    // Output 0:
-    let output0_val = 42_u64;
-    let output0_dest = pallas::Point::random(&mut OsRng);
-    let output0_coords = output0_dest.to_affine().coordinates().unwrap();
-    let output0_blind = pallas::Base::random(&mut OsRng);
-
-    let message =
-        [pallas::Base::from(output0_val), *output0_coords.x(), *output0_coords.y(), output0_blind];
-    let hasher = poseidon::Hash::init(P128Pow5T3, ConstantLength::<4>);
-    let output0 = hasher.hash(message);
-
-    let authority = Keypair::random(&mut OsRng);
-    let signature = authority.secret.sign(&output0.to_bytes());
-
-    let vote_1 = pallas::Base::from(44);
-    let vote_2 = pallas::Base::from(13);
-    // This is a NO vote
-    let vote_3 = -pallas::Base::from(49);
-
-    let vote_1_blind = pallas::Scalar::random(&mut OsRng);
-    let vote_1_commit = pedersen_commitment_scalar(mod_r_p(vote_1), vote_1_blind);
-
-    let vote_2_blind = pallas::Scalar::random(&mut OsRng);
-    let vote_2_commit = pedersen_commitment_scalar(mod_r_p(vote_2), vote_2_blind);
-
-    let vote_3_blind = pallas::Scalar::random(&mut OsRng);
-    let vote_3_commit = pedersen_commitment_scalar(mod_r_p(vote_3), vote_3_blind);
-
-    let vote_commit = vote_1_commit + vote_2_commit + vote_3_commit;
-    let vote_blinds = vote_1_blind + vote_2_blind + vote_3_blind;
-    let vote_commit_coords = vote_commit.to_affine().coordinates().unwrap();
-
-    /*
-    let number = pallas::Base::from(u64::MAX).to_bytes();
-    let bits = number.view_bits::<Lsb0>();
-    println!("Positive: {:?}", bits);
-
-    //let number = (-pallas::Base::from(u64::MAX)).to_bytes();
-    let number = pallas::Base::from(0).to_bytes();
-    let bits = number.view_bits::<Lsb0>();
-    println!("Negative: {:?}", bits);
-    */
-
-    Ok(())
-}

+ 0 - 27
example/tree.rs

@@ -1,27 +0,0 @@
-use group::ff::Field;
-use incrementalmerkletree::{bridgetree::BridgeTree, Frontier, Tree};
-use pasta_curves::pallas;
-use rand::rngs::OsRng;
-
-use darkfi::{crypto::merkle_node::MerkleNode, Result};
-
-fn main() -> Result<()> {
-    let mut tree = BridgeTree::<MerkleNode, 32>::new(100);
-
-    for i in 0..10 {
-        tree.append(&MerkleNode(pallas::Base::random(&mut OsRng)));
-        if i % 3 == 0 {
-            tree.witness();
-        }
-    }
-
-    let bytes = bincode::serialize(&tree).unwrap();
-    let tree2: BridgeTree<MerkleNode, 32> = bincode::deserialize(&bytes).unwrap();
-
-    let root1 = tree.root();
-    let root2 = tree2.root();
-
-    assert_eq!(root1, root2);
-
-    Ok(())
-}

+ 0 - 34
example/tui_ex.rs

@@ -1,34 +0,0 @@
-use darkfi::{
-    tui::{App, HBox, VBox, Widget},
-    Result,
-};
-
-async fn start() -> Result<()> {
-    let wv1 = vec![Widget::new(0, 0, 0, 0, "V1".into())?];
-
-    let wh1 = vec![Widget::new(0, 0, 0, 0, "H1".into())?];
-
-    let wv2 = vec![Widget::new(0, 0, 0, 0, "V2".into())?];
-
-    let wv3 = vec![Widget::new(0, 0, 0, 0, "V3".into())?, Widget::new(0, 0, 0, 0, "V4".into())?];
-
-    let v_box1 = Box::new(VBox::new(wv1.clone(), 2));
-    let h_box1 = Box::new(HBox::new(wh1.clone(), 2));
-    let v_box2 = Box::new(VBox::new(wv2.clone(), 2));
-    let v_box3 = Box::new(VBox::new(wv3.clone(), 1));
-
-    let mut app = App::new()?;
-
-    app.add_layout(v_box1)?;
-    app.add_layout(h_box1)?;
-    app.add_layout(v_box2)?;
-    app.add_layout(v_box3)?;
-
-    app.run().await?;
-
-    Ok(())
-}
-
-fn main() -> Result<()> {
-    smol::future::block_on(start())
-}