Skip to content

src/crypto/sr25519_provider.hpp

Namespaces

Name
sgns
sgns::crypto

Classes

Name
class sgns::crypto::SR25519Provider

Types

Name
enum class SR25519ProviderError

Types Documentation

enum SR25519ProviderError

Enumerator Value Description
SIGN_UNKNOWN_ERROR 1
VERIFY_UNKNOWN_ERROR

sr25519 provider error codes

Source code

#ifndef SUPERGENIUS_SRC_CRYPTO_SR25519_PROVIDER_HPP
#define SUPERGENIUS_SRC_CRYPTO_SR25519_PROVIDER_HPP

#include <gsl/span>
#include "outcome/outcome.hpp"
#include "crypto/sr25519_types.hpp"
#include "singleton/IComponent.hpp"

namespace sgns::crypto {

  enum class SR25519ProviderError {
    SIGN_UNKNOWN_ERROR = 1,  // unknown error occured during call to `sign`
                             // method of bound function
    VERIFY_UNKNOWN_ERROR     // unknown error occured during call to `verify`
                             // method of bound function
  };

  class SR25519Provider : public IComponent {
   public:
       ~SR25519Provider() override = default;

    virtual SR25519Keypair generateKeypair() const = 0;

    virtual SR25519Keypair generateKeypair(const SR25519Seed &seed) const = 0;

    virtual outcome::result<SR25519Signature> sign(
        const SR25519Keypair &keypair, gsl::span<const uint8_t> message) const = 0;

    virtual outcome::result<bool> verify(
        const SR25519Signature &signature,
        gsl::span<const uint8_t> message,
        const SR25519PublicKey &public_key) const = 0;
  };
}  // namespace sgns::crypto

OUTCOME_HPP_DECLARE_ERROR_2(sgns::crypto, SR25519ProviderError)

#endif  // SUPERGENIUS_SRC_CRYPTO_SR25519_PROVIDER_HPP

Updated on 2026-03-04 at 13:10:44 -0800