Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3b5d83c
add: benches for bivariate ops and matmul
dvdplm May 6, 2026
c3e724d
add: benches for bivariate ops and matmul
dvdplm May 6, 2026
9e79916
wip: optimizations sweep 1
dvdplm May 6, 2026
dbc2767
wip: aggressive unrolling and removal of ndarray (almost) completely.
dvdplm May 6, 2026
cb554ce
chore: remove aggressive unrolling and reformulate loops for speed.
dvdplm May 7, 2026
2382591
chore: better docs,
dvdplm May 7, 2026
11871c9
chore: update bivariate benches to new api
dvdplm May 7, 2026
3853a18
perf: avoid a few allocations
dvdplm May 7, 2026
d424382
chore: update to new api
dvdplm May 7, 2026
5af9318
chore: dial down the benchmarks to more relevant sizes and cases.
dvdplm May 7, 2026
686044d
Merge branch 'main' into dvdplm/perf/bivariate-optimizations
dvdplm May 7, 2026
0c7b8b4
chore: remove trait, mak`from_secret` the only constructor, remove `D…
dvdplm May 8, 2026
8c6444d
chore: tighter comments&docs
dvdplm May 8, 2026
6f63479
chore: shorter names
dvdplm May 8, 2026
5482097
chore: add benches for remaining matmul
dvdplm May 9, 2026
db30358
chore: replace the ndarray based matmul impl with direct calculation
dvdplm May 9, 2026
af35d62
chore: remove ndarray from the workspace
dvdplm May 9, 2026
fb62a9d
chore: update to new api
dvdplm May 9, 2026
f9d6ed9
chore: tweak naming
dvdplm May 10, 2026
f5c9fcd
Merge branch 'main' into dvdplm/perf/matmul-optimizations
dvdplm May 10, 2026
d390928
Merge branch 'main' into dvdplm/perf/matmul-optimizations
dvdplm May 11, 2026
6d18091
chore: merge main and sort out merge conflicts
dvdplm May 21, 2026
317a5d8
Merge remote-tracking branch 'origin/main' into dvdplm/perf/matmul-op…
dvdplm May 22, 2026
60c3a95
forgot this one
dvdplm May 22, 2026
ab9e6f5
fix: merg conflict artifact
dvdplm May 22, 2026
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: 0 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ k256 = "=0.13.4" # secp256k1 elliptic curve - LOW RISK: RustCrypto org, 33M+ do
minijinja = { version = "=2.11.0", features = ["loader"] } # Template engine - HIGH RISK: Individual maintainer (mitsuhiko), despite exceptional track record
ml-kem = { version = "=0.2.2", features = ["zeroize"] } # ML-KEM (Kyber) post-quantum KEM - MEDIUM RISK: New standard implementation, needs security audit
mockall = "=0.13.1" # Mocking for tests - HIGH RISK: Individual maintainer (asomers), test-only dependency
ndarray = { version = "=0.16.1", features = ["serde"] } # N-dimensional arrays - LOW RISK: rust-ndarray team
nom = "=8.0.0" # Parser combinator library - HIGH RISK: Individual maintainer (Geal), despite 319M+ downloads
num-integer = "=0.1.46" # Integer utilities - LOW RISK: rust-num team
num-traits = "=0.2.19" # Numeric traits - LOW RISK: rust-num team
Expand Down
5 changes: 4 additions & 1 deletion core/threshold-algebra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ threshold-types.workspace = true
g2p.workspace = true
error-utils.workspace = true
itertools.workspace = true
ndarray.workspace = true
rand.workspace = true
serde.workspace = true
sha3.workspace = true
Expand All @@ -33,3 +32,7 @@ rstest.workspace = true
[[bench]]
name = "bivariate"
harness = false

[[bench]]
name = "matrix"
harness = false
73 changes: 73 additions & 0 deletions core/threshold-algebra/benches/matrix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
use aes_prng::AesRng;
use criterion::{Criterion, criterion_group, criterion_main};
use rand::SeedableRng;
use std::hint::black_box;
use threshold_algebra::{
galois_rings::degree_4::ResiduePolyF4Z128, matrix::VdmMatrix, structure_traits::Sample,
};

const PRODUCTION_PARTIES: usize = 13;
const PRODUCTION_THRESHOLD: usize = 4;
const EXTRACTED_WIDTH: usize = PRODUCTION_PARTIES - PRODUCTION_THRESHOLD;

fn sample_vec(rng: &mut AesRng, len: usize) -> Vec<ResiduePolyF4Z128> {
(0..len).map(|_| ResiduePolyF4Z128::sample(rng)).collect()
}

fn bench_single_sharing_vdm(c: &mut Criterion) {
let mut rng = AesRng::seed_from_u64(0);
let shares = sample_vec(&mut rng, PRODUCTION_PARTIES);
let vdm = VdmMatrix::<ResiduePolyF4Z128>::from_exceptional_sequence(
PRODUCTION_PARTIES,
EXTRACTED_WIDTH,
)
.unwrap();

c.bench_function("matrix/production/single_sharing_vdm/n13_t4", |b| {
b.iter(|| black_box(black_box(&vdm).mul_vector(black_box(&shares)).unwrap()))
});
}

fn bench_double_sharing_vdm(c: &mut Criterion) {
let mut rng = AesRng::seed_from_u64(1);
let shares_t = sample_vec(&mut rng, PRODUCTION_PARTIES);
let shares_2t = sample_vec(&mut rng, PRODUCTION_PARTIES);
let vdm = VdmMatrix::<ResiduePolyF4Z128>::from_exceptional_sequence(
PRODUCTION_PARTIES,
EXTRACTED_WIDTH,
)
.unwrap();

c.bench_function("matrix/production/double_sharing_vdm/n13_t4", |b| {
b.iter(|| {
black_box((
black_box(&vdm).mul_vector(black_box(&shares_t)).unwrap(),
black_box(&vdm).mul_vector(black_box(&shares_2t)).unwrap(),
))
})
});
}

fn bench_robust_prss_vdm(c: &mut Criterion) {
let mut rng = AesRng::seed_from_u64(2);
let shares = sample_vec(&mut rng, PRODUCTION_PARTIES);
let vdm = VdmMatrix::<ResiduePolyF4Z128>::from_exceptional_sequence(
PRODUCTION_PARTIES,
EXTRACTED_WIDTH,
)
.unwrap();

// Keep the Criterion ID stable so this branch can compare against the
// original transposed ndarray baseline.
c.bench_function("matrix/production/robust_prss_transposed_vdm/n13_t4", |b| {
b.iter(|| black_box(black_box(&vdm).mul_vector(black_box(&shares)).unwrap()))
});
}

criterion_group!(
matrix,
bench_single_sharing_vdm,
bench_double_sharing_vdm,
bench_robust_prss_vdm,
);
criterion_main!(matrix);
Loading
Loading