/* * Based on * 1. OpenSSL lib * 2. PurpleI2P source code * 3. cppcodec lib * * PUBLIC DOMAIN C++ WRAPPER * acetone, 2022 */ #ifndef ED25519_H #define ED25519_H #include #include #include #include using uint8_t = unsigned char; namespace FriendlyCrypto { namespace Ed25519 { class KeyPair { public: KeyPair() {} void generateKeys() noexcept; void setSecretKey(const std::array& secret) noexcept; const std::array getSecretKey() const noexcept; const std::array getPublicKey() const noexcept; std::string getPublicKeyBase64String() const noexcept; std::string getSecretKeyBase64String() const noexcept; private: std::array m_secret; std::array m_public; }; class Signature { public: Signature(const std::array& raw) : m_data( new std::array(raw) ) {} const std::shared_ptr> data() const noexcept; std::string base64String() const noexcept; bool operator==(const Ed25519::Signature& another) const noexcept; bool operator==(const std::array& rawAnother) const noexcept; bool operator==(const std::string& base64String) const noexcept; private: std::shared_ptr> m_data; }; //// FUNCTIONS Ed25519::Signature sign (const std::vector& message, const std::array& secretKey) noexcept; bool verify (const std::vector& message, const Ed25519::Signature& signature, const std::array& publicKey) noexcept; } // namespace Ed25519 } // namespace FriendlyCrypto #endif // ED25519_H