Skip to content

Commit

Permalink
tests: Test also with blame=True
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Oct 17, 2024
1 parent cf54925 commit 39b2c9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
5 changes: 3 additions & 2 deletions python/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
22 changes: 10 additions & 12 deletions python/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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]
Expand All @@ -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)

0 comments on commit 39b2c9e

Please sign in to comment.