Repository: aptos-labs/aptos-core
File: crates/aptos-dkg/benches/pvss.rs (Rust)

Code before:
    algebra::evaluation_domain::BatchEvaluationDomain,
    pvss::{
        self,
        test_utils::{
            self, get_threshold_configs_for_benchmarking, get_weighted_configs_for_benchmarking,
            DealingArgs, NoAux, BENCHMARK_CONFIGS,
        },
        traits::transcript::{
            Aggregatable, AggregatableTranscript, HasAggregatableSubtranscript,
            MalleableTranscript, Transcript, WithMaxNumShares,
        },
        LowDegreeTest, WeightedConfigBlstrs,
    },
};
use criterion::{
    criterion_group, criterion_main,
    measurement::{Measurement, WallTime},
    BenchmarkGroup, Criterion, Throughput,
};
use more_asserts::assert_le;
use rand::{rngs::ThreadRng, thread_rng, Rng};

pub fn all_groups(c: &mut Criterion) {
    // unweighted BN254 PVSS with aggregatable subscript
    for tc in get_threshold_configs_for_benchmarking() {
        subaggregatable_pvss_group::<<aptos_dkg::pvss::chunky::Transcript<ark_ec::models::bn::Bn<ark_bn254::Config>> as aptos_dkg::pvss::traits::Transcript>::SecretSharingConfig, pvss::chunky::Transcript<ark_bn254::Bn254>>(&tc, c);
    }

    // unweighted aggregatable PVSS
    for tc in get_threshold_configs_for_benchmarking() {
        aggregatable_pvss_group::<pvss::das::Transcript>(&tc, c);
    }

    // weighted PVSS
    for wc in get_weighted_configs_for_benchmarking() {
        let d = aggregatable_pvss_group::<pvss::das::WeightedTranscript>(&wc, c);
        weighted_pvss_group(&wc, d, c);

        // Note: Insecure, so not interested in benchmarks.
        // let d = pvss_group::<GenericWeighting<pvss::das::Transcript>>(&wc, c);
        // weighted_pvss_group(&wc, d, c);
    }

    // LDT
    ldt_group(c);
}

// TODO: benchmark both blstrs and arkworks LDT?
pub fn ldt_group(c: &mut Criterion) {
    let mut rng = thread_rng();
    let mut group = c.benchmark_group("ldt");

Review comment (security):
I would try to make `<aptos_dkg::pvss::chunky::Transcript<ark_ec::models::bn::Bn<ark_bn254::Config>> as aptos_dkg::pvss::traits::Transcript>::SecretSharingConfig` a bit more succinct

Code after:
    algebra::evaluation_domain::BatchEvaluationDomain,
    pvss::{
        self,
        chunky::Transcript as ChunkyTranscript,
        test_utils::{
            self, get_threshold_configs_for_benchmarking, get_weighted_configs_for_benchmarking,
            DealingArgs, NoAux, BENCHMARK_CONFIGS,
        },
        traits::transcript::{
            Aggregatable, AggregatableTranscript, HasAggregatableSubtranscript,
            MalleableTranscript, Transcript, WithMaxNumShares,
        },
        LowDegreeTest, WeightedConfigBlstrs,
    },
};
use ark_bn254::Config as Bn254Config;
use ark_ec::models::bn::Bn;
use criterion::{
    criterion_group, criterion_main,
    measurement::{Measurement, WallTime},
    BenchmarkGroup, Criterion, Throughput,
};
use more_asserts::assert_le;
use rand::{rngs::ThreadRng, thread_rng, Rng};

pub fn all_groups(c: &mut Criterion) {
    // unweighted BN254 PVSS with aggregatable subscript
    for tc in get_threshold_configs_for_benchmarking() {
        subaggregatable_pvss_group::<
            <ChunkyTranscript<Bn<Bn254Config>> as Transcript>::SecretSharingConfig,
            pvss::chunky::Transcript<ark_bn254::Bn254>,
        >(&tc, c);
    }

    // unweighted aggregatable PVSS
    for tc in get_threshold_configs_for_benchmarking() {
        aggregatable_pvss_group::<pvss::das::Transcript>(&tc, c);
    }

    // weighted PVSS
    for wc in get_weighted_configs_for_benchmarking() {
        let d = aggregatable_pvss_group::<pvss::das::WeightedTranscript>(&wc, c);
        weighted_pvss_group(&wc, d, c);

        // Note: Insecure, so not interested in benchmarks.
        // let d = pvss_group::<GenericWeighting<pvss::das::Transcript>>(&wc, c);
        // weighted_pvss_group(&wc, d, c);
    }

    // LDT
    ldt_group(c);