Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion fastcrypto-tbls/benches/polynomial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,37 @@ use std::num::NonZeroU16;

mod polynomial_benches {
use super::*;
use fastcrypto_tbls::threshold_schnorr::gao::RSDecoder;
use fastcrypto_tbls::threshold_schnorr::S;
use fastcrypto_tbls::types::ShareIndex;
use itertools::Itertools;

fn rs_decoder(c: &mut Criterion) {
const SIZES: [usize; 4] = [128, 256, 512, 1024];

for n in SIZES {
let k = n / 3;
let a = (1..=n)
.map(|i| ShareIndex::new(i as u16).unwrap())
.collect_vec();
let decoder = RSDecoder::new(a.clone(), k);

let message: Vec<S> = (0..k).map(|i| S::from((i * 10) as u128)).collect();
let code_word = decoder.encode(message.clone()).unwrap();

// Introduce errors
let mut received = code_word.clone();
received[4] = S::from(20u128); // Error at position 4
received[2] = S::from(200u128); // Error at position 2

let mut rs_decoder: BenchmarkGroup<_> = c.benchmark_group("RS Decoder");
rs_decoder.bench_function(format!("n={}, k={}", n, k).as_str(), |b| {
b.iter(|| {
decoder.decode(&received).unwrap();
})
});
}
}

fn polynomials(c: &mut Criterion) {
const SIZES: [usize; 7] = [128, 256, 512, 1024, 2048, 4096, 8192];
Expand Down Expand Up @@ -77,7 +108,7 @@ mod polynomial_benches {
criterion_group! {
name = polynomial_benches;
config = Criterion::default();
targets = polynomials,
targets = polynomials, rs_decoder,
}
}

Expand Down
4 changes: 2 additions & 2 deletions fastcrypto-tbls/src/dkg_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ where
return Err(FastCryptoError::InvalidMessage);
};

if self.t as usize != msg.vss_pk.degree() + 1 {
if self.t as usize != msg.vss_pk.degree_bound() + 1 {
warn!(
"DKG: Message sanity check failed for id {}, expected degree={}, got {}",
msg.sender,
self.t - 1,
msg.vss_pk.degree()
msg.vss_pk.degree_bound()
);
return Err(FastCryptoError::InvalidMessage);
}
Expand Down
4 changes: 2 additions & 2 deletions fastcrypto-tbls/src/dl_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub fn verify_poly_evals<G: GroupElement + MultiScalarMul, R: AllowedRng>(
poly: &Poly<G>,
rng: &mut R,
) -> FastCryptoResult<()> {
assert!(poly.degree() > 0);
assert!(poly.degree_bound() > 0);
if evals.is_empty() {
return Ok(());
}
Expand All @@ -59,7 +59,7 @@ pub fn verify_poly_evals<G: GroupElement + MultiScalarMul, R: AllowedRng>(
.iter()
.map(|e| G::ScalarType::from(e.index.get().into()))
.collect::<Vec<_>>();
let coeffs = batch_coefficients(&rs, &evals_as_scalars, poly.degree());
let coeffs = batch_coefficients(&rs, &evals_as_scalars, poly.degree_bound());
let rhs = G::multi_scalar_mul(&coeffs, poly.as_vec()).expect("sizes match");

if lhs != rhs {
Expand Down
1 change: 0 additions & 1 deletion fastcrypto-tbls/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub mod nodes;
pub mod polynomial;
pub mod random_oracle;
pub mod tbls;
#[cfg(any(test, feature = "experimental"))]
pub mod threshold_schnorr;
pub mod types;

Expand Down
Loading
Loading