Skip to content

Commit

Permalink
example: Take t and n as command line args
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Dec 18, 2024
1 parent 848ea72 commit 04595ae
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions python/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,21 @@ async def session():


def main():
n = 5
t = 3

parser = argparse.ArgumentParser(description="ChillDKG example")
parser.add_argument(
"--faulty-participant",
action="store_true",
help="When this flag is set, one random participant will send an invalid message, and blame mode will be enabled for other participants and the coordinator.",
)
parser.add_argument(
"t", nargs="?", type=int, default=2, help="Signing threshold [default = 2]"
)
parser.add_argument(
"n", nargs="?", type=int, default=3, help="Number of participants [default = 3]"
)
args = parser.parse_args()
t = args.t
n = args.n
if args.faulty_participant:
faulty_idx = randint(0, n - 1)
else:
Expand All @@ -217,8 +222,7 @@ def main():
params = SessionParams(hostpubkeys, t)

print("=== Inputs ===")
print(f"t: {t}")
print(f"n: {n}")
print(f"t = {t}, n = {n}")
print()
if faulty_idx is not None:
print(f"Participant {faulty_idx} is faulty.")
Expand All @@ -227,7 +231,7 @@ def main():
f"Participant {i}'s (hostseckey, hostpubkey) pair: "
f"({hostseckeys[i].hex()}, {hostpubkeys[i].hex()})"
)

print()
print(f"SessionParams identifier: {params_id(params).hex()}")
print()

Expand Down

0 comments on commit 04595ae

Please sign in to comment.