Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
zksnark.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # Copyright (c) 2015-2022 Clearmatics Technologies Ltd
4 #
5 # SPDX-License-Identifier: LGPL-3.0+
6 
7 """
8 zk-SNARK abstraction
9 """
10 
11 from __future__ import annotations
12 from zeth.core.pairing import G1Point, G2Point, PairingParameters, \
13  g1_point_to_contract_parameters, g1_point_from_proto, g1_point_to_proto, \
14  g2_point_to_contract_parameters, g2_point_from_proto, g2_point_to_proto, \
15  g2_point_negate
16 from zeth.core import constants
17 from zeth.api import snark_messages_pb2
18 
19 import json
20 from abc import (ABC, abstractmethod)
21 from typing import Dict, List, Any, cast
22 # pylint: disable=unnecessary-pass
23 
24 
25 # Map from the pairing name (on PairingParameters) to contract name fragment,
26 # used in contract naming conventions.
27 PAIRING_NAME_TO_CONTRACT_NAME = {
28  "alt-bn128": "AltBN128",
29  "bls12-377": "BLS12_377",
30 }
31 
32 
33 class IVerificationKey(ABC):
34  """
35  Abstract base class of verification keys
36  """
37  @abstractmethod
38  def to_json_dict(self) -> Dict[str, Any]:
39  pass
40 
41  @staticmethod
42  @abstractmethod
43  def from_json_dict(json_dict: Dict[str, Any]) -> IVerificationKey:
44  pass
45 
46 
47 class IProof(ABC):
48  """
49  Abstract base class of proofs
50  """
51  @abstractmethod
52  def to_json_dict(self) -> Dict[str, Any]:
53  pass
54 
55  @staticmethod
56  @abstractmethod
57  def from_json_dict(json_dict: Dict[str, Any]) -> IProof:
58  pass
59 
60 
62  """
63  A GenericProof and associated inputs
64  """
65  def __init__(self, proof: IProof, inputs: List[str]):
66  self.proof = proof
67  self.inputs = inputs
68 
69  def to_json_dict(self) -> Dict[str, Any]:
70  return {
71  "proof": self.proof.to_json_dict(),
72  "inputs": self.inputs,
73  }
74 
75  @staticmethod
77  zksnark: IZKSnarkProvider,
78  json_dict: Dict[str, Any]) -> ExtendedProof:
79  return ExtendedProof(
80  proof=zksnark.proof_from_json_dict(json_dict["proof"]),
81  inputs=json_dict["inputs"])
82 
83 
84 class IZKSnarkProvider(ABC):
85  """
86  Interface to be implemented by specific zk-snark providers. Ideally, the
87  rest of the logic should deal only with this interface and have no
88  understanding of the underlying mechanisms.
89  """
90 
91  @staticmethod
92  @abstractmethod
93  def get_contract_name(pp: PairingParameters) -> str:
94  """
95  Get the verifier and mixer contracts for this SNARK.
96  """
97  pass
98 
99  @staticmethod
100  @abstractmethod
102  vk: IVerificationKey,
103  pp: PairingParameters) -> List[int]:
104  pass
105 
106  @staticmethod
107  @abstractmethod
109  vk_obj: snark_messages_pb2.VerificationKey) -> IVerificationKey:
110  pass
111 
112  @staticmethod
113  @abstractmethod
115  vk: IVerificationKey) -> snark_messages_pb2.VerificationKey:
116  pass
117 
118  @staticmethod
119  @abstractmethod
121  json_dict: Dict[str, Any]) -> IVerificationKey:
122  pass
123 
124  @staticmethod
125  @abstractmethod
126  def proof_from_json_dict(json_dict: Dict[str, Any]) -> IProof:
127  pass
128 
129  @staticmethod
130  @abstractmethod
132  ext_proof_proto: snark_messages_pb2.ExtendedProof
133  ) -> ExtendedProof:
134  pass
135 
136  @staticmethod
137  @abstractmethod
139  ext_proof: ExtendedProof) -> snark_messages_pb2.ExtendedProof:
140  pass
141 
142  @staticmethod
143  @abstractmethod
145  proof: IProof, pp: PairingParameters) -> List[int]:
146  """
147  Generate the leading parameters to the mix function for this SNARK, from a
148  GenericProof object.
149  """
150  pass
151 
152 
154 
156  def __init__(
157  self,
158  alpha: G1Point,
159  beta: G2Point,
160  delta: G2Point,
161  abc: List[G1Point]):
162  self.alpha = alpha
163  self.beta = beta
164  self.delta = delta
165  self.abc = abc
166 
167  def to_json_dict(self) -> Dict[str, Any]:
168  return {
169  "alpha": self.alpha.to_json_list(),
170  "beta": self.beta.to_json_list(),
171  "delta": self.delta.to_json_list(),
172  "ABC": [abc.to_json_list() for abc in self.abc],
173  }
174 
175  @staticmethod
176  def from_json_dict(json_dict: Dict[str, Any]) -> Groth16.VerificationKey:
178  alpha=G1Point.from_json_list(json_dict["alpha"]),
179  beta=G2Point.from_json_list(json_dict["beta"]),
180  delta=G2Point.from_json_list(json_dict["delta"]),
181  abc=[G1Point.from_json_list(abc)
182  for abc in json_dict["ABC"]])
183 
184  class Proof(IProof):
185  def __init__(
186  self,
187  a: G1Point,
188  b: G2Point,
189  c: G1Point):
190  self.a = a
191  self.b = b
192  self.c = c
193 
194  def to_json_dict(self) -> Dict[str, Any]:
195  return {
196  "a": self.a.to_json_list(),
197  "b": self.b.to_json_list(),
198  "c": self.c.to_json_list(),
199  }
200 
201  @staticmethod
202  def from_json_dict(json_dict: Dict[str, Any]) -> Groth16.Proof:
203  return Groth16.Proof(
204  a=G1Point.from_json_list(json_dict["a"]),
205  b=G2Point.from_json_list(json_dict["b"]),
206  c=G1Point.from_json_list(json_dict["c"]))
207 
208  @staticmethod
209  def get_contract_name(pp: PairingParameters) -> str:
210  return _contract_name("Groth16", pp)
211 
212  @staticmethod
214  vk: IVerificationKey,
215  pp: PairingParameters) -> List[int]:
216  assert isinstance(vk, Groth16.VerificationKey)
217  minus_beta = g2_point_negate(vk.beta, pp)
218  minus_delta = g2_point_negate(vk.delta, pp)
219  return \
220  g1_point_to_contract_parameters(vk.alpha) + \
221  g2_point_to_contract_parameters(minus_beta) + \
222  g2_point_to_contract_parameters(minus_delta) + \
223  sum(
225  for abc in vk.abc],
226  [])
227 
228  @staticmethod
230  vk_obj: snark_messages_pb2.VerificationKey
232  vk = vk_obj.groth16_verification_key
234  alpha=g1_point_from_proto(vk.alpha_g1),
235  beta=g2_point_from_proto(vk.beta_g2),
236  delta=g2_point_from_proto(vk.delta_g2),
237  abc=[G1Point.from_json_list(abc)
238  for abc in json.loads(vk.abc_g1)])
239 
240  @staticmethod
242  vk: IVerificationKey) -> snark_messages_pb2.VerificationKey:
243  assert isinstance(vk, Groth16.VerificationKey)
244  vk_obj = snark_messages_pb2.VerificationKey()
245  groth16_key = vk_obj.groth16_verification_key # pylint: disable=no-member
246  g1_point_to_proto(vk.alpha, groth16_key.alpha_g1)
247  g2_point_to_proto(vk.beta, groth16_key.beta_g2)
248  g2_point_to_proto(vk.delta, groth16_key.delta_g2)
249  groth16_key.abc_g1 = json.dumps([abc.to_json_list() for abc in vk.abc])
250  return vk_obj
251 
252  @staticmethod
254  json_dict: Dict[str, Any]) -> Groth16.VerificationKey:
255  return Groth16.VerificationKey.from_json_dict(json_dict)
256 
257  @staticmethod
258  def proof_from_json_dict(json_dict: Dict[str, Any]) -> Groth16.Proof:
259  return Groth16.Proof.from_json_dict(json_dict)
260 
261  @staticmethod
263  ext_proof_proto: snark_messages_pb2.ExtendedProof) -> ExtendedProof:
264  ext_proof = ext_proof_proto.groth16_extended_proof
265  return ExtendedProof(
266  proof=Groth16.Proof(
267  a=g1_point_from_proto(ext_proof.a),
268  b=g2_point_from_proto(ext_proof.b),
269  c=g1_point_from_proto(ext_proof.c)),
270  inputs=json.loads(ext_proof.inputs))
271 
272  @staticmethod
274  ext_proof: ExtendedProof) -> snark_messages_pb2.ExtendedProof:
275  proof = ext_proof.proof
276  assert isinstance(proof, Groth16.Proof)
277  extproof_proto = snark_messages_pb2.ExtendedProof()
278  proof_proto = extproof_proto.groth16_extended_proof \
279  # pylint: disable=no-member
280  g1_point_to_proto(proof.a, proof_proto.a)
281  g2_point_to_proto(proof.b, proof_proto.b)
282  g1_point_to_proto(proof.c, proof_proto.c)
283  proof_proto.inputs = json.dumps(ext_proof.inputs)
284  return extproof_proto
285 
286  @staticmethod
288  proof: IProof, pp: PairingParameters) -> List[int]:
289  assert isinstance(proof, Groth16.Proof)
290  return \
294 
295 
297 
299  def __init__(
300  self,
301  a: G2Point,
302  b: G1Point,
303  c: G2Point,
304  g: G2Point,
305  gb1: G1Point,
306  gb2: G2Point,
307  z: G2Point,
308  ic: List[G1Point]):
309  self.a = a
310  self.b = b
311  self.c = c
312  self.g = g
313  self.gb1 = gb1
314  self.gb2 = gb2
315  self.z = z
316  self.ic = ic
317 
318  def to_json_dict(self) -> Dict[str, Any]:
319  return {
320  "a": self.a.to_json_list(),
321  "b": self.b.to_json_list(),
322  "c": self.c.to_json_list(),
323  "g": self.g.to_json_list(),
324  "gb1": self.gb1.to_json_list(),
325  "gb2": self.gb2.to_json_list(),
326  "z": self.z.to_json_list(),
327  "ic": [ic.to_json_list() for ic in self.ic],
328  }
329 
330  @staticmethod
331  def from_json_dict(json_dict: Dict[str, Any]) -> PGHR13.VerificationKey:
332  return PGHR13.VerificationKey(
333  a=G2Point.from_json_list(json_dict["a"]),
334  b=G1Point.from_json_list(json_dict["b"]),
335  c=G2Point.from_json_list(json_dict["c"]),
336  g=G2Point.from_json_list(json_dict["g"]),
337  gb1=G1Point.from_json_list(json_dict["gb1"]),
338  gb2=G2Point.from_json_list(json_dict["gb2"]),
339  z=G2Point.from_json_list(json_dict["z"]),
340  ic=[G1Point.from_json_list(ic)
341  for ic in json_dict["ic"]])
342 
343  class Proof(IProof):
344  def __init__(
345  self,
346  a: G1Point,
347  a_p: G1Point,
348  b: G2Point,
349  b_p: G1Point,
350  c: G1Point,
351  c_p: G1Point,
352  h: G1Point,
353  k: G1Point):
354  self.a = a
355  self.a_p = a_p
356  self.b = b
357  self.b_p = b_p
358  self.c = c
359  self.c_p = c_p
360  self.h = h
361  self.k = k
362 
363  def to_json_dict(self) -> Dict[str, Any]:
364  return {
365  "a": self.a.to_json_list(),
366  "a_p": self.a_p.to_json_list(),
367  "b": self.b.to_json_list(),
368  "b_p": self.b_p.to_json_list(),
369  "c": self.c.to_json_list(),
370  "c_p": self.c_p.to_json_list(),
371  "h": self.h.to_json_list(),
372  "k": self.k.to_json_list(),
373  }
374 
375  @staticmethod
376  def from_json_dict(json_dict: Dict[str, Any]) -> PGHR13.Proof:
377  return PGHR13.Proof(
378  a=G1Point.from_json_list(json_dict["a"]),
379  a_p=G1Point.from_json_list(json_dict["a_p"]),
380  b=G2Point.from_json_list(json_dict["b"]),
381  b_p=G1Point.from_json_list(json_dict["b_p"]),
382  c=G1Point.from_json_list(json_dict["c"]),
383  c_p=G1Point.from_json_list(json_dict["c_p"]),
384  h=G1Point.from_json_list(json_dict["h"]),
385  k=G1Point.from_json_list(json_dict["k"]))
386 
387  @staticmethod
388  def get_contract_name(pp: PairingParameters) -> str:
389  return _contract_name("Pghr13", pp)
390 
391  @staticmethod
393  vk: IVerificationKey,
394  pp: PairingParameters) -> List[int]:
395  assert isinstance(vk, PGHR13.VerificationKey)
396  return \
405  for ic in vk.ic], [])
406 
407  @staticmethod
409  vk_obj: snark_messages_pb2.VerificationKey) -> PGHR13.VerificationKey:
410  vk = vk_obj.pghr13_verification_key
411  return PGHR13.VerificationKey(
412  a=g2_point_from_proto(vk.a),
413  b=g1_point_from_proto(vk.b),
414  c=g2_point_from_proto(vk.c),
415  g=g2_point_from_proto(vk.gamma),
416  gb1=g1_point_from_proto(vk.gamma_beta_g1),
417  gb2=g2_point_from_proto(vk.gamma_beta_g2),
418  z=g2_point_from_proto(vk.z),
419  ic=[G1Point.from_json_list(ic)
420  for ic in json.loads(vk.ic)])
421 
422  @staticmethod
424  vk: IVerificationKey) -> snark_messages_pb2.VerificationKey:
425  raise Exception("not implemented")
426 
427  @staticmethod
429  json_dict: Dict[str, Any]) -> PGHR13.VerificationKey:
430  return PGHR13.VerificationKey.from_json_dict(json_dict)
431 
432  @staticmethod
433  def proof_from_json_dict(json_dict: Dict[str, Any]) -> PGHR13.Proof:
434  return PGHR13.Proof.from_json_dict(json_dict)
435 
436  @staticmethod
438  ext_proof_proto: snark_messages_pb2.ExtendedProof) -> ExtendedProof:
439  ext_proof = ext_proof_proto.pghr13_extended_proof
440  return ExtendedProof(
441  proof=PGHR13.Proof(
442  a=g1_point_from_proto(ext_proof.a),
443  a_p=g1_point_from_proto(ext_proof.a_p),
444  b=g2_point_from_proto(ext_proof.b),
445  b_p=g1_point_from_proto(ext_proof.b_p),
446  c=g1_point_from_proto(ext_proof.c),
447  c_p=g1_point_from_proto(ext_proof.c_p),
448  h=g1_point_from_proto(ext_proof.h),
449  k=g1_point_from_proto(ext_proof.k)),
450  inputs=cast(List[str], json.loads(ext_proof.inputs)))
451 
452  @staticmethod
454  ext_proof: ExtendedProof) -> snark_messages_pb2.ExtendedProof:
455  proof = ext_proof.proof
456  assert isinstance(proof, PGHR13.Proof)
457  extproof_proto = snark_messages_pb2.ExtendedProof()
458  proof_proto = extproof_proto.pghr13_extended_proof \
459  # pylint: disable=no-member
460  g1_point_to_proto(proof.a, proof_proto.a)
461  g1_point_to_proto(proof.a_p, proof_proto.a_p)
462  g2_point_to_proto(proof.b, proof_proto.b)
463  g1_point_to_proto(proof.b_p, proof_proto.b_p)
464  g1_point_to_proto(proof.c, proof_proto.c)
465  g1_point_to_proto(proof.c_p, proof_proto.c_p)
466  g1_point_to_proto(proof.h, proof_proto.h)
467  g1_point_to_proto(proof.k, proof_proto.k)
468  proof_proto.inputs = json.dumps(ext_proof.inputs)
469  return extproof_proto
470 
471  @staticmethod
473  proof: IProof, pp: PairingParameters) -> List[int]:
474  assert isinstance(proof, PGHR13.Proof)
475  return \
477  g1_point_to_contract_parameters(proof.a_p) + \
479  g1_point_to_contract_parameters(proof.b_p) + \
481  g1_point_to_contract_parameters(proof.c_p) + \
484 
485 
486 def get_zksnark_provider(zksnark_name: str) -> IZKSnarkProvider:
487  if zksnark_name == constants.PGHR13_ZKSNARK:
488  return PGHR13()
489  if zksnark_name == constants.GROTH16_ZKSNARK:
490  return Groth16()
491  raise Exception(f"unknown zk-SNARK name: {zksnark_name}")
492 
493 
494 def _contract_name(zksnark_name: str, pp: PairingParameters) -> str:
495  """
496  Given a snark name fragment (as used in contract naming conventions) and
497  pairing parameters, determine the full contract name.
498  """
499  return "Mixer" + zksnark_name + PAIRING_NAME_TO_CONTRACT_NAME[pp.name]
zeth.core.zksnark.Groth16.Proof
Definition: zksnark.py:184
zeth.core.zksnark.PGHR13.VerificationKey
Definition: zksnark.py:298
zeth.core.zksnark.PGHR13.VerificationKey.gb1
gb1
Definition: zksnark.py:304
zeth.core.zksnark.PGHR13.Proof.h
h
Definition: zksnark.py:351
zeth.core.zksnark.PGHR13.Proof.__init__
def __init__(self, G1Point a, G1Point a_p, G2Point b, G1Point b_p, G1Point c, G1Point c_p, G1Point h, G1Point k)
Definition: zksnark.py:344
zeth.core.zksnark.PGHR13.Proof.c
c
Definition: zksnark.py:349
zeth.core.pairing.g1_point_to_contract_parameters
List[int] g1_point_to_contract_parameters(G1Point g1)
Definition: pairing.py:61
zeth.core.zksnark.Groth16.verification_key_to_proto
snark_messages_pb2.VerificationKey verification_key_to_proto(IVerificationKey vk)
Definition: zksnark.py:241
zeth.core.zksnark.PGHR13
Definition: zksnark.py:296
zeth.core.zksnark.PGHR13.verification_key_from_proto
PGHR13.VerificationKey verification_key_from_proto(snark_messages_pb2.VerificationKey vk_obj)
Definition: zksnark.py:408
zeth.core.zksnark.PGHR13.verification_key_to_proto
snark_messages_pb2.VerificationKey verification_key_to_proto(IVerificationKey vk)
Definition: zksnark.py:423
zeth.core.zksnark.PGHR13.VerificationKey.g
g
Definition: zksnark.py:303
zeth.core.zksnark.PGHR13.Proof
Definition: zksnark.py:343
zeth.core.zksnark.ExtendedProof.from_json_dict
ExtendedProof from_json_dict(IZKSnarkProvider zksnark, Dict[str, Any] json_dict)
Definition: zksnark.py:76
zeth.core.zksnark.Groth16.VerificationKey.alpha
alpha
Definition: zksnark.py:157
zeth.core.pairing.g2_point_from_proto
G2Point g2_point_from_proto(ec_group_messages_pb2.Group2Point point)
Definition: pairing.py:99
zeth.core.zksnark.Groth16.Proof.__init__
def __init__(self, G1Point a, G2Point b, G1Point c)
Definition: zksnark.py:185
zeth.core.zksnark.ExtendedProof.inputs
inputs
Definition: zksnark.py:67
zeth.core.zksnark.Groth16.VerificationKey.beta
beta
Definition: zksnark.py:158
zeth.core.zksnark.PGHR13.VerificationKey.gb2
gb2
Definition: zksnark.py:305
zeth.core.zksnark.ExtendedProof.proof
proof
Definition: zksnark.py:66
zeth.core.zksnark.IZKSnarkProvider.extended_proof_to_proto
snark_messages_pb2.ExtendedProof extended_proof_to_proto(ExtendedProof ext_proof)
Definition: zksnark.py:138
zeth.core.zksnark.Groth16.verification_key_from_json_dict
Groth16.VerificationKey verification_key_from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:253
zeth.core.zksnark.Groth16.Proof.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: zksnark.py:194
zeth.core.zksnark.IZKSnarkProvider.verification_key_to_proto
snark_messages_pb2.VerificationKey verification_key_to_proto(IVerificationKey vk)
Definition: zksnark.py:114
zeth.core.zksnark.PGHR13.Proof.a_p
a_p
Definition: zksnark.py:346
zeth.core.zksnark.PGHR13.get_contract_name
str get_contract_name(PairingParameters pp)
Definition: zksnark.py:388
zeth.core.zksnark.Groth16.Proof.c
c
Definition: zksnark.py:188
zeth.core.zksnark.Groth16.proof_from_json_dict
Groth16.Proof proof_from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:258
zeth.core.zksnark.PGHR13.Proof.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: zksnark.py:363
zeth.core.zksnark.PGHR13.extended_proof_from_proto
ExtendedProof extended_proof_from_proto(snark_messages_pb2.ExtendedProof ext_proof_proto)
Definition: zksnark.py:437
zeth.core.zksnark.PGHR13.verification_key_from_json_dict
PGHR13.VerificationKey verification_key_from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:428
zeth.core.zksnark.Groth16.verification_key_to_contract_parameters
List[int] verification_key_to_contract_parameters(IVerificationKey vk, PairingParameters pp)
Definition: zksnark.py:213
zeth.core.zksnark.PGHR13.Proof.from_json_dict
PGHR13.Proof from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:376
zeth.core.zksnark.PGHR13.VerificationKey.__init__
def __init__(self, G2Point a, G1Point b, G2Point c, G2Point g, G1Point gb1, G2Point gb2, G2Point z, List[G1Point] ic)
Definition: zksnark.py:299
zeth.core.zksnark.PGHR13.VerificationKey.a
a
Definition: zksnark.py:300
zeth.core.zksnark.IProof
Definition: zksnark.py:47
zeth.core.zksnark.Groth16.extended_proof_to_proto
snark_messages_pb2.ExtendedProof extended_proof_to_proto(ExtendedProof ext_proof)
Definition: zksnark.py:273
zeth.core.zksnark.Groth16.Proof.a
a
Definition: zksnark.py:186
zeth.core.zksnark.Groth16.proof_to_contract_parameters
List[int] proof_to_contract_parameters(IProof proof, PairingParameters pp)
Definition: zksnark.py:287
zeth.core.zksnark.IZKSnarkProvider.verification_key_from_json_dict
IVerificationKey verification_key_from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:120
zeth.core.zksnark.PGHR13.VerificationKey.c
c
Definition: zksnark.py:302
zeth.core.zksnark.IVerificationKey
Definition: zksnark.py:33
zeth.core.zksnark.IZKSnarkProvider.proof_from_json_dict
IProof proof_from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:126
zeth.core.zksnark.ExtendedProof.__init__
def __init__(self, IProof proof, List[str] inputs)
Definition: zksnark.py:65
zeth.core.zksnark.ExtendedProof.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: zksnark.py:69
zeth.api
Definition: __init__.py:1
zeth.core.pairing
Definition: pairing.py:1
zeth.core.zksnark.IZKSnarkProvider.verification_key_from_proto
IVerificationKey verification_key_from_proto(snark_messages_pb2.VerificationKey vk_obj)
Definition: zksnark.py:108
zeth.core.pairing.g2_point_negate
G2Point g2_point_negate(G2Point g2, PairingParameters pp)
Definition: pairing.py:192
zeth.core.zksnark.PGHR13.VerificationKey.z
z
Definition: zksnark.py:306
zeth.core.zksnark.IZKSnarkProvider
Definition: zksnark.py:84
zeth.core.zksnark.PGHR13.Proof.k
k
Definition: zksnark.py:352
zeth.core.zksnark.IZKSnarkProvider.proof_to_contract_parameters
List[int] proof_to_contract_parameters(IProof proof, PairingParameters pp)
Definition: zksnark.py:144
zeth.core.zksnark.ExtendedProof
Definition: zksnark.py:61
zeth.core.zksnark.Groth16.get_contract_name
str get_contract_name(PairingParameters pp)
Definition: zksnark.py:209
zeth.core.zksnark.Groth16.VerificationKey.__init__
def __init__(self, G1Point alpha, G2Point beta, G2Point delta, List[G1Point] abc)
Definition: zksnark.py:156
zeth.core.zksnark.PGHR13.Proof.b_p
b_p
Definition: zksnark.py:348
zeth.core.pairing.g1_point_from_proto
G1Point g1_point_from_proto(ec_group_messages_pb2.Group1Point point)
Definition: pairing.py:45
zeth.core.zksnark.IZKSnarkProvider.extended_proof_from_proto
ExtendedProof extended_proof_from_proto(snark_messages_pb2.ExtendedProof ext_proof_proto)
Definition: zksnark.py:131
zeth.core.zksnark.IVerificationKey.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: zksnark.py:38
zeth.core.zksnark.Groth16.VerificationKey.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: zksnark.py:167
zeth.core.zksnark.Groth16.VerificationKey
Definition: zksnark.py:155
zeth.core.zksnark.PGHR13.VerificationKey.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: zksnark.py:318
zeth.core.zksnark.PGHR13.proof_to_contract_parameters
List[int] proof_to_contract_parameters(IProof proof, PairingParameters pp)
Definition: zksnark.py:472
zeth.core.zksnark.PGHR13.VerificationKey.from_json_dict
PGHR13.VerificationKey from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:331
zeth.core.zksnark.IProof.to_json_dict
Dict[str, Any] to_json_dict(self)
Definition: zksnark.py:52
zeth.core.zksnark.PGHR13.VerificationKey.b
b
Definition: zksnark.py:301
zeth.core.zksnark.PGHR13.Proof.c_p
c_p
Definition: zksnark.py:350
zeth.core.pairing.g2_point_to_proto
None g2_point_to_proto(G2Point g2, ec_group_messages_pb2.Group2Point g2_proto)
Definition: pairing.py:106
zeth.core.zksnark.IZKSnarkProvider.get_contract_name
str get_contract_name(PairingParameters pp)
Definition: zksnark.py:93
zeth.core.zksnark.IVerificationKey.from_json_dict
IVerificationKey from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:43
zeth.core.zksnark.Groth16.Proof.from_json_dict
Groth16.Proof from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:202
zeth.core.zksnark.Groth16.VerificationKey.from_json_dict
Groth16.VerificationKey from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:176
zeth.core.pairing.g2_point_to_contract_parameters
List[int] g2_point_to_contract_parameters(G2Point g2)
Definition: pairing.py:113
zeth.core.zksnark.PGHR13.Proof.a
a
Definition: zksnark.py:345
zeth.core
Definition: __init__.py:1
zeth.core.zksnark.IZKSnarkProvider.verification_key_to_contract_parameters
List[int] verification_key_to_contract_parameters(IVerificationKey vk, PairingParameters pp)
Definition: zksnark.py:101
zeth.core.zksnark.Groth16.Proof.b
b
Definition: zksnark.py:187
zeth.core.zksnark.PGHR13.verification_key_to_contract_parameters
List[int] verification_key_to_contract_parameters(IVerificationKey vk, PairingParameters pp)
Definition: zksnark.py:392
zeth.core.zksnark.Groth16.extended_proof_from_proto
ExtendedProof extended_proof_from_proto(snark_messages_pb2.ExtendedProof ext_proof_proto)
Definition: zksnark.py:262
zeth.core.zksnark.IProof.from_json_dict
IProof from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:57
zeth.core.zksnark.PGHR13.proof_from_json_dict
PGHR13.Proof proof_from_json_dict(Dict[str, Any] json_dict)
Definition: zksnark.py:433
zeth.core.zksnark.Groth16.verification_key_from_proto
Groth16.VerificationKey verification_key_from_proto(snark_messages_pb2.VerificationKey vk_obj)
Definition: zksnark.py:229
zeth.core.zksnark.Groth16.VerificationKey.delta
delta
Definition: zksnark.py:159
zeth.core.pairing.g1_point_to_proto
None g1_point_to_proto(G1Point g1, ec_group_messages_pb2.Group1Point g1_proto)
Definition: pairing.py:54
zeth.core.zksnark.Groth16
Definition: zksnark.py:153
zeth.core.zksnark.get_zksnark_provider
IZKSnarkProvider get_zksnark_provider(str zksnark_name)
Definition: zksnark.py:486
zeth.core.zksnark.PGHR13.Proof.b
b
Definition: zksnark.py:347
zeth.core.zksnark.PGHR13.VerificationKey.ic
ic
Definition: zksnark.py:307
zeth.core.zksnark.PGHR13.extended_proof_to_proto
snark_messages_pb2.ExtendedProof extended_proof_to_proto(ExtendedProof ext_proof)
Definition: zksnark.py:453
zeth.core.zksnark.Groth16.VerificationKey.abc
abc
Definition: zksnark.py:160