Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
Classes | Functions
zeth.core.pairing Namespace Reference

Classes

class  G1Point
 
class  G2Point
 
class  PairingParameters
 

Functions

G1Point g1_point_from_proto (ec_group_messages_pb2.Group1Point point)
 
None g1_point_to_proto (G1Point g1, ec_group_messages_pb2.Group1Point g1_proto)
 
List[int] g1_point_to_contract_parameters (G1Point g1)
 
G2Point g2_point_from_proto (ec_group_messages_pb2.Group2Point point)
 
None g2_point_to_proto (G2Point g2, ec_group_messages_pb2.Group2Point g2_proto)
 
List[int] g2_point_to_contract_parameters (G2Point g2)
 
PairingParameters pairing_parameters_from_proto (ec_group_messages_pb2.PairingParameters pairing_params_proto)
 
str field_element_negate (str value_hex, str mod_hex)
 
G1Point g1_point_negate (G1Point g1, PairingParameters pairing_parameters)
 
G2Point g2_point_negate (G2Point g2, PairingParameters pp)
 

Function Documentation

◆ field_element_negate()

str zeth.core.pairing.field_element_negate ( str  value_hex,
str  mod_hex 
)

Definition at line 178 of file pairing.py.

178 def field_element_negate(value_hex: str, mod_hex: str) -> str:
179  mod, num_bytes = int_and_bytelen_from_hex(mod_hex)
180  value = int(value_hex, 16)
181  value = mod - (value % mod)
182  return int_to_hex(value, num_bytes)
183 
184 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ g1_point_from_proto()

G1Point zeth.core.pairing.g1_point_from_proto ( ec_group_messages_pb2.Group1Point  point)

Definition at line 45 of file pairing.py.

46  point: ec_group_messages_pb2.Group1Point) -> G1Point:
47  x_coord = json.loads(point.x_coord)
48  y_coord = json.loads(point.y_coord)
49  assert isinstance(x_coord, str)
50  assert isinstance(y_coord, str)
51  return G1Point(x_coord, y_coord)
52 
53 
Here is the caller graph for this function:

◆ g1_point_negate()

G1Point zeth.core.pairing.g1_point_negate ( G1Point  g1,
PairingParameters  pairing_parameters 
)

Definition at line 185 of file pairing.py.

185 def g1_point_negate(
186  g1: G1Point,
187  pairing_parameters: PairingParameters) -> G1Point:
188  return G1Point(
189  g1.x_coord, field_element_negate(g1.y_coord, pairing_parameters.q))
190 
191 
Here is the call graph for this function:

◆ g1_point_to_contract_parameters()

List[int] zeth.core.pairing.g1_point_to_contract_parameters ( G1Point  g1)

Definition at line 61 of file pairing.py.

61 def g1_point_to_contract_parameters(g1: G1Point) -> List[int]:
62  return \
63  list(hex_to_uint256_list(g1.x_coord)) + \
64  list(hex_to_uint256_list(g1.y_coord))
65 
66 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ g1_point_to_proto()

None zeth.core.pairing.g1_point_to_proto ( G1Point  g1,
ec_group_messages_pb2.Group1Point  g1_proto 
)

Definition at line 54 of file pairing.py.

55  g1: G1Point,
56  g1_proto: ec_group_messages_pb2.Group1Point) -> None:
57  g1_proto.x_coord = json.dumps(g1.x_coord)
58  g1_proto.y_coord = json.dumps(g1.y_coord)
59 
60 
Here is the caller graph for this function:

◆ g2_point_from_proto()

G2Point zeth.core.pairing.g2_point_from_proto ( ec_group_messages_pb2.Group2Point  point)

Definition at line 99 of file pairing.py.

100  point: ec_group_messages_pb2.Group2Point) -> G2Point:
101  return G2Point(
102  x_coord=json.loads(point.x_coord),
103  y_coord=json.loads(point.y_coord))
104 
105 
Here is the caller graph for this function:

◆ g2_point_negate()

G2Point zeth.core.pairing.g2_point_negate ( G2Point  g2,
PairingParameters  pp 
)

Definition at line 192 of file pairing.py.

192 def g2_point_negate(
193  g2: G2Point,
194  pp: PairingParameters) -> G2Point:
195  if isinstance(g2.y_coord, str):
196  return G2Point(g2.x_coord, field_element_negate(g2.y_coord, pp.q))
197  return G2Point(
198  g2.x_coord, [field_element_negate(y, pp.q) for y in g2.y_coord])
Here is the call graph for this function:
Here is the caller graph for this function:

◆ g2_point_to_contract_parameters()

List[int] zeth.core.pairing.g2_point_to_contract_parameters ( G2Point  g2)

Definition at line 113 of file pairing.py.

113 def g2_point_to_contract_parameters(g2: G2Point) -> List[int]:
114  if isinstance(g2.x_coord, str):
115  assert isinstance(g2.y_coord, str)
116  return \
117  list(hex_to_uint256_list(g2.x_coord)) + \
118  list(hex_to_uint256_list(g2.y_coord))
119  return \
120  hex_list_to_uint256_list(g2.x_coord) + \
121  hex_list_to_uint256_list(g2.y_coord)
122 
123 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ g2_point_to_proto()

None zeth.core.pairing.g2_point_to_proto ( G2Point  g2,
ec_group_messages_pb2.Group2Point  g2_proto 
)

Definition at line 106 of file pairing.py.

107  g2: G2Point,
108  g2_proto: ec_group_messages_pb2.Group2Point) -> None:
109  g2_proto.x_coord = json.dumps(g2.x_coord)
110  g2_proto.y_coord = json.dumps(g2.y_coord)
111 
112 
Here is the caller graph for this function:

◆ pairing_parameters_from_proto()

PairingParameters zeth.core.pairing.pairing_parameters_from_proto ( ec_group_messages_pb2.PairingParameters   pairing_params_proto)

Definition at line 167 of file pairing.py.

168  pairing_params_proto: ec_group_messages_pb2.PairingParameters
169 ) -> PairingParameters:
170  return PairingParameters(
171  name=pairing_params_proto.name,
172  r=pairing_params_proto.r,
173  q=pairing_params_proto.q,
174  generator_g1=g1_point_from_proto(pairing_params_proto.generator_g1),
175  generator_g2=g2_point_from_proto(pairing_params_proto.generator_g2))
176 
177 
Here is the call graph for this function:
Here is the caller graph for this function:
zeth.core.utils.hex_list_to_uint256_list
List[int] hex_list_to_uint256_list(Sequence[Union[str, List[str]]] elements)
Definition: utils.py:189
zeth.cli.zeth_deploy.int
int
Definition: zeth_deploy.py:27
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.utils.int_to_hex
str int_to_hex(int value, int num_bytes)
Definition: utils.py:147
zeth.core.utils.int_and_bytelen_from_hex
Tuple[int, int] int_and_bytelen_from_hex(str value_hex)
Definition: utils.py:134
zeth.core.pairing.g1_point_negate
G1Point g1_point_negate(G1Point g1, PairingParameters pairing_parameters)
Definition: pairing.py:185
zeth.core.pairing.field_element_negate
str field_element_negate(str value_hex, str mod_hex)
Definition: pairing.py:178
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.pairing_parameters_from_proto
PairingParameters pairing_parameters_from_proto(ec_group_messages_pb2.PairingParameters pairing_params_proto)
Definition: pairing.py:167
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.utils.hex_to_uint256_list
Iterable[int] hex_to_uint256_list(str hex_str)
Definition: utils.py:172