Zecale - Reconciling Privacy and Scalability on Smart-Contract Chains  0.5
Reference implementation of the Zecale protocol by Clearmatics
proto_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 zecale.core.aggregated_transaction import AggregatedTransaction
6 from zecale.core.aggregator_config import AggregatorConfiguration
7 from zecale.core.nested_transaction import NestedTransaction
8 from zecale.api import aggregator_pb2
9 from zeth.core.zksnark import IZKSnarkProvider
10 from zeth.core.pairing import pairing_parameters_from_proto
11 
12 
14  aggregator_config_proto: aggregator_pb2.AggregatorConfiguration
15 ) -> AggregatorConfiguration:
17  nested_snark_name=aggregator_config_proto.nested_snark_name,
18  wrapper_snark_name=aggregator_config_proto.wrapper_snark_name,
19  nested_pairing_parameters=pairing_parameters_from_proto(
20  aggregator_config_proto.nested_pairing_parameters),
21  wrapper_pairing_parameters=pairing_parameters_from_proto(
22  aggregator_config_proto.wrapper_pairing_parameters))
23 
24 
26  zksnark: IZKSnarkProvider,
27  tx: NestedTransaction) -> aggregator_pb2.NestedTransaction:
28  assert isinstance(tx, NestedTransaction)
29  tx_proto = aggregator_pb2.NestedTransaction()
30  tx_proto.application_name = tx.app_name
31  tx_proto.extended_proof.CopyFrom( # pylint: disable=no-member
32  zksnark.extended_proof_to_proto(tx.ext_proof))
33  tx_proto.parameters = tx.parameters
34  tx_proto.fee_in_wei = tx.fee_in_wei
35  return tx_proto
36 
37 
39  zksnark: IZKSnarkProvider,
40  aggregated_transaction_proto: aggregator_pb2.AggregatedTransaction
41 ) -> AggregatedTransaction:
42  """
43  Convert a generic protobuf AggregatedTransactionRequest to an in-memory
44  AggregatedTransaction
45  """
46  app_name = aggregated_transaction_proto.application_name
47  extproof = zksnark.extended_proof_from_proto(
48  aggregated_transaction_proto.extended_proof)
49  nested_parameters = list(aggregated_transaction_proto.nested_parameters)
50  return AggregatedTransaction(app_name, extproof, nested_parameters)
zecale.api
Definition: __init__.py:1
zecale.core.nested_transaction
Definition: nested_transaction.py:1
zecale.core.aggregated_transaction
Definition: aggregated_transaction.py:1
zecale.core.aggregated_transaction.AggregatedTransaction
Definition: aggregated_transaction.py:10
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.aggregator_config
Definition: aggregator_config.py:1
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.core.proto_utils.aggregator_configuration_from_proto
AggregatorConfiguration aggregator_configuration_from_proto(aggregator_pb2.AggregatorConfiguration aggregator_config_proto)
Definition: proto_utils.py:13
zecale.core.aggregator_config.AggregatorConfiguration
Definition: aggregator_config.py:11