Пример #1
0
 def _do_test_verification_key_proto_encode_decode(
         self, vk: zksnark.GenericVerificationKey,
         snark: zksnark.IZKSnarkProvider) -> None:
     vk_proto = snark.verification_key_to_proto(vk)
     vk_decoded = snark.verification_key_from_proto(vk_proto)
     # For now, compare as json to brush over tuple-list differences.
     self.assertEqual(json.dumps(vk), json.dumps(vk_decoded))
Пример #2
0
 def _do_test_verification_key_proto_encode_decode(
         self,
         vk: IVerificationKey,
         snark: IZKSnarkProvider) -> None:
     vk_proto = snark.verification_key_to_proto(vk)
     vk_decoded = snark.verification_key_from_proto(vk_proto)
     # For now, compare as json to brush over tuple-list differences.
     self.assertEqual(vk.to_json_dict(), vk_decoded.to_json_dict())
Пример #3
0
 def get_nested_verification_key_hash(self,
                                      nested_zksnark: IZKSnarkProvider,
                                      vk: IVerificationKey) -> str:
     with grpc.insecure_channel(self.endpoint) as channel:
         stub = aggregator_pb2_grpc.AggregatorStub(channel)  # type: ignore
         vk_proto = nested_zksnark.verification_key_to_proto(vk)
         vk_hash_json = stub.GetNestedVerificationKeyHash(vk_proto).hash
         return json.loads(vk_hash_json)
Пример #4
0
    def register_application(self, nested_zksnark: IZKSnarkProvider,
                             vk: IVerificationKey, app_name: str) -> None:
        """
        Register an application. Throw an error with message if this fails for any
        reason.
        """
        app_desc = aggregator_pb2.ApplicationDescription()
        app_desc.application_name = app_name
        app_desc.vk.CopyFrom(nested_zksnark.verification_key_to_proto(vk)) \
            # pylint: disable=no-member

        with grpc.insecure_channel(self.endpoint) as channel:
            stub = aggregator_pb2_grpc.AggregatorStub(channel)  # type: ignore
            stub.RegisterApplication(app_desc)