1 /* 2 * Copyright 2018 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef FCP_SECAGG_SERVER_SECAGG_SERVER_R3_UNMASKING_STATE_H_ 18 #define FCP_SECAGG_SERVER_SECAGG_SERVER_R3_UNMASKING_STATE_H_ 19 20 #include <memory> 21 22 #include "fcp/secagg/server/secagg_server_state.h" 23 24 namespace fcp { 25 namespace secagg { 26 27 // This class is the State for the SecAggServer when it is in the 28 // Round 3: Unmasking state. This state covers the process of collecting secret 29 // shares from clients, based on which clients submitted masked input in the 30 // previous round. Unless the server aborts a client (or itself), it should not 31 // need to send messages this state. This state should transition to 32 // SecAggServerPrngRunningState once enough secret shares have been collected. 33 // Unlike previous steps, there is no particular reason to wait for more than 34 // the bare minimum number of clients to proceed. 35 36 class SecAggServerR3UnmaskingState : public SecAggServerState { 37 public: 38 SecAggServerR3UnmaskingState( 39 std::unique_ptr<SecAggServerProtocolImpl> impl, 40 int number_of_clients_failed_after_sending_masked_input, 41 int number_of_clients_failed_before_sending_masked_input, 42 int number_of_clients_terminated_without_unmasking); 43 44 ~SecAggServerR3UnmaskingState() override; 45 46 // Handles an unmasking response or abort message from a client. 47 Status HandleMessage(uint32_t client_id, 48 const ClientToServerWrapperMessage& message) override; 49 50 bool IsNumberOfIncludedInputsCommitted() const override; 51 52 int MinimumMessagesNeededForNextRound() const override; 53 54 int NumberOfIncludedInputs() const override; 55 56 int NumberOfPendingClients() const override; 57 58 StatusOr<std::unique_ptr<SecAggServerState> > ProceedToNextRound() override; 59 60 // This will return true only after minimum_number_of_clients_to_proceed 61 // messages have been received. 62 bool ReadyForNextRound() const override; 63 64 private: 65 void HandleAbortClient(uint32_t client_id, 66 ClientDropReason reason_code) override; 67 }; 68 69 } // namespace secagg 70 } // namespace fcp 71 72 #endif // FCP_SECAGG_SERVER_SECAGG_SERVER_R3_UNMASKING_STATE_H_ 73