/* * Based on * 1. OpenSSL lib * 2. PurpleI2P source code * 3. cppcodec lib * * PUBLIC DOMAIN C++ WRAPPER * acetone, 2022 */ #ifndef X25519_H #define X25519_H #include #include #include #include namespace FriendlyCrypto { class X25519Keys { public: X25519Keys(); ~X25519Keys(); void generateKeys() noexcept; void setSecretKey (const uint8_t * priv, bool calculatePublic = false) noexcept; void setSecretKey (const std::array& priv, bool calculatePublic = false) noexcept; void setSecretKey (const std::vector& priv, bool calculatePublic = false) ; void setSecretKey (const std::string& priv, bool calculatePublic = false) ; const std::array getPublicKey() const noexcept; const std::array getSecretKey() const noexcept; const std::array agree (const std::array& pub) const noexcept; const std::array agree (const std::string& pub) const noexcept; const std::array agree (const uint8_t* pub, size_t size = 32) const noexcept; const std::string getPublicKeyBase64String() const noexcept; const std::string getSecretKeyBase64String() const noexcept; private: std::array m_publicKey {0}; EVP_PKEY_CTX * m_Ctx; EVP_PKEY * m_Pkey; }; } // namespace #endif // X25519_H