Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Public Member Functions | Public Attributes | List of all members
zeth.core.prover_client.ProverClient Class Reference

Public Member Functions

def __init__ (self, str endpoint, Optional[str] prover_config_file=None)
 
ProverConfiguration get_configuration (self)
 
IZKSnarkProvider get_zksnark_provider (self)
 
IVerificationKey get_verification_key (self)
 
Tuple[ExtendedProof, List[int]] get_proof (self, ProofInputs proof_inputs)
 

Public Attributes

 endpoint
 
 prover_config_file
 
 prover_config
 

Detailed Description

Definition at line 53 of file prover_client.py.

Constructor & Destructor Documentation

◆ __init__()

def zeth.core.prover_client.ProverClient.__init__ (   self,
str  endpoint,
Optional[str]   prover_config_file = None 
)
If config_file is not None, the ProverConfiguration will be cached in the
given file.

Definition at line 54 of file prover_client.py.

54  def __init__(
55  self,
56  endpoint: str,
57  prover_config_file: Optional[str] = None):
58  """
59  If config_file is not None, the ProverConfiguration will be cached in the
60  given file.
61  """
62  self.endpoint = endpoint
63  self.prover_config_file = prover_config_file
64  self.prover_config: Optional[ProverConfiguration] = None
65 

Member Function Documentation

◆ get_configuration()

ProverConfiguration zeth.core.prover_client.ProverClient.get_configuration (   self)
Get the ProverConfiguration for the connected server, caching in memory
and in `config_file` if given.

Definition at line 66 of file prover_client.py.

66  def get_configuration(self) -> ProverConfiguration:
67  """
68  Get the ProverConfiguration for the connected server, caching in memory
69  and in `config_file` if given.
70  """
71  if self.prover_config is not None:
72  return self.prover_config
73 
74  if (self.prover_config_file is not None) and \
75  exists(self.prover_config_file):
76  try:
77  with open(self.prover_config_file, "r") as prover_config_f:
78  self.prover_config = ProverConfiguration.from_json_dict(
79  json.load(prover_config_f))
80  return self.prover_config
81  except Exception as ex:
82  print(
83  f"prover config error '{self.prover_config_file}': {str(ex)}")
84  unlink(self.prover_config_file)
85 
86  with grpc.insecure_channel(self.endpoint) as channel:
87  stub = prover_pb2_grpc.ProverStub(channel) # type: ignore
88  prover_config_proto = stub.GetConfiguration(_make_empty_message())
89  self.prover_config = prover_configuration_from_proto(
90  prover_config_proto)
91 
92  if self.prover_config_file is not None:
93  with open(self.prover_config_file, "w") as prover_config_f:
94  json.dump(self.prover_config.to_json_dict(), prover_config_f)
95 
96  return self.prover_config
97 
Here is the caller graph for this function:

◆ get_proof()

Tuple[ExtendedProof, List[int]] zeth.core.prover_client.ProverClient.get_proof (   self,
ProofInputs  proof_inputs 
)
Request a proof generation to the proving service

Definition at line 115 of file prover_client.py.

115  def get_proof(
116  self,
117  proof_inputs: ProofInputs) -> Tuple[ExtendedProof, List[int]]:
118  """
119  Request a proof generation to the proving service
120  """
121  assert len(proof_inputs.js_inputs) == JS_INPUTS
122  with grpc.insecure_channel(self.endpoint) as channel:
123  stub = prover_pb2_grpc.ProverStub(channel) # type: ignore
124  extproof_and_pub_data = stub.Prove(proof_inputs)
125  zksnark = self.get_zksnark_provider()
126  extproof = zksnark.extended_proof_from_proto(
127  extproof_and_pub_data.extended_proof)
128  public_data = [int(x, 16) for x in extproof_and_pub_data.public_data]
129  return extproof, public_data
130 
131 
Here is the call graph for this function:

◆ get_verification_key()

IVerificationKey zeth.core.prover_client.ProverClient.get_verification_key (   self)
Fetch the verification key from the proving service

Definition at line 105 of file prover_client.py.

105  def get_verification_key(self) -> IVerificationKey:
106  """
107  Fetch the verification key from the proving service
108  """
109  with grpc.insecure_channel(self.endpoint) as channel:
110  stub = prover_pb2_grpc.ProverStub(channel) # type: ignore
111  vk_proto = stub.GetVerificationKey(_make_empty_message())
112  zksnark = self.get_zksnark_provider()
113  return zksnark.verification_key_from_proto(vk_proto)
114 
Here is the call graph for this function:

◆ get_zksnark_provider()

IZKSnarkProvider zeth.core.prover_client.ProverClient.get_zksnark_provider (   self)
Get the appropriate zksnark provider, based on the server configuration.

Definition at line 98 of file prover_client.py.

98  def get_zksnark_provider(self) -> IZKSnarkProvider:
99  """
100  Get the appropriate zksnark provider, based on the server configuration.
101  """
102  config = self.get_configuration()
103  return get_zksnark_provider(config.zksnark_name)
104 
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ endpoint

zeth.core.prover_client.ProverClient.endpoint

Definition at line 59 of file prover_client.py.

◆ prover_config

zeth.core.prover_client.ProverClient.prover_config

Definition at line 78 of file prover_client.py.

◆ prover_config_file

zeth.core.prover_client.ProverClient.prover_config_file

Definition at line 60 of file prover_client.py.


The documentation for this class was generated from the following file:
zeth.cli.zeth_deploy.int
int
Definition: zeth_deploy.py:27
zeth.cli.zeth_get_verification_key.get_verification_key
None get_verification_key(Context ctx, Optional[str] vk_out)
Definition: zeth_get_verification_key.py:15
zeth.core.prover_client.prover_configuration_from_proto
ProverConfiguration prover_configuration_from_proto(prover_pb2.ProverConfiguration prover_config_proto)
Definition: prover_client.py:44
zeth.core.zksnark.get_zksnark_provider
IZKSnarkProvider get_zksnark_provider(str zksnark_name)
Definition: zksnark.py:486