예제 #1
0
 def from_json_dict(
         json_dict: Dict[str, Any]) -> Groth16.VerificationKey:
     return Groth16.VerificationKey(
         alpha=G1Point.from_json_list(json_dict["alpha"]),
         beta=G2Point.from_json_list(json_dict["beta"]),
         delta=G2Point.from_json_list(json_dict["delta"]),
         abc=[G1Point.from_json_list(abc) for abc in json_dict["ABC"]])
예제 #2
0
 def from_json_dict(
         json_dict: Dict[str, Any]) -> PGHR13.VerificationKey:
     return PGHR13.VerificationKey(
         a=G2Point.from_json_list(json_dict["a"]),
         b=G1Point.from_json_list(json_dict["b"]),
         c=G2Point.from_json_list(json_dict["c"]),
         g=G2Point.from_json_list(json_dict["g"]),
         gb1=G1Point.from_json_list(json_dict["gb1"]),
         gb2=G2Point.from_json_list(json_dict["gb2"]),
         z=G2Point.from_json_list(json_dict["z"]),
         ic=[G1Point.from_json_list(ic) for ic in json_dict["ic"]])
예제 #3
0
 def verification_key_from_proto(
         vk_obj: snark_messages_pb2.VerificationKey
 ) -> Groth16.VerificationKey:
     vk = vk_obj.groth16_verification_key
     return Groth16.VerificationKey(
         alpha=g1_point_from_proto(vk.alpha_g1),
         beta=g2_point_from_proto(vk.beta_g2),
         delta=g2_point_from_proto(vk.delta_g2),
         abc=[G1Point.from_json_list(abc) for abc in json.loads(vk.abc_g1)])
예제 #4
0
 def from_json_dict(json_dict: Dict[str, Any]) -> PGHR13.Proof:
     return PGHR13.Proof(a=G1Point.from_json_list(json_dict["a"]),
                         a_p=G1Point.from_json_list(json_dict["a_p"]),
                         b=G2Point.from_json_list(json_dict["b"]),
                         b_p=G1Point.from_json_list(json_dict["b_p"]),
                         c=G1Point.from_json_list(json_dict["c"]),
                         c_p=G1Point.from_json_list(json_dict["c_p"]),
                         h=G1Point.from_json_list(json_dict["h"]),
                         k=G1Point.from_json_list(json_dict["k"]))
예제 #5
0
 def verification_key_from_proto(
         vk_obj: snark_messages_pb2.VerificationKey
 ) -> PGHR13.VerificationKey:
     vk = vk_obj.pghr13_verification_key
     return PGHR13.VerificationKey(
         a=g2_point_from_proto(vk.a),
         b=g1_point_from_proto(vk.b),
         c=g2_point_from_proto(vk.c),
         g=g2_point_from_proto(vk.gamma),
         gb1=g1_point_from_proto(vk.gamma_beta_g1),
         gb2=g2_point_from_proto(vk.gamma_beta_g2),
         z=g2_point_from_proto(vk.z),
         ic=[G1Point.from_json_list(ic) for ic in json.loads(vk.ic)])
예제 #6
0
 def _do_test_g1_proto_encode_decode(self, g1: G1Point) -> None:
     g1_proto = ec_group_messages_pb2.Group1Point()
     g1_point_to_proto(g1, g1_proto)
     g1_decoded = g1_point_from_proto(g1_proto)
     self.assertEqual(g1.to_json_list(), g1_decoded.to_json_list())
예제 #7
0
 def test_g1_proto_encode_decode(self) -> None:
     self._do_test_g1_proto_encode_decode(
         G1Point("0xaabbccdd", "0x11223344"))
예제 #8
0
 def from_json_dict(json_dict: Dict[str, Any]) -> Groth16.Proof:
     return Groth16.Proof(a=G1Point.from_json_list(json_dict["a"]),
                          b=G2Point.from_json_list(json_dict["b"]),
                          c=G1Point.from_json_list(json_dict["c"]))
예제 #9
0
        "0x0000000000000000000000000000000000000000000000000000000000000002"
    ],
    "generator_g2": [
        [
            "0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",
            "0x1800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed"
        ],
        [
            "0x090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b",
            "0x12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa"
        ],
    ]
})

ALT_BN128_G1_MINUS_1 = G1Point.from_json_list([
    "0x0000000000000000000000000000000000000000000000000000000000000001",
    "0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd45"
])

ALT_BN128_G1_8 = G1Point.from_json_list([
    "0x08b1d51d23480c10f472f5e93b9cfea88238c121fe155af7043937882c306a63",
    "0x299836713dad3fa34e337aa412466015c366af8ec50b9d7bd05aa74642822021"
])

ALT_BN128_G1_MINUS_8 = G1Point.from_json_list([
    "0x08b1d51d23480c10f472f5e93b9cfea88238c121fe155af7043937882c306a63",
    "0x06cc1801a38460866a1ccb126f3af847d41abb02a3662d116bc5e4d095fadd26"
])

ALT_BN128_G2_MINUS_1 = G2Point.from_json_list(
    [[
        "0x198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c2",