StormByte C++ Library: Crypto module 0.0.9999
StormByte-Crypto is a StormByte library module for handling cryptographic operations
Loading...
Searching...
No Matches
generic.hxx
1#pragma once
2
3#include <StormByte/crypto/keypair/generic.hxx>
4
9namespace StormByte::Crypto::Secret {
14 enum class Type {
15 ECDH,
16 X25519,
17 };
18
23 class STORMBYTE_CRYPTO_PUBLIC Generic: public StormByte::Clonable<Generic> {
24 public:
29 Generic(const Generic& other) = default;
30
35 Generic(Generic&& other) noexcept = default;
36
40 virtual ~Generic() noexcept = default;
41
47 Generic& operator=(const Generic& other) = default;
48
54 Generic& operator=(Generic&& other) noexcept = default;
55
60 KeyPair::Generic::PointerType KeyPair() const noexcept {
61 return m_keypair;
62 }
63
68 enum Type Type() const noexcept {
69 return m_type;
70 }
71
77 inline std::optional<std::string> Share(const std::string& peerPublicKey) const noexcept {
78 return DoShare(peerPublicKey);
79 }
80
81 protected:
82 enum Type m_type;
83 KeyPair::Generic::PointerType m_keypair;
84
89 inline Generic(enum Type type, KeyPair::Generic::PointerType keypair):
90 m_type(type), m_keypair(keypair) {}
91
96 inline Generic(enum Type type, const KeyPair::Generic& keypair):
97 m_type(type), m_keypair(keypair.Clone()) {}
98
103 inline Generic(enum Type type, KeyPair::Generic&& keypair):
104 m_type(type), m_keypair(keypair.Move()) {}
105
106 private:
112 virtual std::optional<std::string> DoShare(const std::string& peerPublicKey) const noexcept = 0;
113 };
114
121 STORMBYTE_CRYPTO_PUBLIC Generic::PointerType Create(enum Type type, KeyPair::Generic::PointerType keypair) noexcept;
122}
A generic class.
Definition generic.hxx:34
A generic secret class.
Definition generic.hxx:23
enum Type m_type
The type of secret generator.
Definition generic.hxx:82
Generic(Generic &&other) noexcept=default
Move constructor.
std::optional< std::string > Share(const std::string &peerPublicKey) const noexcept
Shares the secret with a peer using their public key.
Definition generic.hxx:77
Generic(enum Type type, KeyPair::Generic &&keypair)
Constructor.
Definition generic.hxx:103
virtual ~Generic() noexcept=default
Virtual destructor.
enum Type Type() const noexcept
Gets the type of the secret share generator used for secret sharing.
Definition generic.hxx:68
Generic(enum Type type, KeyPair::Generic::PointerType keypair)
Constructor.
Definition generic.hxx:89
Generic(enum Type type, const KeyPair::Generic &keypair)
Constructor.
Definition generic.hxx:96
Generic(const Generic &other)=default
Copy constructor.
KeyPair::Generic::PointerType m_keypair
The keypair used for secret sharing.
Definition generic.hxx:83
The namespace containing all the keypair-related classes.