1 /* 2 * Copyright 2019 Google LLC. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * https://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef PRIVATE_JOIN_AND_COMPUTE_PROTOCOL_CLIENT_H_ 17 #define PRIVATE_JOIN_AND_COMPUTE_PROTOCOL_CLIENT_H_ 18 19 #include "private_join_and_compute/message_sink.h" 20 #include "private_join_and_compute/private_join_and_compute.pb.h" 21 #include "private_join_and_compute/util/status.inc" 22 23 namespace private_join_and_compute { 24 25 // Abstract class representing a server for a cryptographic protocol. 26 class ProtocolClient { 27 public: 28 virtual ~ProtocolClient() = default; 29 30 // All subclasses should send the starting client message(s) to the message 31 // sink. 32 virtual Status StartProtocol( 33 MessageSink<ClientMessage>* client_message_sink) = 0; 34 35 // All subclasses should check that the server response is the right type, 36 // and, if so, execute the next round of the client, which may involve sending 37 // one or more messages to the client message sink. 38 virtual Status Handle(const ServerMessage& server_message, 39 MessageSink<ClientMessage>* client_message_sink) = 0; 40 41 // For all subclasses, if the protocol is finished, calling this function 42 // should print the output. 43 virtual Status PrintOutput() = 0; 44 45 // All subclasses should return true if the protocol is complete, and 46 // false otherwise. 47 virtual bool protocol_finished() = 0; 48 49 protected: 50 ProtocolClient() = default; 51 }; 52 53 } // namespace private_join_and_compute 54 55 #endif // PRIVATE_JOIN_AND_COMPUTE_PROTOCOL_CLIENT_H_ 56