Skip to content

src/crypto/crypto_store.hpp

Namespaces

Name
sgns
sgns::crypto

Classes

Name
class sgns::crypto::CryptoStore

Source code

#ifndef SUPERGENIUS_CRYPTO_STORE_HPP
#define SUPERGENIUS_CRYPTO_STORE_HPP

#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
#include <libp2p/crypto/key.hpp>
#include "crypto/crypto_store/key_type.hpp"
#include "crypto/ed25519_types.hpp"
#include "crypto/sr25519_types.hpp"

namespace sgns::crypto {
  class CryptoStore {
   public:
    // currently std::filesystem::path is missing required methods in macos SDK
    // so we have to use boost's filesystem primitives
    using Path = boost::filesystem::path;

    virtual ~CryptoStore() = default;

    using ED25519Keys = std::vector<ED25519PublicKey>;
    using SR25519Keys = std::vector<SR25519PublicKey>;

    virtual outcome::result<ED25519Keypair> generateEd25519Keypair(
        KeyTypeId key_type, std::string_view mnemonic_phrase) = 0;

    virtual outcome::result<SR25519Keypair> generateSr25519Keypair(
        KeyTypeId key_type, std::string_view mnemonic_phrase) = 0;

    virtual ED25519Keypair generateEd25519Keypair(KeyTypeId key_type,
                                                  const ED25519Seed &seed) = 0;

    virtual SR25519Keypair generateSr25519Keypair(KeyTypeId key_type,
                                                  const SR25519Seed &seed) = 0;

    virtual outcome::result<ED25519Keypair> generateEd25519Keypair(
        KeyTypeId key_type) = 0;

    virtual outcome::result<SR25519Keypair> generateSr25519Keypair(
        KeyTypeId key_type) = 0;

    virtual outcome::result<ED25519Keypair> findEd25519Keypair(
        KeyTypeId key_type, const ED25519PublicKey &pk) const = 0;

    virtual outcome::result<SR25519Keypair> findSr25519Keypair(
        KeyTypeId key_type, const SR25519PublicKey &pk) const = 0;

    virtual ED25519Keys getEd25519PublicKeys(KeyTypeId key_type) const = 0;

    virtual SR25519Keys getSr25519PublicKeys(KeyTypeId key_type) const = 0;
  };
}

#endif

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