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_SERVER_H_ 17 #define PRIVATE_JOIN_AND_COMPUTE_PROTOCOL_SERVER_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 // 27 // In all subclasses, the server should expect the first protocol message to be 28 // sent by the client. (If the protocol requires the server to send the first 29 // meaningful message, the first client message can be a dummy.) 30 class ProtocolServer { 31 public: 32 virtual ~ProtocolServer() = default; 33 34 // All subclasses should check that the client_message is the right type, and, 35 // if so, execute the next round of the server, which may involve sending one 36 // or more messages to the server message sink. 37 virtual Status Handle(const ClientMessage& client_message, 38 MessageSink<ServerMessage>* server_message_sink) = 0; 39 40 // All subclasses should return true if the protocol is complete, and false 41 // otherwise. 42 virtual bool protocol_finished() = 0; 43 44 protected: 45 ProtocolServer() = default; 46 }; 47 48 } // namespace private_join_and_compute 49 50 #endif // PRIVATE_JOIN_AND_COMPUTE_PROTOCOL_SERVER_H_ 51