Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
utils.py
Go to the documentation of this file.
1 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
2 #
3 # SPDX-License-Identifier: LGPL-3.0+
4 
5 from __future__ import annotations
6 from zeth.cli.constants import WALLET_USERNAME, ETH_ADDRESS_DEFAULT, \
7  ETH_PRIVATE_KEY_FILE_DEFAULT, ETH_RPC_ENDPOINT_DEFAULTS, \
8  ETH_NETWORK_FILE_DEFAULT, ETH_NETWORK_DEFAULT, \
9  ZETH_PUBLIC_ADDRESS_FILE_DEFAULT
10 from zeth.core.zeth_address import ZethAddressPub, ZethAddressPriv, ZethAddress
11 from zeth.core.contracts import \
12  InstanceDescription, get_block_number, compile_files
13 from zeth.core.mimc import get_tree_hash_for_pairing
14 from zeth.core.prover_client import ProverClient
15 from zeth.core.pairing import PairingParameters
16 from zeth.core.mixer_client import MixerClient, get_mix_results
17 from zeth.core.utils import \
18  open_web3, short_commitment, EtherValue, get_zeth_dir, from_zeth_units
19 from zeth.core.wallet import ZethNoteDescription, Wallet
20 from click import ClickException
21 import json
22 from os.path import exists, join, splitext
23 from web3 import Web3 # type: ignore
24 from typing import Dict, Tuple, Optional, Callable, Any, cast
25 
26 
28  """
29  Simple description of a network. Name (may be used in some cases to
30  understand the type of network) and endpoint URL.
31  """
32  def __init__(
33  self,
34  name: str,
35  endpoint: str,
36  certificate: Optional[str] = None,
37  insecure: bool = False):
38  self.name = name
39  self.endpoint = endpoint
40  self.certificate = certificate
41  self.insecure = insecure
42 
43  def to_json(self) -> str:
44  json_dict: Dict[str, Any] = {
45  "name": self.name,
46  "endpoint": self.endpoint,
47  }
48  if self.certificate:
49  json_dict["certificate"] = self.certificate
50  if self.insecure:
51  json_dict["insecure"] = self.insecure
52  return json.dumps(json_dict)
53 
54  @staticmethod
55  def from_json(network_config_json: str) -> NetworkConfig:
56  json_dict = json.loads(network_config_json)
57  return NetworkConfig(
58  name=json_dict["name"],
59  endpoint=json_dict["endpoint"],
60  certificate=json_dict.get("certificate", None),
61  insecure=json_dict.get("insecure", None))
62 
63 
65  """
66  Context for users of these client tools
67  """
68  def __init__(
69  self,
70  eth_network: Optional[str],
71  prover_server_endpoint: str,
72  prover_config_file: str,
73  instance_file: str,
74  address_file: str,
75  wallet_dir: str):
76  self.eth_network = eth_network
77  self.prover_server_endpoint = prover_server_endpoint
78  self.prover_config_file = prover_config_file
79  self.instance_file = instance_file
80  self.address_file = address_file
81  self.wallet_dir = wallet_dir
82 
83 
84 def get_eth_network(eth_network: Optional[str]) -> NetworkConfig:
85  """
86  Parse the `eth_network` parameter to extract a URL. If `eth_network` does
87  not contain a URL, try interpreting it as a network name, otherwise
88  interpret it as a file to load the network config from. Fall back to a
89  default network config filename, and finally the default network name.
90  """
91  if eth_network is None:
92  if exists(ETH_NETWORK_FILE_DEFAULT):
93  eth_network = ETH_NETWORK_FILE_DEFAULT
94  else:
95  eth_network = ETH_NETWORK_DEFAULT
96 
97  if eth_network.startswith("http"):
98  # When given only a url, assume the default network name
99  return NetworkConfig(ETH_NETWORK_DEFAULT, eth_network)
100 
101  # Try loading from a file
102  if exists(eth_network):
103  with open(eth_network) as network_f:
104  return NetworkConfig.from_json(network_f.read())
105 
106  # Assume a network name
107  try:
108  endpoint = ETH_RPC_ENDPOINT_DEFAULTS[eth_network]
109  return NetworkConfig(eth_network, endpoint)
110  except KeyError as ex:
111  raise ClickException(f"invalid network name / url: {eth_network}") from ex
112 
113 
114 def open_web3_from_network(eth_net: NetworkConfig) -> Any:
115  return open_web3(
116  url=eth_net.endpoint,
117  certificate=eth_net.certificate,
118  insecure=eth_net.insecure)
119 
120 
121 def load_contract_address(contract_addr: str) -> str:
122  """
123  Parse a string as either an eth address, or a contract instance file.
124  """
125  if contract_addr.startswith("0x"):
126  return Web3.toChecksumAddress(contract_addr)
127  if exists(contract_addr):
128  with open(contract_addr, "r") as instance_f:
129  instance = InstanceDescription.from_json_dict(json.load(instance_f))
130  return Web3.toChecksumAddress(instance.address)
131  raise ClickException(
132  f"failed to parse as address or instance file: {contract_addr}")
133 
134 
135 def open_web3_from_ctx(ctx: ClientConfig) -> Any:
136  eth_net = get_eth_network(ctx.eth_network)
137  return open_web3_from_network(eth_net)
138 
139 
141  """
142  Holds an InstanceDescription for the mixer contract, and optionally an
143  InstanceDescription for the token contract. When serialized to json, the
144  InstanceDescription for the mixer is held in the top-level object, so that
145  MixerDescription is compatible with a regular contract instance.
146  """
147  def __init__(
148  self,
149  mixer: InstanceDescription,
150  token: Optional[InstanceDescription],
151  permitted_dispatcher: Optional[str],
152  vk_hash: Optional[str]):
153  self.mixer = mixer
154  self.token = token
155  self.permitted_dispatcher = permitted_dispatcher
156  self.vk_hash = vk_hash
157 
158  def to_json_dict(self) -> Dict[str, Any]:
159  # Create an InstanceDescription JSON object, adding a "zeth_mixer"
160  # attribute for the extra data.
161  json_dict = self.mixer.to_json_dict()
162 
163  zeth_mixer: Dict[str, Any] = {}
164  if self.token:
165  zeth_mixer["token"] = self.token.to_json_dict()
166  if self.permitted_dispatcher:
167  zeth_mixer["permitted_dispatcher"] = self.permitted_dispatcher
168  if self.vk_hash:
169  zeth_mixer["vk_hash"] = self.vk_hash
170  json_dict["zeth_mixer"] = zeth_mixer
171  return json_dict
172 
173  @staticmethod
174  def from_json_dict(json_dict: Dict[str, Any]) -> MixerDescription:
175  zeth_mixer = json_dict["zeth_mixer"]
176 
177  mixer = InstanceDescription.from_json_dict(json_dict)
178  token_dict = cast(Optional[Dict[str, Any]], zeth_mixer.get("token", None))
179  token = InstanceDescription.from_json_dict(token_dict) \
180  if token_dict else None
181  permitted_dispatcher = \
182  cast(Optional[str], zeth_mixer.get("permitted_dispatcher", None))
183  vk_hash = cast(Optional[str], zeth_mixer.get("vk_hash", None))
184  return MixerDescription(mixer, token, permitted_dispatcher, vk_hash)
185 
186 
187 def get_erc20_abi() -> Dict[str, Any]:
188  zeth_dir = get_zeth_dir()
189  openzeppelin_dir = join(
190  zeth_dir, "zeth_contracts", "node_modules", "openzeppelin-solidity")
191  ierc20_path = join(
192  openzeppelin_dir, "contracts", "token", "ERC20", "IERC20.sol")
193  compiled_sol = compile_files([ierc20_path])
194  erc20_interface = compiled_sol[ierc20_path + ":IERC20"]
195  return erc20_interface["abi"]
196 
197 
198 def get_erc20_instance_description(token_address: str) -> InstanceDescription:
199  return InstanceDescription(token_address, get_erc20_abi())
200 
201 
203  mixer_desc_file: str,
204  mixer_desc: MixerDescription) -> None:
205  """
206  Write the mixer (and token) instance information
207  """
208  with open(mixer_desc_file, "w") as instance_f:
209  json.dump(mixer_desc.to_json_dict(), instance_f)
210 
211 
212 def load_mixer_description(mixer_desc_file: str) -> MixerDescription:
213  """
214  Return mixer and token (if present) contract instances
215  """
216  with open(mixer_desc_file, "r") as desc_f:
217  return MixerDescription.from_json_dict(json.load(desc_f))
218 
219 
220 def load_mixer_description_from_ctx(ctx: ClientConfig) -> MixerDescription:
221  return load_mixer_description(ctx.instance_file)
222 
223 
224 def get_zeth_address_file(ctx: ClientConfig) -> str:
225  return ctx.address_file
226 
227 
228 def load_zeth_address_public(ctx: ClientConfig) -> ZethAddressPub:
229  """
230  Load a ZethAddressPub from a key file.
231  """
232  secret_key_file = get_zeth_address_file(ctx)
233  pub_addr_file = pub_address_file(secret_key_file)
234  with open(pub_addr_file, "r") as pub_addr_f:
235  return ZethAddressPub.parse(pub_addr_f.read())
236 
237 
239  pub_addr: ZethAddressPub, pub_addr_file: str) -> None:
240  """
241  Write a ZethAddressPub to a file
242  """
243  with open(pub_addr_file, "w") as pub_addr_f:
244  pub_addr_f.write(str(pub_addr))
245 
246 
247 def load_zeth_address_secret(ctx: ClientConfig) -> ZethAddressPriv:
248  """
249  Read ZethAddressPriv
250  """
251  addr_file = get_zeth_address_file(ctx)
252  with open(addr_file, "r") as addr_f:
253  return ZethAddressPriv.from_json(addr_f.read())
254 
255 
257  secret_addr: ZethAddressPriv, addr_file: str) -> None:
258  """
259  Write ZethAddressPriv to file
260  """
261  with open(addr_file, "w") as addr_f:
262  addr_f.write(secret_addr.to_json())
263 
264 
265 def load_zeth_address(ctx: ClientConfig) -> ZethAddress:
266  """
267  Load a ZethAddress secret from a file, and the associated public address,
268  and return as a ZethAddress.
269  """
270  return ZethAddress.from_secret_public(
273 
274 
276  mixer_instance: Any,
277  js_secret: ZethAddressPriv,
278  ctx: ClientConfig) -> Wallet:
279  """
280  Load a wallet using a secret key.
281  """
282  wallet_dir = ctx.wallet_dir
283  prover_config = create_prover_client(ctx).get_configuration()
284  tree_hash = get_tree_hash_for_pairing(prover_config.pairing_parameters.name)
285  return Wallet(
286  mixer_instance, WALLET_USERNAME, wallet_dir, js_secret, tree_hash)
287 
288 
290  web3: Any,
291  wallet: Wallet,
292  pp: PairingParameters,
293  wait_tx: Optional[str],
294  callback: Optional[Callable[[ZethNoteDescription], None]] = None,
295  batch_size: Optional[int] = None) -> int:
296  """
297  Implementation of sync, reused by several commands. Returns the
298  block_number synced to. Also updates and saves the MerkleTree.
299  """
300  def _do_sync() -> int:
301  wallet_next_block = wallet.get_next_block()
302  chain_block_number = get_block_number(web3)
303 
304  if chain_block_number >= wallet_next_block:
305  new_merkle_root: Optional[bytes] = None
306 
307  print(f"SYNCHING blocks ({wallet_next_block} - {chain_block_number})")
308  mixer_instance = wallet.mixer_instance
309  for mix_result in get_mix_results(
310  web3,
311  mixer_instance,
312  wallet_next_block,
313  chain_block_number,
314  batch_size):
315  new_merkle_root = mix_result.new_merkle_root
316  for note_desc in wallet.receive_notes(
317  mix_result.output_events, pp):
318  if callback:
319  callback(note_desc)
320 
321  spent_commits = wallet.mark_nullifiers_used(mix_result.nullifiers)
322  for commit in spent_commits:
323  print(f" SPENT: {commit}")
324 
325  wallet.update_and_save_state(next_block=chain_block_number + 1)
326 
327  # Check merkle root and save the updated tree
328  if new_merkle_root:
329  our_merkle_root = wallet.merkle_tree.get_root()
330  assert new_merkle_root == our_merkle_root
331 
332  return chain_block_number
333 
334  # Do a sync upfront (it would be a waste of time to wait for a tx before
335  # syncing, as it can take time to traverse all blocks). Then wait for a tx
336  # if requested, and sync again.
337 
338  if wait_tx:
339  _do_sync()
340  tx_receipt = web3.eth.waitForTransactionReceipt(wait_tx, 10000)
341  tx = web3.eth.getTransaction(wait_tx)
342  gas_used = tx_receipt.gasUsed
343  status = tx_receipt.status
344  size_bytes = len(tx.input)
345  print(
346  f"{wait_tx[0:8]}: gasUsed={gas_used}, status={status}, "
347  f"input_size={size_bytes}")
348 
349  return _do_sync()
350 
351 
352 def pub_address_file(addr_file: str) -> str:
353  """
354  The name of a public address file, given the secret address file.
355  """
356  return splitext(addr_file)[0] + ".pub"
357 
358 
359 def find_pub_address_file(base_file: str) -> str:
360  """
361  Given a file name, which could point to a private or public key file, guess
362  at the name of the public key file.
363  """
364  pub_addr_file = pub_address_file(base_file)
365  if exists(pub_addr_file):
366  return pub_addr_file
367  if exists(base_file):
368  return base_file
369 
370  raise ClickException(f"No public key file {pub_addr_file} or {base_file}")
371 
372 
373 def create_prover_client(ctx: ClientConfig) -> ProverClient:
374  """
375  Create a prover client using the settings from the commands context.
376  """
377  return ProverClient(
378  ctx.prover_server_endpoint, ctx.prover_config_file)
379 
380 
382  ctx: ClientConfig,
383  prover_client: Optional[ProverClient] = None) -> MixerClient:
384  """
385  Create a MixerClient for an existing deployment.
386  """
387  mixer_client, _ = create_mixer_client_and_mixer_desc(ctx, prover_client)
388  return mixer_client
389 
390 
392  ctx: ClientConfig,
393  prover_client: Optional[ProverClient] = None
394 ) -> Tuple[MixerClient, MixerDescription]:
395  """
396  Create a MixerClient and MixerDescription object, for an existing deployment.
397  """
398  web3 = open_web3_from_ctx(ctx)
399  mixer_desc = load_mixer_description_from_ctx(ctx)
400  mixer_instance = mixer_desc.mixer.instantiate(web3)
401  if prover_client is None:
402  prover_client = create_prover_client(ctx)
403  prover_config = prover_client.get_configuration()
404  mixer_client = MixerClient(web3, prover_config, mixer_instance)
405  return (mixer_client, mixer_desc)
406 
407 
408 def zeth_note_short(note_desc: ZethNoteDescription) -> str:
409  """
410  Generate a short human-readable description of a commitment.
411  """
412  value = from_zeth_units(int(note_desc.note.value, 16)).ether()
413  cm = short_commitment(note_desc.commitment)
414  return f"{cm}: value={value} ETH, addr={note_desc.address}"
415 
416 
417 def zeth_note_short_print(note_desc: ZethNoteDescription) -> None:
418  print(f" NEW NOTE: {zeth_note_short(note_desc)}")
419 
420 
421 def parse_output(output_str: str) -> Tuple[ZethAddressPub, EtherValue]:
422  """
423  Parse a string of the form "<receiver_pub_address>,<value>" to an output
424  specification. <receiver_pub_address> can be a file name containing the
425  address. "<value>" is interpreted as the <default-address-file>,<value>.
426  """
427  parts = output_str.split(",")
428  if len(parts) == 1:
429  addr = ZETH_PUBLIC_ADDRESS_FILE_DEFAULT
430  value = parts[0]
431  elif len(parts) == 2:
432  addr = parts[0]
433  value = parts[1]
434  else:
435  raise ClickException(f"invalid output spec: {output_str}")
436 
437  if exists(addr):
438  with open(addr, "r") as addr_f:
439  addr = addr_f.read()
440 
441  return (ZethAddressPub.parse(addr), EtherValue(value))
442 
443 
444 def load_eth_address(eth_addr: Optional[str]) -> str:
445  """
446  Given an --eth-addr command line param, either parse the address, load from
447  the file, or use a default file name.
448  """
449  eth_addr = eth_addr or ETH_ADDRESS_DEFAULT
450  if eth_addr.startswith("0x"):
451  return Web3.toChecksumAddress(eth_addr)
452  if exists(eth_addr):
453  with open(eth_addr, "r") as eth_addr_f:
454  return Web3.toChecksumAddress(eth_addr_f.read().rstrip())
455  raise ClickException(f"could find file or parse eth address: {eth_addr}")
456 
457 
458 def write_eth_address(eth_addr: str, eth_addr_file: str) -> None:
459  if exists(eth_addr_file):
460  raise ClickException(f"refusing to overwrite address \"{eth_addr_file}\"")
461  with open(eth_addr_file, "w") as eth_addr_f:
462  eth_addr_f.write(eth_addr)
463 
464 
465 def load_eth_private_key(private_key_file: Optional[str]) -> Optional[bytes]:
466  private_key_file = private_key_file or ETH_PRIVATE_KEY_FILE_DEFAULT
467  if exists(private_key_file):
468  with open(private_key_file, "rb") as private_key_f:
469  return private_key_f.read(32)
470  return None
471 
472 
473 def write_eth_private_key(private_key: bytes, private_key_file: str) -> None:
474  if exists(private_key_file):
475  raise ClickException(
476  f"refusing to overwrite private key \"{private_key_file}\"")
477  with open(private_key_file, "wb") as private_key_f:
478  private_key_f.write(private_key)
zeth.cli.utils.get_eth_network
NetworkConfig get_eth_network(Optional[str] eth_network)
Definition: utils.py:84
zeth.core.mixer_client.MixerClient
Definition: mixer_client.py:259
test_commands.mock.str
str
Definition: mock.py:18
zeth.cli.utils.write_eth_address
None write_eth_address(str eth_addr, str eth_addr_file)
Definition: utils.py:458
zeth.cli.utils.open_web3_from_ctx
Any open_web3_from_ctx(ClientConfig ctx)
Definition: utils.py:135
zeth.cli.utils.NetworkConfig.from_json
NetworkConfig from_json(str network_config_json)
Definition: utils.py:55
zeth.cli.utils.create_prover_client
ProverClient create_prover_client(ClientConfig ctx)
Definition: utils.py:373
zeth.cli.utils.write_zeth_address_public
None write_zeth_address_public(ZethAddressPub pub_addr, str pub_addr_file)
Definition: utils.py:238
zeth.cli.utils.load_contract_address
str load_contract_address(str contract_addr)
Definition: utils.py:121
zeth.cli.utils.open_wallet
Wallet open_wallet(Any mixer_instance, ZethAddressPriv js_secret, ClientConfig ctx)
Definition: utils.py:275
zeth.cli.zeth_deploy.int
int
Definition: zeth_deploy.py:27
zeth.core.contracts.InstanceDescription
Definition: contracts.py:21
zeth.core.wallet.Wallet
Definition: wallet.py:111
zeth.core.utils.open_web3
Any open_web3(str url, Optional[str] certificate=None, bool insecure=False)
Definition: utils.py:28
zeth.cli.utils.ClientConfig.wallet_dir
wallet_dir
Definition: utils.py:74
zeth.cli.utils.load_eth_address
str load_eth_address(Optional[str] eth_addr)
Definition: utils.py:444
zeth.cli.utils.find_pub_address_file
str find_pub_address_file(str base_file)
Definition: utils.py:359
zeth.cli.utils.load_mixer_description_from_ctx
MixerDescription load_mixer_description_from_ctx(ClientConfig ctx)
Definition: utils.py:220
zeth.cli.utils.create_mixer_client_and_mixer_desc
Tuple[MixerClient, MixerDescription] create_mixer_client_and_mixer_desc(ClientConfig ctx, Optional[ProverClient] prover_client=None)
Definition: utils.py:391
zeth.core.utils.get_zeth_dir
str get_zeth_dir()
Definition: utils.py:249
zeth.cli.utils.load_zeth_address_secret
ZethAddressPriv load_zeth_address_secret(ClientConfig ctx)
Definition: utils.py:247
zeth.cli.utils.MixerDescription.token
token
Definition: utils.py:149
zeth.cli.utils.parse_output
Tuple[ZethAddressPub, EtherValue] parse_output(str output_str)
Definition: utils.py:421
zeth.core.wallet
Definition: wallet.py:1
zeth.cli.utils.ClientConfig.instance_file
instance_file
Definition: utils.py:72
zeth.core.mimc.get_tree_hash_for_pairing
ITreeHash get_tree_hash_for_pairing(str pairing_name)
Definition: mimc.py:138
zeth.cli.utils.load_zeth_address
ZethAddress load_zeth_address(ClientConfig ctx)
Definition: utils.py:265
zeth.cli.utils.MixerDescription.mixer
mixer
Definition: utils.py:148
zeth.core.prover_client
Definition: prover_client.py:1
zeth.core.mixer_client
Definition: mixer_client.py:1
zeth.cli.utils.ClientConfig.eth_network
eth_network
Definition: utils.py:69
zeth.cli.utils.ClientConfig.prover_config_file
prover_config_file
Definition: utils.py:71
zeth.cli.utils.zeth_note_short_print
None zeth_note_short_print(ZethNoteDescription note_desc)
Definition: utils.py:417
zeth.cli.utils.NetworkConfig.certificate
certificate
Definition: utils.py:35
zeth.cli.utils.zeth_note_short
str zeth_note_short(ZethNoteDescription note_desc)
Definition: utils.py:408
zeth.core.prover_client.ProverClient
Definition: prover_client.py:53
zeth.cli.utils.ClientConfig
Definition: utils.py:64
zeth.core.contracts.compile_files
Any compile_files(List[str] files, **Any kwargs)
Definition: contracts.py:122
zeth.cli.constants
Definition: constants.py:1
zeth.cli.utils.get_zeth_address_file
str get_zeth_address_file(ClientConfig ctx)
Definition: utils.py:224
zeth.cli.utils.write_eth_private_key
None write_eth_private_key(bytes private_key, str private_key_file)
Definition: utils.py:473
zeth.cli.utils.NetworkConfig.insecure
insecure
Definition: utils.py:36
zeth.core.utils
Definition: utils.py:1
zeth.cli.utils.load_eth_private_key
Optional[bytes] load_eth_private_key(Optional[str] private_key_file)
Definition: utils.py:465
zeth.cli.utils.ClientConfig.address_file
address_file
Definition: utils.py:73
zeth.core.pairing
Definition: pairing.py:1
zeth.cli.utils.NetworkConfig.__init__
def __init__(self, str name, str endpoint, Optional[str] certificate=None, bool insecure=False)
Definition: utils.py:32
zeth.cli.utils.NetworkConfig.to_json
str to_json(self)
Definition: utils.py:43
zeth.core.contracts
Definition: contracts.py:1
zeth.cli.utils.write_mixer_description
None write_mixer_description(str mixer_desc_file, MixerDescription mixer_desc)
Definition: utils.py:202
zeth.core.utils.short_commitment
str short_commitment(bytes cm)
Definition: utils.py:306
zeth.cli.utils.MixerDescription.from_json_dict
MixerDescription from_json_dict(Dict[str, Any] json_dict)
Definition: utils.py:174
zeth.cli.utils.ClientConfig.prover_server_endpoint
prover_server_endpoint
Definition: utils.py:70
zeth.cli.utils.load_mixer_description
MixerDescription load_mixer_description(str mixer_desc_file)
Definition: utils.py:212
zeth.cli.utils.MixerDescription.permitted_dispatcher
permitted_dispatcher
Definition: utils.py:150
zeth.cli.utils.open_web3_from_network
Any open_web3_from_network(NetworkConfig eth_net)
Definition: utils.py:114
zeth.core.utils.from_zeth_units
EtherValue from_zeth_units(int zeth_units)
Definition: utils.py:227
zeth.core.contracts.get_block_number
int get_block_number(Any web3)
Definition: contracts.py:114
zeth.cli.utils.write_zeth_address_secret
None write_zeth_address_secret(ZethAddressPriv secret_addr, str addr_file)
Definition: utils.py:256
zeth.cli.utils.pub_address_file
str pub_address_file(str addr_file)
Definition: utils.py:352
zeth.cli.utils.MixerDescription.vk_hash
vk_hash
Definition: utils.py:151
zeth.cli.utils.load_zeth_address_public
ZethAddressPub load_zeth_address_public(ClientConfig ctx)
Definition: utils.py:228
zeth.core.utils.EtherValue
Definition: utils.py:46
zeth.cli.utils.ClientConfig.__init__
def __init__(self, Optional[str] eth_network, str prover_server_endpoint, str prover_config_file, str instance_file, str address_file, str wallet_dir)
Definition: utils.py:68
zeth.cli.utils.do_sync
int do_sync(Any web3, Wallet wallet, PairingParameters pp, Optional[str] wait_tx, Optional[Callable[[ZethNoteDescription], None]] callback=None, Optional[int] batch_size=None)
Definition: utils.py:289
zeth.cli.utils.MixerDescription.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: utils.py:158
zeth.core.mimc
Definition: mimc.py:1
zeth.core.zeth_address
Definition: zeth_address.py:1
zeth.cli.utils.get_erc20_instance_description
InstanceDescription get_erc20_instance_description(str token_address)
Definition: utils.py:198
zeth.core.mixer_client.get_mix_results
Iterator[MixResult] get_mix_results(Any web3, Any mixer_instance, int start_block, int end_block, Optional[int] batch_size=None)
Definition: mixer_client.py:640
zeth.cli.utils.NetworkConfig
Definition: utils.py:27
zeth.cli.utils.create_mixer_client
MixerClient create_mixer_client(ClientConfig ctx, Optional[ProverClient] prover_client=None)
Definition: utils.py:381
zeth.cli.utils.NetworkConfig.name
name
Definition: utils.py:33
zeth.cli.utils.MixerDescription.__init__
def __init__(self, InstanceDescription mixer, Optional[InstanceDescription] token, Optional[str] permitted_dispatcher, Optional[str] vk_hash)
Definition: utils.py:147
zeth.cli.utils.NetworkConfig.endpoint
endpoint
Definition: utils.py:34
zeth.cli.utils.MixerDescription
Definition: utils.py:140
zeth.cli.utils.get_erc20_abi
Dict[str, Any] get_erc20_abi()
Definition: utils.py:187