From 39b2c9e01fdc52175c540012c7910e80c0946fee Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Thu, 17 Oct 2024 15:45:06 +0200 Subject: [PATCH] tests: Test also with blame=True --- python/example.py | 5 +++-- python/tests.py | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/python/example.py b/python/example.py index b3640e2..ed3726a 100755 --- a/python/example.py +++ b/python/example.py @@ -123,8 +123,9 @@ async def coordinator( # -def simulate_chilldkg_full(hostseckeys, t) -> List[Tuple[DKGOutput, RecoveryData]]: - blame = True # TODO Test also blame=False +def simulate_chilldkg_full( + hostseckeys, t, blame=True +) -> List[Tuple[DKGOutput, RecoveryData]]: # Generate common inputs for all participants and coordinator n = len(hostseckeys) hostpubkeys = [] diff --git a/python/tests.py b/python/tests.py index 53947dc..bd136b9 100755 --- a/python/tests.py +++ b/python/tests.py @@ -35,8 +35,7 @@ def rand_polynomial(t): ) -def simulate_simplpedpop(seeds, t) -> List[Tuple[simplpedpop.DKGOutput, bytes]]: - blame = True # TODO Test also blame=False +def simulate_simplpedpop(seeds, t, blame) -> List[Tuple[simplpedpop.DKGOutput, bytes]]: n = len(seeds) prets = [] for i in range(n): @@ -66,8 +65,7 @@ def encpedpop_keys(seed: bytes) -> Tuple[bytes, bytes]: return deckey, enckey -def simulate_encpedpop(seeds, t) -> List[Tuple[simplpedpop.DKGOutput, bytes]]: - blame = True # TODO Test also blame=False +def simulate_encpedpop(seeds, t, blame) -> List[Tuple[simplpedpop.DKGOutput, bytes]]: n = len(seeds) enc_prets0 = [] enc_prets1 = [] @@ -100,9 +98,8 @@ def simulate_encpedpop(seeds, t) -> List[Tuple[simplpedpop.DKGOutput, bytes]]: def simulate_chilldkg( - hostseckeys, t + hostseckeys, t, blame ) -> List[Tuple[chilldkg.DKGOutput, chilldkg.RecoveryData]]: - blame = True # TODO Test also blame=False n = len(hostseckeys) hostpubkeys = [] @@ -201,12 +198,12 @@ def test_correctness_dkg_output(t, n, dkg_outputs: List[simplpedpop.DKGOutput]): assert recovered * G == GE.from_bytes_compressed(threshold_pubkey) -def test_correctness(t, n, simulate_dkg, recovery=False): +def test_correctness(t, n, simulate_dkg, recovery=False, blame=True): seeds = [None] + [random_bytes(32) for _ in range(n)] # rets[0] are the return values from the coordinator # rets[1 : n + 1] are from the participants - rets = simulate_dkg(seeds[1:], t) + rets = simulate_dkg(seeds[1:], t, blame=blame) assert len(rets) == n + 1 dkg_outputs = [ret[0] for ret in rets] @@ -229,7 +226,8 @@ def test_correctness(t, n, simulate_dkg, recovery=False): test_vss_correctness() test_recover_secret() for t, n in [(1, 1), (1, 2), (2, 2), (2, 3), (2, 5)]: - test_correctness(t, n, simulate_simplpedpop) - test_correctness(t, n, simulate_encpedpop) - test_correctness(t, n, simulate_chilldkg, recovery=True) - test_correctness(t, n, simulate_chilldkg_full, recovery=True) + for blame in [False, True]: + test_correctness(t, n, simulate_simplpedpop, blame=blame) + test_correctness(t, n, simulate_encpedpop, blame=blame) + test_correctness(t, n, simulate_chilldkg, blame=blame, recovery=True) + test_correctness(t, n, simulate_chilldkg_full, blame=blame, recovery=True)