Skip to content

src/crypto/ed25519_provider.hpp

Namespaces

Name
sgns
sgns::crypto

Classes

Name
class sgns::crypto::ED25519Provider

Types

Name
enum class ED25519ProviderError

Types Documentation

enum ED25519ProviderError

Enumerator Value Description
FAILED_GENERATE_KEYPAIR 1
SIGN_UNKNOWN_ERROR
VERIFY_UNKNOWN_ERROR

Source code

#ifndef SUPERGENIUS_SRC_CRYPTO_ED25519_PROVIDER_HPP
#define SUPERGENIUS_SRC_CRYPTO_ED25519_PROVIDER_HPP

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

namespace sgns::crypto {
  enum class ED25519ProviderError {
    FAILED_GENERATE_KEYPAIR = 1,
    SIGN_UNKNOWN_ERROR,   // unknown error occurred during call to `sign` method
                          // of bound function
    VERIFY_UNKNOWN_ERROR  // unknown error occured during call to `verify`
                          // method of bound function
  };

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

    virtual outcome::result<ED25519Keypair> generateKeypair() const = 0;

    virtual ED25519Keypair generateKeypair(const ED25519Seed &seed) const = 0;

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

    virtual outcome::result<bool> verify(
        const ED25519Signature &signature,
        gsl::span<uint8_t> message,
        const ED25519PublicKey &public_key) const = 0;
  };
}

OUTCOME_HPP_DECLARE_ERROR_2(sgns::crypto, ED25519ProviderError)

#endif

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