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

Public Member Functions

def __init__ (self, Any web3, InstanceDescription instance_desc, IZKSnarkProvider zksnark)
 
bytes process_batch (self, PairingParameters pp, AggregatedTransaction batch, str application_contract_address, str eth_addr, Optional[bytes] eth_private_key)
 
None dump_logs (self, Any tx_receipt)
 

Static Public Member Functions

Tuple[DispatcherContract, InstanceDescription] deploy (Any web3, IZKSnarkProvider zksnark, PairingParameters pp, IVerificationKey vk, str eth_addr, Optional[bytes] eth_private_key)
 

Public Attributes

 web3
 
 instance
 
 zksnark
 

Detailed Description

Wrapper around operations on the zecale dispatcher contract.

Definition at line 23 of file dispatcher_contract.py.

Constructor & Destructor Documentation

◆ __init__()

def zecale.core.dispatcher_contract.DispatcherContract.__init__ (   self,
Any  web3,
InstanceDescription  instance_desc,
IZKSnarkProvider  zksnark 
)

Definition at line 28 of file dispatcher_contract.py.

28  def __init__(
29  self,
30  web3: Any,
31  instance_desc: InstanceDescription,
32  zksnark: IZKSnarkProvider):
33  self.web3 = web3
34  self.instance = instance_desc.instantiate(web3)
35  self.zksnark = zksnark
36 

Member Function Documentation

◆ deploy()

Tuple[DispatcherContract, InstanceDescription] zecale.core.dispatcher_contract.DispatcherContract.deploy ( Any  web3,
IZKSnarkProvider  zksnark,
PairingParameters  pp,
IVerificationKey  vk,
str  eth_addr,
Optional[bytes]   eth_private_key 
)
static
Deploy the contract, returning an instance of this wrapper, and a
description (which can be saved to a file to later instantiate).

Definition at line 38 of file dispatcher_contract.py.

38  def deploy(
39  web3: Any,
40  zksnark: IZKSnarkProvider,
41  pp: PairingParameters,
42  vk: IVerificationKey,
43  eth_addr: str,
44  eth_private_key: Optional[bytes]
45  ) -> Tuple[DispatcherContract, InstanceDescription]:
46  """
47  Deploy the contract, returning an instance of this wrapper, and a
48  description (which can be saved to a file to later instantiate).
49  """
50  vk_evm = zksnark.verification_key_to_contract_parameters(vk, pp)
51  instance_desc = InstanceDescription.deploy(
52  web3,
53  DISPATCHER_SOURCE_FILE,
54  "ZecaleDispatcher",
55  eth_addr,
56  eth_private_key,
57  DISPATCHER_DEPLOY_GAS,
58  {"allow_paths": CONTRACTS_DIR},
59  [vk_evm])
60  return DispatcherContract(web3, instance_desc, zksnark), instance_desc
61 

◆ dump_logs()

None zecale.core.dispatcher_contract.DispatcherContract.dump_logs (   self,
Any  tx_receipt 
)
Print out debug log information from a dispatcher invocation

Definition at line 96 of file dispatcher_contract.py.

96  def dump_logs(self, tx_receipt: Any) -> None:
97  """
98  Print out debug log information from a dispatcher invocation
99  """
100  logs = get_event_logs_from_tx_receipt(self.instance, "log", tx_receipt)
101  for event_data in logs:
102  print(f"{event_data.args['a']}: {event_data.args['v']}")

◆ process_batch()

bytes zecale.core.dispatcher_contract.DispatcherContract.process_batch (   self,
PairingParameters  pp,
AggregatedTransaction  batch,
str  application_contract_address,
str  eth_addr,
Optional[bytes]  eth_private_key 
)
Send a batch to the contracts process_batch entry point. Returns the
transaction ID.

Definition at line 62 of file dispatcher_contract.py.

62  def process_batch(
63  self,
64  pp: PairingParameters,
65  batch: AggregatedTransaction,
66  application_contract_address: str,
67  eth_addr: str,
68  eth_private_key: Optional[bytes]) -> bytes:
69  """
70  Send a batch to the contracts process_batch entry point. Returns the
71  transaction ID.
72  """
73 
74  # Encode the parameters of the entry point and create a local call
75  # object. The proof and inputs are encoded into contract parameters,
76  # and the nested_parameters are passed as raw bytes arrays.
77  proof_evm = self.zksnark.proof_to_contract_parameters(
78  batch.ext_proof.proof, pp)
79  inputs_evm = hex_list_to_uint256_list(batch.ext_proof.inputs)
80 
81  contract_call = self.instance.functions.process_batch(
82  proof_evm,
83  inputs_evm,
84  batch.nested_parameters,
85  application_contract_address)
86 
87  # Broadcast the call
88  return send_contract_call(
89  self.web3,
90  contract_call,
91  eth_addr,
92  eth_private_key,
93  None, # TODO: value (fee?)
94  None)
95 

Member Data Documentation

◆ instance

zecale.core.dispatcher_contract.DispatcherContract.instance

Definition at line 30 of file dispatcher_contract.py.

◆ web3

zecale.core.dispatcher_contract.DispatcherContract.web3

Definition at line 29 of file dispatcher_contract.py.

◆ zksnark

zecale.core.dispatcher_contract.DispatcherContract.zksnark

Definition at line 31 of file dispatcher_contract.py.


The documentation for this class was generated from the following file:
zecale.cli.zecale_deploy.deploy
None deploy(Context ctx, str verification_key_file)
Definition: zecale_deploy.py:20