11 nested_transaction_to_proto, aggregated_transaction_from_proto
12 from zeth.core.zksnark
import IZKSnarkProvider, IVerificationKey
14 from google.protobuf
import empty_pb2
20 Interface to Aggregator RPC calls. Interface uses the in-memory version of
21 objects, internally converting to the protobuf versions.
27 with grpc.insecure_channel(self.
endpoint)
as channel:
28 stub = aggregator_pb2_grpc.AggregatorStub(channel)
29 config_proto = stub.GetConfiguration(empty_pb2.Empty())
33 self, wrapper_zksnark: IZKSnarkProvider) -> IVerificationKey:
34 with grpc.insecure_channel(self.
endpoint)
as channel:
35 stub = aggregator_pb2_grpc.AggregatorStub(channel)
36 vk_proto = stub.GetVerificationKey(empty_pb2.Empty())
37 return wrapper_zksnark.verification_key_from_proto(vk_proto)
40 self, nested_zksnark: IZKSnarkProvider, vk: IVerificationKey) -> str:
41 with grpc.insecure_channel(self.
endpoint)
as channel:
42 stub = aggregator_pb2_grpc.AggregatorStub(channel)
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)
49 nested_zksnark: IZKSnarkProvider,
51 app_name: str) ->
None:
53 Register an application. Throw an error with message if this fails for any
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)) \
60 with grpc.insecure_channel(self.
endpoint)
as channel:
61 stub = aggregator_pb2_grpc.AggregatorStub(channel)
62 stub.RegisterApplication(app_desc)
66 nested_zksnark: IZKSnarkProvider,
67 nested_tx: NestedTransaction) ->
None:
69 Submit a nested transaction to the aggregator.
71 assert isinstance(nested_zksnark, IZKSnarkProvider)
72 assert isinstance(nested_tx, NestedTransaction)
74 with grpc.insecure_channel(self.
endpoint)
as channel:
75 stub = aggregator_pb2_grpc.AggregatorStub(channel)
76 stub.SubmitNestedTransaction(nested_tx_proto)
80 wrapper_zksnark: IZKSnarkProvider,
81 name: str) -> AggregatedTransaction:
83 Request an aggregated transaction.
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)
89 agg_tx_proto = stub.GenerateAggregatedTransaction(agg_tx_request)