From 54dbfcb7acc212200c44f84e60d5ed7abaae5435 Mon Sep 17 00:00:00 2001 From: Mike Rolish Date: Mon, 19 Aug 2024 21:37:15 -0500 Subject: [PATCH] Move dkg to examples --- Cargo.toml | 11 +++-------- {src => examples}/dkg.rs | 14 ++++++++------ src/lib.rs | 1 - 3 files changed, 11 insertions(+), 15 deletions(-) rename {src => examples}/dkg.rs (97%) diff --git a/Cargo.toml b/Cargo.toml index 3674dbc..1472723 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,9 +13,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[[bin]] +[[example]] name = "dkg" -path = "src/dkg.rs" +path = "examples/dkg.rs" [dependencies] hex-literal = "0.4.1" @@ -23,11 +23,6 @@ num-traits = "0.2.19" subtle = "2.6.1" crypto-bigint = "0.6.0-rc.2" sha3 = "0.11.0-pre.4" -tracing-subscriber = "0.3.18" -tracing = "0.1.40" -confy = "0.6.1" -rand = "0.9.0-alpha.2" -serde = { version = "1.0.204", features = ["derive"] } [dev-dependencies] @@ -37,4 +32,4 @@ sha2 = "0.11.0-pre.4" tracing-subscriber = "0.3.18" tracing = "0.1.40" confy = "0.6.1" -rand = "0.9.0-alpha.2" \ No newline at end of file +rand = "0.9.0-alpha.2" diff --git a/src/dkg.rs b/examples/dkg.rs similarity index 97% rename from src/dkg.rs rename to examples/dkg.rs index 36c78ce..99cd60f 100644 --- a/src/dkg.rs +++ b/examples/dkg.rs @@ -1,8 +1,7 @@ -// TODO: to examples dir -use crypto_bigint::U256; use std::collections::HashMap; +use crypto_bigint::U256; use num_traits::{One, Pow, Zero}; -use crate::fields::fp::Fp; +use sylow::Fp; use tracing::{event, Level}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -164,8 +163,12 @@ fn do_round(round_id: u64, quorum: u32) { let x_shares = from_vec_u32(generate_distinct_random_values(quorum as usize, MIN_COEFFICIENT, MAX_COEFFICIENT)); let recipient_index = 0; let mut complaint_count = 0; - // TODO: exclude self + for (recipient_id, recipient) in round_data.participants.iter() { + if dealer_id == recipient_id { + continue; + } + let x_share = x_shares[recipient_index]; let y_share = dealer_secret.eval_polynomial(x_share); let share = DealerShare { @@ -190,11 +193,10 @@ fn do_round(round_id: u64, quorum: u32) { event!(Level::INFO, "End round {round_id}"); } -#[test] fn main() -> Result<(), confy::ConfyError> { tracing_subscriber::fmt().init(); event!(Level::INFO, "Begin dkg::main"); - let config_path = PathBuf::from("dkg.toml"); + let config_path = PathBuf::from("../dkg.toml"); let cfg: MyConfig = confy::load_path(&config_path)?; event!(Level::INFO, "Loaded config: {:?}", cfg); diff --git a/src/lib.rs b/src/lib.rs index 5bcda4c..4ec84ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,7 +19,6 @@ mod groups; mod hasher; mod pairing; mod svdw; -mod dkg; use crate::fields::fp::{FieldExtensionTrait, Fp, Fr}; use crate::groups::g1::G1Projective;