Skip to content

Commit 8bee803

Browse files
committed
chore: added deterministic tests for keygen
chore: added support for refresh and reshare chore: added eddsa and ckd support feat: add support for ecdsa feat: make all tests deterministic fix: address nits feat: do determinism tests independently, use cargo-insta fix: minor after rebase fix: rebase fixes fix: minor
1 parent 24238cd commit 8bee803

File tree

52 files changed

+1561
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1561
-415
lines changed

Cargo.lock

Lines changed: 162 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ test-utils = ["rand", "rand_chacha"]
5858
[dev-dependencies]
5959
criterion = {version = "0.7.0", features = ["html_reports"]}
6060
bincode = { version = "2.0.1", features = ["serde"] }
61+
insta = { version = "1.43.1", features = ["json", "redactions"] }
6162
rand = { version = "0.8.5"}
6263
rand_core = { version = "0.6.4", features = ["getrandom"]}
6364
threshold-signatures = { path = ".", features = ["test-utils"] }

benches/inversion.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
use criterion::{criterion_group, criterion_main, Criterion};
33
use frost_core::{Field, Group};
44
use frost_secp256k1::{Secp256K1ScalarField, Secp256K1Sha256};
5-
use rand_core::OsRng;
5+
use rand::SeedableRng;
66
use std::hint::black_box;
7-
use threshold_signatures::batch_invert;
7+
use threshold_signatures::{batch_invert, test_utils::MockCryptoRng};
88

99
fn bench_inversion(c: &mut Criterion) {
1010
let mut group = c.benchmark_group("Single_vs_Batch_Inversion");
11+
let mut rng = MockCryptoRng::seed_from_u64(42);
1112

1213
group.measurement_time(std::time::Duration::from_secs(10));
1314

1415
let num_inversions = 10_000;
1516
let values: Vec<_> = (0..num_inversions)
16-
.map(|_| Secp256K1ScalarField::random(&mut OsRng))
17+
.map(|_| Secp256K1ScalarField::random(&mut rng))
1718
.collect();
1819

1920
group.bench_function("single_inversion", |b| {
@@ -35,19 +36,20 @@ fn bench_inversion(c: &mut Criterion) {
3536

3637
fn bench_inversion_vs_multiplication(c: &mut Criterion) {
3738
let mut group = c.benchmark_group("Inversion_vs_Multiplication");
39+
let mut rng = MockCryptoRng::seed_from_u64(42);
3840

3941
group.bench_function("single_inversion", |b| {
4042
b.iter(|| {
41-
let value_to_invert = Secp256K1ScalarField::random(&mut OsRng);
43+
let value_to_invert = Secp256K1ScalarField::random(&mut rng);
4244
black_box(value_to_invert.invert().unwrap());
4345
});
4446
});
4547

4648
group.bench_function("three_multiplications", |b| {
4749
b.iter(|| {
48-
let a = Secp256K1ScalarField::random(&mut OsRng);
49-
let b = Secp256K1ScalarField::random(&mut OsRng);
50-
let c = Secp256K1ScalarField::random(&mut OsRng);
50+
let a = Secp256K1ScalarField::random(&mut rng);
51+
let b = Secp256K1ScalarField::random(&mut rng);
52+
let c = Secp256K1ScalarField::random(&mut rng);
5153
black_box(a * b * c);
5254
});
5355
});

benches/lagrange.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,26 @@
22
use criterion::{criterion_group, criterion_main, Criterion};
33
use frost_core::Field;
44
use frost_secp256k1::{Secp256K1ScalarField, Secp256K1Sha256};
5-
use rand_core::OsRng;
5+
use rand::SeedableRng;
66
use std::hint::black_box;
77
use threshold_signatures::{
88
batch_compute_lagrange_coefficients, compute_lagrange_coefficient, participants::Participant,
9+
test_utils::MockCryptoRng,
910
};
1011

1112
type C = Secp256K1Sha256;
1213

1314
fn bench_lagrange_computation(c: &mut Criterion) {
1415
let mut group = c.benchmark_group("Lagrange");
16+
let mut rng = MockCryptoRng::seed_from_u64(42);
1517

1618
for degree in &[1u32, 100, 1_000] {
1719
let participants = (0..=*degree).map(Participant::from).collect::<Vec<_>>();
1820
let ids = participants
1921
.iter()
2022
.map(Participant::scalar::<C>)
2123
.collect::<Vec<_>>();
22-
let point = Some(Secp256K1ScalarField::random(&mut OsRng));
24+
let point = Some(Secp256K1ScalarField::random(&mut rng));
2325

2426
group.bench_with_input(
2527
format!("sequential_degree_{degree}"),
@@ -66,19 +68,20 @@ fn bench_lagrange_computation(c: &mut Criterion) {
6668

6769
pub fn bench_inversion_vs_multiplication(c: &mut Criterion) {
6870
let mut group = c.benchmark_group("Inversion_vs_Multiplication");
71+
let mut rng = MockCryptoRng::seed_from_u64(42);
6972

7073
group.bench_function("single_inversion", |b| {
7174
b.iter(|| {
72-
let value_to_invert = Secp256K1ScalarField::random(&mut OsRng);
75+
let value_to_invert = Secp256K1ScalarField::random(&mut rng);
7376
black_box(value_to_invert.invert().unwrap());
7477
});
7578
});
7679

7780
group.bench_function("three_multiplications", |b| {
7881
b.iter(|| {
79-
let a = Secp256K1ScalarField::random(&mut OsRng);
80-
let b = Secp256K1ScalarField::random(&mut OsRng);
81-
let c = Secp256K1ScalarField::random(&mut OsRng);
82+
let a = Secp256K1ScalarField::random(&mut rng);
83+
let b = Secp256K1ScalarField::random(&mut rng);
84+
let c = Secp256K1ScalarField::random(&mut rng);
8285
black_box(a * b * c);
8386
});
8487
});

0 commit comments

Comments
 (0)