Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
zeth_gen_address.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 zeth.core.zeth_address import generate_zeth_address
6 from zeth.cli.utils import get_zeth_address_file, pub_address_file, \
7  write_zeth_address_secret, write_zeth_address_public
8 from click import command, pass_context, ClickException, Context
9 from os.path import exists
10 
11 
12 @command()
13 @pass_context
14 def gen_address(ctx: Context) -> None:
15  """
16  Generate a new Zeth secret key and public address
17  """
18  client_ctx = ctx.obj
19  addr_file = get_zeth_address_file(client_ctx)
20  if exists(addr_file):
21  raise ClickException(f"ZethAddress file {addr_file} exists")
22 
23  pub_addr_file = pub_address_file(addr_file)
24  if exists(pub_addr_file):
25  raise ClickException(f"ZethAddress pub file {pub_addr_file} exists")
26 
27  zeth_address = generate_zeth_address()
28  write_zeth_address_secret(zeth_address.addr_sk, addr_file)
29  print(f"ZethAddress Secret key written to {addr_file}")
30  write_zeth_address_public(zeth_address.addr_pk, pub_addr_file)
31  print(f"Public ZethAddress written to {pub_addr_file}")
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
Definition: utils.py:1
zeth.cli.zeth_gen_address.gen_address
None gen_address(Context ctx)
Definition: zeth_gen_address.py:14
zeth.cli.utils.get_zeth_address_file
str get_zeth_address_file(ClientConfig ctx)
Definition: utils.py:224
zeth.core.zeth_address.generate_zeth_address
ZethAddress generate_zeth_address()
Definition: zeth_address.py:110
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.core.zeth_address
Definition: zeth_address.py:1