Skip to content

Commit

Permalink
Move dkg to examples
Browse files Browse the repository at this point in the history
  • Loading branch information
merolish committed Aug 20, 2024
1 parent 14e6e45 commit 54dbfcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
11 changes: 3 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,16 @@ 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"
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]
Expand All @@ -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"
rand = "0.9.0-alpha.2"
14 changes: 8 additions & 6 deletions src/dkg.rs → examples/dkg.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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);

Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 54dbfcb

Please sign in to comment.