Kagome
Polkadot Runtime Engine in C++17
sr25519_provider.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_CRYPTO_SR25519_PROVIDER_HPP
7 #define KAGOME_CORE_CRYPTO_SR25519_PROVIDER_HPP
8 
9 #include <gsl/span>
10 #include <outcome/outcome.hpp>
11 #include "crypto/sr25519_types.hpp"
12 
13 namespace kagome::crypto {
14 
18  enum class Sr25519ProviderError {
19  SIGN_UNKNOWN_ERROR = 1, // unknown error occured during call to `sign`
20  // method of bound function
21  VERIFY_UNKNOWN_ERROR // unknown error occured during call to `verify`
22  // method of bound function
23  };
24 
26  public:
27  virtual ~Sr25519Provider() = default;
28 
32  virtual Sr25519KeypairAndSeed generateKeypair() const = 0;
33 
37  virtual Sr25519Keypair generateKeypair(const Sr25519Seed &seed) const = 0;
38 
47  virtual outcome::result<Sr25519Signature> sign(
48  const Sr25519Keypair &keypair,
49  gsl::span<const uint8_t> message) const = 0;
50 
55  virtual outcome::result<bool> verify(
56  const Sr25519Signature &signature,
57  gsl::span<const uint8_t> message,
58  const Sr25519PublicKey &public_key) const = 0;
59 
60  virtual outcome::result<bool> verify_deprecated(
61  const Sr25519Signature &signature,
62  gsl::span<const uint8_t> message,
63  const Sr25519PublicKey &public_key) const = 0;
64  };
65 } // namespace kagome::crypto
66 
68 
69 #endif // KAGOME_CORE_CRYPTO_SR25519_PROVIDER_HPP
OUTCOME_HPP_DECLARE_ERROR(kagome::api, JRpcServerImpl::Error)