Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
powersoftau_process_command.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
4 #
5 # SPDX-License-Identifier: LGPL-3.0+
6 
7 from typing import Optional, List
8 from os.path import exists
9 
10 CONFIG = "release"
11 
12 
14  """
15  Wrapper around the pot-process command.
16  """
17 
18  def __init__(
19  self, pot_process_tool: Optional[str] = None, dry_run: bool = False):
20  self.pot_process_tool = pot_process_tool or _default_tool()
21  self.dry_run = dry_run
22  assert exists(self.pot_process_tool), \
23  f"pot-process tool does not exist {self.pot_process_tool}"
24 
26  self,
27  pot_file: str,
28  pot_degree: int,
29  lagrange_output_file: str,
30  lagrange_degree: Optional[int]) -> bool:
31  lagrange_degree = lagrange_degree or pot_degree
32  return self._exec(
33  ["--out", lagrange_output_file,
34  "--lagrange-degree", str(lagrange_degree),
35  pot_file,
36  str(pot_degree)])
37 
38  def _exec(self, args: List[str]) -> bool:
39  import subprocess
40  args = [self.pot_process_tool] + args
41  print(f"CMD: {' '.join(args)}")
42  return self.dry_run or \
43  subprocess.run(args=args, check=False).returncode == 0
44 
45 
46 def _default_tool() -> str:
47  from os.path import join, dirname
48  return join(
49  dirname(__file__), "..", "..", "build", "mpc_tools", "pot-process")
test_commands.mock.str
str
Definition: mock.py:18
coordinator.powersoftau_process_command.PowersOfTauProcessCommand.pot_process_tool
pot_process_tool
Definition: powersoftau_process_command.py:19
coordinator.powersoftau_process_command.PowersOfTauProcessCommand.__init__
def __init__(self, Optional[str] pot_process_tool=None, bool dry_run=False)
Definition: powersoftau_process_command.py:18
coordinator.powersoftau_process_command.PowersOfTauProcessCommand._exec
bool _exec(self, List[str] args)
Definition: powersoftau_process_command.py:38
coordinator.powersoftau_process_command.PowersOfTauProcessCommand
Definition: powersoftau_process_command.py:13
coordinator.powersoftau_process_command.PowersOfTauProcessCommand.compute_lagrange
bool compute_lagrange(self, str pot_file, int pot_degree, str lagrange_output_file, Optional[int] lagrange_degree)
Definition: powersoftau_process_command.py:25
coordinator.powersoftau_process_command.PowersOfTauProcessCommand.dry_run
dry_run
Definition: powersoftau_process_command.py:20