Kagome
Polkadot Runtime Engine in C++17
ecdsa_provider_impl.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CRYPTO_ECDSA_PROVIDER_IMPL_H
7 #define KAGOME_CRYPTO_ECDSA_PROVIDER_IMPL_H
8 
10 
11 #include "libp2p/crypto/ecdsa_provider/ecdsa_provider_impl.hpp"
12 #include "log/logger.hpp"
13 
14 namespace kagome::crypto {
15 
17  public:
18  enum class Error { VERIFICATION_FAILED = 1, SIGN_FAILED };
19  using Libp2pEcdsaProvider = libp2p::crypto::ecdsa::EcdsaProvider;
20  using Libp2pEcdsaProviderImpl = libp2p::crypto::ecdsa::EcdsaProviderImpl;
21 
23 
24  explicit EcdsaProviderImpl(std::shared_ptr<Libp2pEcdsaProvider> provider);
25 
26  outcome::result<EcdsaKeypairAndSeed> generate() const override;
27 
28  outcome::result<EcdsaPublicKey> derive(
29  const EcdsaSeed &seed) const override;
30 
31  outcome::result<EcdsaSignature> sign(
32  gsl::span<const uint8_t> message,
33  const EcdsaPrivateKey &key) const override;
34 
35  outcome::result<EcdsaSignature> signPrehashed(
36  const EcdsaPrehashedMessage &message,
37  const EcdsaPrivateKey &key) const override;
38 
39  outcome::result<bool> verify(
40  gsl::span<const uint8_t> message,
41  const EcdsaSignature &signature,
42  const EcdsaPublicKey &publicKey) const override;
43 
44  outcome::result<bool> verifyPrehashed(
45  const EcdsaPrehashedMessage &message,
46  const EcdsaSignature &signature,
47  const EcdsaPublicKey &publicKey) const override;
48 
49  private:
50  std::shared_ptr<Libp2pEcdsaProvider> provider_;
52  };
53 
54 } // namespace kagome::crypto
55 
57 
58 #endif // KAGOME_CRYPTO_ECDSA_PROVIDER_IMPL_H
outcome::result< EcdsaPublicKey > derive(const EcdsaSeed &seed) const override
outcome::result< EcdsaSignature > signPrehashed(const EcdsaPrehashedMessage &message, const EcdsaPrivateKey &key) const override
outcome::result< EcdsaKeypairAndSeed > generate() const override
libp2p::crypto::ecdsa::EcdsaProviderImpl Libp2pEcdsaProviderImpl
std::vector< uint8_t > EcdsaSignature
Definition: ecdsa_types.hpp:43
OUTCOME_HPP_DECLARE_ERROR(kagome::crypto, EcdsaProviderImpl::Error)
outcome::result< bool > verify(gsl::span< const uint8_t > message, const EcdsaSignature &signature, const EcdsaPublicKey &publicKey) const override
libp2p::crypto::ecdsa::PrehashedMessage EcdsaPrehashedMessage
Definition: ecdsa_types.hpp:45
std::shared_ptr< soralog::Logger > Logger
Definition: logger.hpp:23
libp2p::crypto::ecdsa::EcdsaProvider Libp2pEcdsaProvider
outcome::result< bool > verifyPrehashed(const EcdsaPrehashedMessage &message, const EcdsaSignature &signature, const EcdsaPublicKey &publicKey) const override
outcome::result< EcdsaSignature > sign(gsl::span< const uint8_t > message, const EcdsaPrivateKey &key) const override
std::shared_ptr< Libp2pEcdsaProvider > provider_