Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Classes | Static Public Member Functions | List of all members
zeth.core.zksnark.Groth16 Class Reference
Inheritance diagram for zeth.core.zksnark.Groth16:
Inheritance graph
[legend]
Collaboration diagram for zeth.core.zksnark.Groth16:
Collaboration graph
[legend]

Classes

class  Proof
 
class  VerificationKey
 

Static Public Member Functions

str get_contract_name (PairingParameters pp)
 
List[int] verification_key_to_contract_parameters (IVerificationKey vk, PairingParameters pp)
 
Groth16.VerificationKey verification_key_from_proto (snark_messages_pb2.VerificationKey vk_obj)
 
snark_messages_pb2.VerificationKey verification_key_to_proto (IVerificationKey vk)
 
Groth16.VerificationKey verification_key_from_json_dict (Dict[str, Any] json_dict)
 
Groth16.Proof proof_from_json_dict (Dict[str, Any] json_dict)
 
ExtendedProof extended_proof_from_proto (snark_messages_pb2.ExtendedProof ext_proof_proto)
 
snark_messages_pb2.ExtendedProof extended_proof_to_proto (ExtendedProof ext_proof)
 
List[int] proof_to_contract_parameters (IProof proof, PairingParameters pp)
 
- Static Public Member Functions inherited from zeth.core.zksnark.IZKSnarkProvider
IVerificationKey verification_key_from_proto (snark_messages_pb2.VerificationKey vk_obj)
 

Detailed Description

Definition at line 153 of file zksnark.py.

Member Function Documentation

◆ extended_proof_from_proto()

ExtendedProof zeth.core.zksnark.Groth16.extended_proof_from_proto ( snark_messages_pb2.ExtendedProof  ext_proof_proto)
static

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 262 of file zksnark.py.

262  def extended_proof_from_proto(
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 
Here is the call graph for this function:

◆ extended_proof_to_proto()

snark_messages_pb2.ExtendedProof zeth.core.zksnark.Groth16.extended_proof_to_proto ( ExtendedProof  ext_proof)
static

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 273 of file zksnark.py.

273  def extended_proof_to_proto(
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 
Here is the call graph for this function:

◆ get_contract_name()

str zeth.core.zksnark.Groth16.get_contract_name ( PairingParameters  pp)
static
Get the verifier and mixer contracts for this SNARK.

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 209 of file zksnark.py.

209  def get_contract_name(pp: PairingParameters) -> str:
210  return _contract_name("Groth16", pp)
211 

◆ proof_from_json_dict()

Groth16.Proof zeth.core.zksnark.Groth16.proof_from_json_dict ( Dict[str, Any]  json_dict)
static

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 258 of file zksnark.py.

258  def proof_from_json_dict(json_dict: Dict[str, Any]) -> Groth16.Proof:
259  return Groth16.Proof.from_json_dict(json_dict)
260 

◆ proof_to_contract_parameters()

List[int] zeth.core.zksnark.Groth16.proof_to_contract_parameters ( IProof  proof,
PairingParameters  pp 
)
static
Generate the leading parameters to the mix function for this SNARK, from a
GenericProof object.

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 287 of file zksnark.py.

287  def proof_to_contract_parameters(
288  proof: IProof, pp: PairingParameters) -> List[int]:
289  assert isinstance(proof, Groth16.Proof)
290  return \
294 
295 
Here is the call graph for this function:

◆ verification_key_from_json_dict()

Groth16.VerificationKey zeth.core.zksnark.Groth16.verification_key_from_json_dict ( Dict[str, Any]  json_dict)
static

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 253 of file zksnark.py.

253  def verification_key_from_json_dict(
254  json_dict: Dict[str, Any]) -> Groth16.VerificationKey:
255  return Groth16.VerificationKey.from_json_dict(json_dict)
256 

◆ verification_key_from_proto()

Groth16.VerificationKey zeth.core.zksnark.Groth16.verification_key_from_proto ( snark_messages_pb2.VerificationKey   vk_obj)
static

Definition at line 229 of file zksnark.py.

229  def verification_key_from_proto(
230  vk_obj: snark_messages_pb2.VerificationKey
231  ) -> Groth16.VerificationKey:
232  vk = vk_obj.groth16_verification_key
233  return Groth16.VerificationKey(
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 
Here is the call graph for this function:

◆ verification_key_to_contract_parameters()

List[int] zeth.core.zksnark.Groth16.verification_key_to_contract_parameters ( IVerificationKey  vk,
PairingParameters  pp 
)
static

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 213 of file zksnark.py.

213  def verification_key_to_contract_parameters(
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 
Here is the call graph for this function:

◆ verification_key_to_proto()

snark_messages_pb2.VerificationKey zeth.core.zksnark.Groth16.verification_key_to_proto ( IVerificationKey  vk)
static

Reimplemented from zeth.core.zksnark.IZKSnarkProvider.

Definition at line 241 of file zksnark.py.

241  def verification_key_to_proto(
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 
Here is the call graph for this function:

The documentation for this class was generated from the following file:
zeth.core.pairing.g1_point_to_contract_parameters
List[int] g1_point_to_contract_parameters(G1Point g1)
Definition: pairing.py:61
zeth.core.pairing.g2_point_from_proto
G2Point g2_point_from_proto(ec_group_messages_pb2.Group2Point point)
Definition: pairing.py:99
zeth.core.pairing.g2_point_negate
G2Point g2_point_negate(G2Point g2, PairingParameters pp)
Definition: pairing.py:192
zeth.core.pairing.g1_point_from_proto
G1Point g1_point_from_proto(ec_group_messages_pb2.Group1Point point)
Definition: pairing.py:45
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.pairing.g2_point_to_contract_parameters
List[int] g2_point_to_contract_parameters(G2Point g2)
Definition: pairing.py:113
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