Zecale - Reconciling Privacy and Scalability on Smart-Contract Chains  0.5
Reference implementation of the Zecale protocol by Clearmatics
Public Member Functions | Public Attributes | List of all members
zecale.core.aggregator_client.AggregatorClient Class Reference

Public Member Functions

def __init__ (self, str endpoint)
 
AggregatorConfiguration get_configuration (self)
 
IVerificationKey get_verification_key (self, IZKSnarkProvider wrapper_zksnark)
 
str get_nested_verification_key_hash (self, IZKSnarkProvider nested_zksnark, IVerificationKey vk)
 
None register_application (self, IZKSnarkProvider nested_zksnark, IVerificationKey vk, str app_name)
 
None submit_nested_transaction (self, IZKSnarkProvider nested_zksnark, NestedTransaction nested_tx)
 
AggregatedTransaction get_aggregated_transaction (self, IZKSnarkProvider wrapper_zksnark, str name)
 

Public Attributes

 endpoint
 

Detailed Description

Interface to Aggregator RPC calls. Interface uses the in-memory version of
objects, internally converting to the protobuf versions.

Definition at line 18 of file aggregator_client.py.

Constructor & Destructor Documentation

◆ __init__()

def zecale.core.aggregator_client.AggregatorClient.__init__ (   self,
str  endpoint 
)

Definition at line 23 of file aggregator_client.py.

23  def __init__(self, endpoint: str):
24  self.endpoint = endpoint
25 

Member Function Documentation

◆ get_aggregated_transaction()

AggregatedTransaction zecale.core.aggregator_client.AggregatorClient.get_aggregated_transaction (   self,
IZKSnarkProvider  wrapper_zksnark,
str  name 
)
Request an aggregated transaction.

Definition at line 78 of file aggregator_client.py.

78  def get_aggregated_transaction(
79  self,
80  wrapper_zksnark: IZKSnarkProvider,
81  name: str) -> AggregatedTransaction:
82  """
83  Request an aggregated transaction.
84  """
85  agg_tx_request = aggregator_pb2.AggregatedTransactionRequest()
86  agg_tx_request.application_name = name
87  with grpc.insecure_channel(self.endpoint) as channel:
88  stub = aggregator_pb2_grpc.AggregatorStub(channel) # type: ignore
89  agg_tx_proto = stub.GenerateAggregatedTransaction(agg_tx_request)
90  return aggregated_transaction_from_proto(wrapper_zksnark, agg_tx_proto)
Here is the call graph for this function:

◆ get_configuration()

AggregatorConfiguration zecale.core.aggregator_client.AggregatorClient.get_configuration (   self)

Definition at line 26 of file aggregator_client.py.

26  def get_configuration(self) -> AggregatorConfiguration:
27  with grpc.insecure_channel(self.endpoint) as channel:
28  stub = aggregator_pb2_grpc.AggregatorStub(channel) # type: ignore
29  config_proto = stub.GetConfiguration(empty_pb2.Empty())
30  return aggregator_configuration_from_proto(config_proto)
31 
Here is the call graph for this function:

◆ get_nested_verification_key_hash()

str zecale.core.aggregator_client.AggregatorClient.get_nested_verification_key_hash (   self,
IZKSnarkProvider  nested_zksnark,
IVerificationKey  vk 
)

Definition at line 39 of file aggregator_client.py.

39  def get_nested_verification_key_hash(
40  self, nested_zksnark: IZKSnarkProvider, vk: IVerificationKey) -> str:
41  with grpc.insecure_channel(self.endpoint) as channel:
42  stub = aggregator_pb2_grpc.AggregatorStub(channel) # type: ignore
43  vk_proto = nested_zksnark.verification_key_to_proto(vk)
44  vk_hash_json = stub.GetNestedVerificationKeyHash(vk_proto).hash
45  return json.loads(vk_hash_json)
46 

◆ get_verification_key()

IVerificationKey zecale.core.aggregator_client.AggregatorClient.get_verification_key (   self,
IZKSnarkProvider  wrapper_zksnark 
)

Definition at line 32 of file aggregator_client.py.

33  self, wrapper_zksnark: IZKSnarkProvider) -> IVerificationKey:
34  with grpc.insecure_channel(self.endpoint) as channel:
35  stub = aggregator_pb2_grpc.AggregatorStub(channel) # type: ignore
36  vk_proto = stub.GetVerificationKey(empty_pb2.Empty())
37  return wrapper_zksnark.verification_key_from_proto(vk_proto)
38 

◆ register_application()

None zecale.core.aggregator_client.AggregatorClient.register_application (   self,
IZKSnarkProvider  nested_zksnark,
IVerificationKey  vk,
str  app_name 
)
Register an application. Throw an error with message if this fails for any
reason.

Definition at line 47 of file aggregator_client.py.

47  def register_application(
48  self,
49  nested_zksnark: IZKSnarkProvider,
50  vk: IVerificationKey,
51  app_name: str) -> None:
52  """
53  Register an application. Throw an error with message if this fails for any
54  reason.
55  """
56  app_desc = aggregator_pb2.ApplicationDescription()
57  app_desc.application_name = app_name
58  app_desc.vk.CopyFrom(nested_zksnark.verification_key_to_proto(vk)) \
59  # pylint: disable=no-member
60  with grpc.insecure_channel(self.endpoint) as channel:
61  stub = aggregator_pb2_grpc.AggregatorStub(channel) # type: ignore
62  stub.RegisterApplication(app_desc)
63 

◆ submit_nested_transaction()

None zecale.core.aggregator_client.AggregatorClient.submit_nested_transaction (   self,
IZKSnarkProvider  nested_zksnark,
NestedTransaction  nested_tx 
)
Submit a nested transaction to the aggregator.

Definition at line 64 of file aggregator_client.py.

64  def submit_nested_transaction(
65  self,
66  nested_zksnark: IZKSnarkProvider,
67  nested_tx: NestedTransaction) -> None:
68  """
69  Submit a nested transaction to the aggregator.
70  """
71  assert isinstance(nested_zksnark, IZKSnarkProvider)
72  assert isinstance(nested_tx, NestedTransaction)
73  nested_tx_proto = nested_transaction_to_proto(nested_zksnark, nested_tx)
74  with grpc.insecure_channel(self.endpoint) as channel:
75  stub = aggregator_pb2_grpc.AggregatorStub(channel) # type: ignore
76  stub.SubmitNestedTransaction(nested_tx_proto)
77 
Here is the call graph for this function:

Member Data Documentation

◆ endpoint

zecale.core.aggregator_client.AggregatorClient.endpoint

Definition at line 24 of file aggregator_client.py.


The documentation for this class was generated from the following file:
zecale.core.proto_utils.nested_transaction_to_proto
aggregator_pb2.NestedTransaction nested_transaction_to_proto(IZKSnarkProvider zksnark, NestedTransaction tx)
Definition: proto_utils.py:25
zecale.core.proto_utils.aggregated_transaction_from_proto
AggregatedTransaction aggregated_transaction_from_proto(IZKSnarkProvider zksnark, aggregator_pb2.AggregatedTransaction aggregated_transaction_proto)
Definition: proto_utils.py:38
zecale.cli.zecale_get_verification_key.get_verification_key
None get_verification_key(Context ctx, str vk_out)
Definition: zecale_get_verification_key.py:18
zecale.core.proto_utils.aggregator_configuration_from_proto
AggregatorConfiguration aggregator_configuration_from_proto(aggregator_pb2.AggregatorConfiguration aggregator_config_proto)
Definition: proto_utils.py:13