From aa75f85e17699cb84926fa33b1cd800d18abac6e Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Tue, 24 Jan 2023 15:11:22 +0100 Subject: [PATCH 1/6] add a benchmark sketch --- tpke/README.md | 11 ++- tpke/examples/bench_primitives_size.rs | 98 ++++++++++++++++++++++++++ tpke/src/lib.rs | 4 +- 3 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 tpke/examples/bench_primitives_size.rs diff --git a/tpke/README.md b/tpke/README.md index cf7ddad7..89a0d94b 100644 --- a/tpke/README.md +++ b/tpke/README.md @@ -1,9 +1,18 @@ # tpke -## Benchmarking WASM +## Benchmarks + +### Benchmarking WASM Based on `centurion.rs` (docs)[https://github.com/bheisler/criterion.rs/blob/version-0.4/book/src/user_guide/wasi.md#webasseblywasi-benchmarking] +### Benchmarking primitives size + +```sh +cargo run --example bench_primitives_size +``` + + ### Setup ```bash diff --git a/tpke/examples/bench_primitives_size.rs b/tpke/examples/bench_primitives_size.rs new file mode 100644 index 00000000..f7c691a1 --- /dev/null +++ b/tpke/examples/bench_primitives_size.rs @@ -0,0 +1,98 @@ +use ark_serialize::CanonicalSerialize; +use group_threshold_cryptography::{ + encrypt, prepare_combine_simple, setup_simple, share_combine_simple, +}; +use rand_core::RngCore; +use std::fs::{create_dir_all, OpenOptions}; +use std::io::prelude::*; +use std::path::Path; + +pub fn update_benchmark( + threshold: usize, + shares_num: usize, + pubkey_share_serialized_size: usize, + privkey_share_serialized_size: usize, +) { + let dir_path = Path::new("/tmp/benchmark_setup"); + create_dir_all(dir_path).unwrap(); + + let file_path = dir_path.join("results.md"); + eprintln!("Saving setup results to file: {}", file_path.display()); + + if !file_path.exists() { + let mut file = OpenOptions::new() + .create(true) + .write(true) + .open(&file_path) + .unwrap(); + + writeln!( + file, + "|threshold|shares_num|pubkey_share_serialized_size|privkey_share_serialized_size|", + ) + .unwrap(); + + writeln!(file, "|---|---|---|---|",).unwrap(); + } + + let mut file = OpenOptions::new().append(true).open(&file_path).unwrap(); + + writeln!( + file, + "|{}|{}|{}|{}|", + threshold, + shares_num, + pubkey_share_serialized_size, + privkey_share_serialized_size, + ) + .unwrap(); +} + +type E = ark_bls12_381::Bls12_381; + +fn main() { + for shares_num in [2, 4, 8, 16, 32, 64] { + let rng = &mut rand::thread_rng(); + + let msg_size = 256; + let threshold = shares_num * 2 / 3; + + let mut msg: Vec = vec![0u8; msg_size]; + rng.fill_bytes(&mut msg[..]); + let aad: &[u8] = "my-aad".as_bytes(); + + let (pubkey, _privkey, contexts) = + setup_simple::(threshold, shares_num, rng); + + // Ciphertext.commitment is already computed to match U + let ciphertext = encrypt::<_, E>(&msg, aad, &pubkey, rng); + + // Creating decryption shares + let decryption_shares: Vec<_> = contexts + .iter() + .map(|context| context.create_share(&ciphertext)) + .collect(); + + let pub_contexts = &contexts[0].public_decryption_contexts; + let domain: Vec<_> = pub_contexts.iter().map(|c| c.domain).collect(); + let lagrange = prepare_combine_simple::(&domain); + + let _shared_secret = + share_combine_simple::(&decryption_shares, &lagrange); + + let pub_context = &contexts[0].public_decryption_contexts[0]; + + update_benchmark( + threshold, + shares_num, + pub_context + .public_key_share + .public_key_share + .serialized_size(), + contexts[0] + .private_key_share + .private_key_share + .serialized_size(), + ); + } +} diff --git a/tpke/src/lib.rs b/tpke/src/lib.rs index b2be3ff6..e7e1c0ae 100644 --- a/tpke/src/lib.rs +++ b/tpke/src/lib.rs @@ -208,7 +208,7 @@ pub fn setup_simple( let pubkey_shares = subproductdomain::fast_multiexp(&evals.evals, g.into_projective()); let pubkey_share = g.mul(evals.evals[0]); - assert!(pubkey_shares[0] == E::G1Affine::from(pubkey_share)); + debug_assert!(pubkey_shares[0] == E::G1Affine::from(pubkey_share)); // Y, but only when b = 1 - private key shares of participants let privkey_shares = @@ -221,7 +221,7 @@ pub fn setup_simple( let privkey = h.mul(x); let secret = threshold_poly.evaluate(&E::Fr::zero()); - assert_eq!(secret, x); + debug_assert!(secret == x); let mut private_contexts = vec![]; let mut public_contexts = vec![]; From 6c28d48ddc8aa0805b0fdb634564a627baf1f52f Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Fri, 27 Jan 2023 13:31:48 +0100 Subject: [PATCH 2/6] benchmark size of pvss transcripts --- Cargo.lock | 15 ++-- ferveo/Cargo.toml | 3 +- ferveo/README.md | 9 ++ ferveo/examples/bench_primitives_size.rs | 107 +++++++++++++++++++++++ tpke/README.md | 7 -- tpke/examples/bench_primitives_size.rs | 98 --------------------- 6 files changed, 126 insertions(+), 113 deletions(-) create mode 100644 ferveo/README.md create mode 100644 ferveo/examples/bench_primitives_size.rs delete mode 100644 tpke/examples/bench_primitives_size.rs diff --git a/Cargo.lock b/Cargo.lock index 6e875f54..3384344a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -673,7 +673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", - "rand_core 0.6.3", + "rand_core 0.6.4", "typenum", ] @@ -902,6 +902,7 @@ dependencies = [ "pprof", "rand 0.7.3", "rand 0.8.5", + "rand_core 0.6.4", "serde", "serde_bytes", "serde_json", @@ -1002,7 +1003,7 @@ dependencies = [ "itertools", "miracl_core", "rand 0.8.5", - "rand_core 0.6.3", + "rand_core 0.6.4", "rayon", "serde", "serde_with", @@ -1647,7 +1648,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -1667,7 +1668,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", + "rand_core 0.6.4", ] [[package]] @@ -1681,9 +1682,9 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom 0.2.7", ] @@ -2156,7 +2157,7 @@ dependencies = [ "group-threshold-cryptography", "js-sys", "rand 0.8.5", - "rand_core 0.6.3", + "rand_core 0.6.4", "serde", "serde_with", "wasm-bindgen", diff --git a/ferveo/Cargo.toml b/ferveo/Cargo.toml index 007ac763..37015d77 100644 --- a/ferveo/Cargo.toml +++ b/ferveo/Cargo.toml @@ -40,6 +40,7 @@ ark-ed-on-bls12-381 = "0.3.0" group-threshold-cryptography = { path = "../tpke" } ferveo-common = { path = "../ferveo-common" } subproductdomain = { path = "../subproductdomain" } +rand_core = "0.6.4" [dependencies.digest] version = "0.10.0" @@ -60,4 +61,4 @@ harness = false [profile.release] opt-level = 3 -lto = true \ No newline at end of file +lto = true diff --git a/ferveo/README.md b/ferveo/README.md new file mode 100644 index 00000000..6b63e57b --- /dev/null +++ b/ferveo/README.md @@ -0,0 +1,9 @@ +# ferveo + +## Benchmarks + +### Benchmarking primitives size + +```sh +cargo run --example bench_primitives_size +``` diff --git a/ferveo/examples/bench_primitives_size.rs b/ferveo/examples/bench_primitives_size.rs new file mode 100644 index 00000000..500993ae --- /dev/null +++ b/ferveo/examples/bench_primitives_size.rs @@ -0,0 +1,107 @@ +use ark_serialize::CanonicalSerialize; + +use ark_bls12_381::Bls12_381 as EllipticCurve; +use ferveo::*; +use ferveo_common::ExternalValidator; +use rand::prelude::StdRng; +use rand_core::SeedableRng; +use std::fs::{create_dir_all, OpenOptions}; +use std::io::prelude::*; +use std::path::Path; + +pub fn save_data(threshold: usize, shares_num: usize, transcript_size: usize) { + let dir_path = Path::new("/tmp/benchmark_setup"); + create_dir_all(dir_path).unwrap(); + let file_path = dir_path.join("results.md"); + + if !file_path.exists() { + eprintln!("Creating a new file: {}", file_path.display()); + let mut file = OpenOptions::new() + .create(true) + .write(true) + .open(&file_path) + .unwrap(); + writeln!(file, "|threshold|shares_num|pvss_transcript_size|",).unwrap(); + writeln!(file, "|---|---|---|",).unwrap(); + } + + eprintln!("Appending to file: {}", file_path.display()); + let mut file = OpenOptions::new().append(true).open(&file_path).unwrap(); + writeln!(file, "|{}|{}|{}|", threshold, shares_num, transcript_size,) + .unwrap(); +} + +// TODO: Find a way to deduplicate the following methods with benchmarks and test setup + +fn gen_keypairs(num: u32) -> Vec> { + let rng = &mut ark_std::test_rng(); + (0..num) + .map(|_| ferveo_common::Keypair::::new(rng)) + .collect() +} + +fn gen_validators( + keypairs: &[ferveo_common::Keypair], +) -> Vec> { + (0..keypairs.len()) + .map(|i| ExternalValidator { + address: format!("validator_{}", i), + public_key: keypairs[i].public(), + }) + .collect() +} + +fn setup_dkg( + validator: usize, + shares_num: u32, +) -> PubliclyVerifiableDkg { + let keypairs = gen_keypairs(shares_num); + let validators = gen_validators(&keypairs); + let me = validators[validator].clone(); + PubliclyVerifiableDkg::new( + validators, + Params { + tau: 0, + security_threshold: shares_num / 3, + shares_num, + retry_after: 1, + }, + &me, + keypairs[validator], + ) + .expect("Setup failed") +} + +fn setup( + shares_num: u32, + rng: &mut StdRng, +) -> PubliclyVerifiableDkg { + let mut transcripts = vec![]; + for i in 0..shares_num { + let mut dkg = setup_dkg(i as usize, shares_num); + transcripts.push(dkg.share(rng).expect("Test failed")); + } + + let mut dkg = setup_dkg(0, shares_num); + for (sender, pvss) in transcripts.into_iter().enumerate() { + dkg.apply_message(dkg.validators[sender].validator.clone(), pvss) + .expect("Setup failed"); + } + dkg +} + +fn main() { + let rng = &mut StdRng::seed_from_u64(0); + + for shares_num in [2, 4, 8, 16, 32, 64] { + let dkg = setup(shares_num as u32, rng); + let mut transcript_bytes = vec![]; + dkg.vss[&0].serialize(&mut transcript_bytes).unwrap(); + + save_data( + dkg.params.security_threshold as usize, + shares_num, + transcript_bytes.len(), + ); + } +} diff --git a/tpke/README.md b/tpke/README.md index 89a0d94b..e48dc7ea 100644 --- a/tpke/README.md +++ b/tpke/README.md @@ -6,13 +6,6 @@ Based on `centurion.rs` (docs)[https://github.com/bheisler/criterion.rs/blob/version-0.4/book/src/user_guide/wasi.md#webasseblywasi-benchmarking] -### Benchmarking primitives size - -```sh -cargo run --example bench_primitives_size -``` - - ### Setup ```bash diff --git a/tpke/examples/bench_primitives_size.rs b/tpke/examples/bench_primitives_size.rs deleted file mode 100644 index f7c691a1..00000000 --- a/tpke/examples/bench_primitives_size.rs +++ /dev/null @@ -1,98 +0,0 @@ -use ark_serialize::CanonicalSerialize; -use group_threshold_cryptography::{ - encrypt, prepare_combine_simple, setup_simple, share_combine_simple, -}; -use rand_core::RngCore; -use std::fs::{create_dir_all, OpenOptions}; -use std::io::prelude::*; -use std::path::Path; - -pub fn update_benchmark( - threshold: usize, - shares_num: usize, - pubkey_share_serialized_size: usize, - privkey_share_serialized_size: usize, -) { - let dir_path = Path::new("/tmp/benchmark_setup"); - create_dir_all(dir_path).unwrap(); - - let file_path = dir_path.join("results.md"); - eprintln!("Saving setup results to file: {}", file_path.display()); - - if !file_path.exists() { - let mut file = OpenOptions::new() - .create(true) - .write(true) - .open(&file_path) - .unwrap(); - - writeln!( - file, - "|threshold|shares_num|pubkey_share_serialized_size|privkey_share_serialized_size|", - ) - .unwrap(); - - writeln!(file, "|---|---|---|---|",).unwrap(); - } - - let mut file = OpenOptions::new().append(true).open(&file_path).unwrap(); - - writeln!( - file, - "|{}|{}|{}|{}|", - threshold, - shares_num, - pubkey_share_serialized_size, - privkey_share_serialized_size, - ) - .unwrap(); -} - -type E = ark_bls12_381::Bls12_381; - -fn main() { - for shares_num in [2, 4, 8, 16, 32, 64] { - let rng = &mut rand::thread_rng(); - - let msg_size = 256; - let threshold = shares_num * 2 / 3; - - let mut msg: Vec = vec![0u8; msg_size]; - rng.fill_bytes(&mut msg[..]); - let aad: &[u8] = "my-aad".as_bytes(); - - let (pubkey, _privkey, contexts) = - setup_simple::(threshold, shares_num, rng); - - // Ciphertext.commitment is already computed to match U - let ciphertext = encrypt::<_, E>(&msg, aad, &pubkey, rng); - - // Creating decryption shares - let decryption_shares: Vec<_> = contexts - .iter() - .map(|context| context.create_share(&ciphertext)) - .collect(); - - let pub_contexts = &contexts[0].public_decryption_contexts; - let domain: Vec<_> = pub_contexts.iter().map(|c| c.domain).collect(); - let lagrange = prepare_combine_simple::(&domain); - - let _shared_secret = - share_combine_simple::(&decryption_shares, &lagrange); - - let pub_context = &contexts[0].public_decryption_contexts[0]; - - update_benchmark( - threshold, - shares_num, - pub_context - .public_key_share - .public_key_share - .serialized_size(), - contexts[0] - .private_key_share - .private_key_share - .serialized_size(), - ); - } -} From feb8d8077564b43a5dae255b30e842ae75e2e85b Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Fri, 27 Jan 2023 16:32:55 +0100 Subject: [PATCH 3/6] benchmark per ratio with no duplicates --- ferveo/examples/bench_primitives_size.rs | 75 ++++++++++++++++-------- 1 file changed, 52 insertions(+), 23 deletions(-) diff --git a/ferveo/examples/bench_primitives_size.rs b/ferveo/examples/bench_primitives_size.rs index 500993ae..56655aa3 100644 --- a/ferveo/examples/bench_primitives_size.rs +++ b/ferveo/examples/bench_primitives_size.rs @@ -1,33 +1,43 @@ use ark_serialize::CanonicalSerialize; +use std::collections::BTreeSet; use ark_bls12_381::Bls12_381 as EllipticCurve; use ferveo::*; use ferveo_common::ExternalValidator; +use itertools::iproduct; use rand::prelude::StdRng; use rand_core::SeedableRng; use std::fs::{create_dir_all, OpenOptions}; use std::io::prelude::*; -use std::path::Path; +use std::path::PathBuf; -pub fn save_data(threshold: usize, shares_num: usize, transcript_size: usize) { - let dir_path = Path::new("/tmp/benchmark_setup"); +const OUTPUT_DIR_PATH: &str = "/tmp/benchmark_setup"; +const OUTPUT_FILE_NAME: &str = "results.md"; + +pub fn create_or_truncate_output_file() -> std::io::Result<()> { + let file_path = PathBuf::from(OUTPUT_DIR_PATH).join(OUTPUT_FILE_NAME); + eprintln!("Creating output file at {}", file_path.display()); + + let dir_path = PathBuf::from(OUTPUT_DIR_PATH); create_dir_all(dir_path).unwrap(); - let file_path = dir_path.join("results.md"); - - if !file_path.exists() { - eprintln!("Creating a new file: {}", file_path.display()); - let mut file = OpenOptions::new() - .create(true) - .write(true) - .open(&file_path) - .unwrap(); - writeln!(file, "|threshold|shares_num|pvss_transcript_size|",).unwrap(); - writeln!(file, "|---|---|---|",).unwrap(); - } + + let mut file = OpenOptions::new() + .write(true) + .create(true) + .truncate(true) + .open(file_path)?; + file.sync_all()?; + + writeln!(file, "|shares_num|threshold|pvss_transcript_size|",)?; + writeln!(file, "|---|---|---|---|") +} + +pub fn save_data(shares_num: usize, threshold: usize, transcript_size: usize) { + let file_path = PathBuf::from(OUTPUT_DIR_PATH).join(OUTPUT_FILE_NAME); eprintln!("Appending to file: {}", file_path.display()); let mut file = OpenOptions::new().append(true).open(&file_path).unwrap(); - writeln!(file, "|{}|{}|{}|", threshold, shares_num, transcript_size,) + writeln!(file, "{}|{}|{}|", shares_num, threshold, transcript_size) .unwrap(); } @@ -54,6 +64,7 @@ fn gen_validators( fn setup_dkg( validator: usize, shares_num: u32, + security_threshold: u32, ) -> PubliclyVerifiableDkg { let keypairs = gen_keypairs(shares_num); let validators = gen_validators(&keypairs); @@ -62,7 +73,7 @@ fn setup_dkg( validators, Params { tau: 0, - security_threshold: shares_num / 3, + security_threshold, shares_num, retry_after: 1, }, @@ -74,15 +85,16 @@ fn setup_dkg( fn setup( shares_num: u32, + security_threshold: u32, rng: &mut StdRng, ) -> PubliclyVerifiableDkg { let mut transcripts = vec![]; for i in 0..shares_num { - let mut dkg = setup_dkg(i as usize, shares_num); + let mut dkg = setup_dkg(i as usize, shares_num, security_threshold); transcripts.push(dkg.share(rng).expect("Test failed")); } - let mut dkg = setup_dkg(0, shares_num); + let mut dkg = setup_dkg(0, shares_num, security_threshold); for (sender, pvss) in transcripts.into_iter().enumerate() { dkg.apply_message(dkg.validators[sender].validator.clone(), pvss) .expect("Setup failed"); @@ -93,14 +105,31 @@ fn setup( fn main() { let rng = &mut StdRng::seed_from_u64(0); - for shares_num in [2, 4, 8, 16, 32, 64] { - let dkg = setup(shares_num as u32, rng); + create_or_truncate_output_file().unwrap(); + + let share_num_vec = [2, 4, 8, 16, 32, 64]; + let threshold_ratio_vec = [0.51, 0.66, 0.8, 1.0]; + + // Create benchmark parameters without duplicates + let configs = iproduct!(&share_num_vec, &threshold_ratio_vec) + .map(|(shares_num, threshold_ratio)| { + let threshold = + (*shares_num as f64 * threshold_ratio).ceil() as u32; + (shares_num, threshold) + }) + .collect::>(); + + println!("Running benchmarks for {:?}", configs); + + for (shares_num, threshold) in configs { + println!("shares_num: {}, threshold: {}", shares_num, threshold); + let dkg = setup(*shares_num as u32, threshold, rng); let mut transcript_bytes = vec![]; dkg.vss[&0].serialize(&mut transcript_bytes).unwrap(); save_data( - dkg.params.security_threshold as usize, - shares_num, + threshold as usize, + *shares_num as usize, transcript_bytes.len(), ); } From 076f2610c753bb02cd5fe5a2219679f63cdffdea Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Fri, 27 Jan 2023 18:04:18 +0100 Subject: [PATCH 4/6] fix switched columns --- ferveo/examples/bench_primitives_size.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ferveo/examples/bench_primitives_size.rs b/ferveo/examples/bench_primitives_size.rs index 56655aa3..c03a6a94 100644 --- a/ferveo/examples/bench_primitives_size.rs +++ b/ferveo/examples/bench_primitives_size.rs @@ -128,8 +128,8 @@ fn main() { dkg.vss[&0].serialize(&mut transcript_bytes).unwrap(); save_data( - threshold as usize, *shares_num as usize, + threshold as usize, transcript_bytes.len(), ); } From 6966b28e3ee273f51c73402ac986a03e10743139 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Fri, 27 Jan 2023 22:50:21 +0100 Subject: [PATCH 5/6] set polynomial degree to t-1 in pvss --- ferveo/src/vss/pvss.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ferveo/src/vss/pvss.rs b/ferveo/src/vss/pvss.rs index 719a0ab0..d622e009 100644 --- a/ferveo/src/vss/pvss.rs +++ b/ferveo/src/vss/pvss.rs @@ -72,7 +72,7 @@ impl PubliclyVerifiableSS { ) -> Result { // Our random polynomial, \phi(x) = s + \sum_{i=1}^{t-1} a_i x^i let mut phi = DensePolynomial::::rand( - (dkg.params.shares_num - dkg.params.security_threshold) as usize, + (dkg.params.security_threshold - 1) as usize, rng, ); phi.coeffs[0] = *s; // setting the first coefficient to secret value @@ -302,10 +302,7 @@ mod test_pvss { // check that the chosen secret coefficient is correct assert_eq!(pvss.coeffs[0], G1::prime_subgroup_generator().mul(s)); //check that a polynomial of the correct degree was created - assert_eq!( - pvss.coeffs.len(), - dkg.params.security_threshold as usize + 1 - ); + assert_eq!(pvss.coeffs.len(), dkg.params.security_threshold as usize); // check that the correct number of shares were created assert_eq!(pvss.shares.len(), dkg.validators.len()); // check that the prove of knowledge is correct @@ -344,7 +341,7 @@ mod test_pvss { //check that a polynomial of the correct degree was created assert_eq!( aggregate.coeffs.len(), - dkg.params.security_threshold as usize + 1 + dkg.params.security_threshold as usize ); // check that the correct number of shares were created assert_eq!(aggregate.shares.len(), dkg.validators.len()); From 6f1b7d4c7086517f7960a0388acd17baf78504b1 Mon Sep 17 00:00:00 2001 From: Piotr Roslaniec Date: Mon, 30 Jan 2023 10:53:55 +0100 Subject: [PATCH 6/6] size is expressed in bytes --- ferveo/examples/bench_primitives_size.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ferveo/examples/bench_primitives_size.rs b/ferveo/examples/bench_primitives_size.rs index c03a6a94..e7a0857b 100644 --- a/ferveo/examples/bench_primitives_size.rs +++ b/ferveo/examples/bench_primitives_size.rs @@ -28,17 +28,25 @@ pub fn create_or_truncate_output_file() -> std::io::Result<()> { .open(file_path)?; file.sync_all()?; - writeln!(file, "|shares_num|threshold|pvss_transcript_size|",)?; + writeln!(file, "|shares_num|threshold|pvss_transcript_size_bytes|",)?; writeln!(file, "|---|---|---|---|") } -pub fn save_data(shares_num: usize, threshold: usize, transcript_size: usize) { +pub fn save_data( + shares_num: usize, + threshold: usize, + transcript_size_bytes: usize, +) { let file_path = PathBuf::from(OUTPUT_DIR_PATH).join(OUTPUT_FILE_NAME); eprintln!("Appending to file: {}", file_path.display()); let mut file = OpenOptions::new().append(true).open(&file_path).unwrap(); - writeln!(file, "{}|{}|{}|", shares_num, threshold, transcript_size) - .unwrap(); + writeln!( + file, + "{}|{}|{}|", + shares_num, threshold, transcript_size_bytes + ) + .unwrap(); } // TODO: Find a way to deduplicate the following methods with benchmarks and test setup