7 from os.path
import exists, join, dirname
8 from typing
import Optional, List, Mapping
11 CHALLENGE_FILE =
"challenge"
12 NEW_CHALLENGE_FILE =
"new_challenge"
13 RESPONSE_FILE =
"response"
20 Wrapper around the powersoftau commands
24 powersoftau_path: Optional[str],
25 num_powers: Optional[int]):
29 raise Exception(f
"expected powersoftau path: {self.powersoftau_path}")
32 return self.
_exec(
"new")
35 return self.
_exec(
"verify_transform")
40 transcript_file: str) ->
None:
42 with open(transcript_file,
"ab")
as transcript_f:
44 [
"dd", f
"if={response}",
"bs=64",
"skip=1"],
50 digest_file: Optional[str],
51 skip_user_input: bool) -> bool:
52 assert exists(CHALLENGE_FILE)
53 cmd_args: List[str] = []
56 cmd_args += [
"--digest", digest_file]
58 kwargs[
"input"] =
"any data\n".encode()
59 if self.
_exec(
"compute", cmd_args, kwargs):
60 assert exists(RESPONSE_FILE)
65 return self.
_exec(
"verify", args=[
"--rounds",
str(num_rounds)])
70 args: List[str] =
None,
71 kwargs: Mapping[str, object] =
None) -> bool:
78 print(f
"CMD: {' '.join(args)}")
79 return subprocess.run(args=args, check=
False, **kwargs).returncode == 0
82 def _default_powersoftau_path() -> str:
84 Return the default path to the PoT binaries directory
87 dirname(__file__),
"..",
"..",
"..",
"powersoftau",
"target", CONFIG)