xref: /aosp_15_r20/external/federated-compute/fcp/secagg/server/secagg_server_aborted_state.h (revision 14675a029014e728ec732f129a32e299b2da0601)
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_ABORTED_STATE_H_
18 #define FCP_SECAGG_SERVER_SECAGG_SERVER_ABORTED_STATE_H_
19 
20 #include <memory>
21 #include <string>
22 
23 #include "fcp/secagg/server/secagg_server_state.h"
24 
25 namespace fcp {
26 namespace secagg {
27 
28 // This class is the State for the SecAggServer after it has aborted. The server
29 // cannot transition out of this state; a new SecAggServer object will be needed
30 // to start a new run of the protocol. However, an aborted SecAggServer still
31 // stores some of the information about the server before it aborted.
32 
33 class SecAggServerAbortedState : public SecAggServerState {
34  public:
35   SecAggServerAbortedState(
36       const std::string& error_message,
37       std::unique_ptr<SecAggServerProtocolImpl> impl,
38       int number_of_clients_failed_after_sending_masked_input,
39       int number_of_clients_failed_before_sending_masked_input,
40       int number_of_clients_terminated_without_unmasking);
41 
42   ~SecAggServerAbortedState() override;
43 
44   // Returns true.
45   bool IsAborted() const override;
46 
47   // Returns an error message explaining why the server aborted.
48   StatusOr<std::string> ErrorMessage() const override;
49 
50   bool IsNumberOfIncludedInputsCommitted() const override;
51 
52  private:
53   const std::string error_message_;
54 };
55 
56 }  // namespace secagg
57 }  // namespace fcp
58 
59 #endif  // FCP_SECAGG_SERVER_SECAGG_SERVER_ABORTED_STATE_H_
60