xref: /aosp_15_r20/external/private-join-and-compute/private_join_and_compute/util/elgamal_key_util.h (revision a6aa18fbfbf9cb5cd47356a9d1b057768998488c)
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_UTIL_ELGAMAL_KEY_UTIL_H_
17 #define PRIVATE_JOIN_AND_COMPUTE_UTIL_ELGAMAL_KEY_UTIL_H_
18 
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 #include "private_join_and_compute/crypto/elgamal.pb.h"
24 #include "private_join_and_compute/util/status.inc"
25 
26 namespace private_join_and_compute::elgamal_key_util {
27 
28 // Generates a pair of public, private ElGamal keys and writes them to the
29 // provided files as ::private_join_and_compute::ElGamalPublicKey and
30 // ::private_join_and_compute::ElGamalPrivateKey proto messages.
31 Status GenerateElGamalKeyPair(int curve_id, absl::string_view pub_key_filename,
32                               absl::string_view prv_key_filename);
33 
34 // Joins the shares of ElGamal public keys into a joint key.
35 // The shares and joint keys are encoded as
36 // ::private_join_and_compute::ElGamalPublicKey proto messages.
37 Status ComputeJointElGamalPublicKey(
38     int curve_id, const std::vector<std::string>& shares_filenames,
39     absl::string_view join_pub_key_key_filename);
40 
41 }  // namespace private_join_and_compute::elgamal_key_util
42 
43 #endif  // PRIVATE_JOIN_AND_COMPUTE_UTIL_ELGAMAL_KEY_UTIL_H_
44