xref: /aosp_15_r20/external/tink/cc/experimental/pqcrypto/signature/subtle/falcon_sign.h (revision e7b1675dde1b92d52ec075b0a92829627f2c52a5)
1 // Copyright 2021 Google LLC
2 //
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 //     http://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 
17 #ifndef TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_FALCON_SIGN_H_
18 #define TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_FALCON_SIGN_H_
19 
20 #include <memory>
21 #include <string>
22 #include <utility>
23 
24 #include "tink/experimental/pqcrypto/signature/subtle/falcon_subtle_utils.h"
25 #include "tink/internal/fips_utils.h"
26 #include "tink/public_key_sign.h"
27 #include "tink/util/secret_data.h"
28 #include "tink/util/statusor.h"
29 
30 namespace crypto {
31 namespace tink {
32 namespace subtle {
33 
34 // Post-Quantum Signing using Falcon - Fast-Fourier Lattice-based
35 // Compact Signature over NTRU
36 class FalconSign : public PublicKeySign {
37  public:
38   static constexpr crypto::tink::internal::FipsCompatibility kFipsStatus =
39       crypto::tink::internal::FipsCompatibility::kNotFips;
40 
41   static crypto::tink::util::StatusOr<std::unique_ptr<PublicKeySign>> New(
42       const FalconPrivateKeyPqclean& private_key);
43 
44   ~FalconSign() override = default;
45 
46   // Computes the signature for 'data'.
47   crypto::tink::util::StatusOr<std::string> Sign(
48       absl::string_view data) const override;
49 
50  private:
FalconSign(const FalconPrivateKeyPqclean & private_key)51   explicit FalconSign(const FalconPrivateKeyPqclean& private_key)
52       : private_key_(private_key) {}
53 
54   const FalconPrivateKeyPqclean private_key_;
55 };
56 
57 }  // namespace subtle
58 }  // namespace tink
59 }  // namespace crypto
60 
61 #endif  // TINK_EXPERIMENTAL_PQCRYPTO_SIGNATURE_SUBTLE_FALCON_SIGN_H_
62