// acetone, 2025 // I hate copyright of any kind. This is a public domain. // Original source: http://git.community.i2p/acetone/i2pdtunnelwizard // Notice for everyone who want reuse this file: this class uses i2p-styled base64 #pragma once #include #include #include #include class X25519Keys { public: X25519Keys(const std::array& sk); X25519Keys() = default; ~X25519Keys() = default; void generateKeys(); const std::array getPublicKey() const { return m_publicKey; } const std::array getSecretKey() const { return m_secretKey; } const std::shared_ptr> agree(const std::array& publicB64) const; // nullptr if failed const std::shared_ptr> agree(const std::string& publicB64) const; // nullptr if failed const std::shared_ptr> agree(const uint8_t* pkey, size_t size = 32) const; // nullptr if failed bool setSecretKey (const std::vector& sec, bool calculatePublic = false); bool setSecretKey (const std::array& sec, bool calculatePublic = false); bool setSecretKey (const std::string& sec, bool calculatePublic = false); std::string getPublicKeyBase64() const; std::string getSecretKeyBase64() const; private: bool setSecretKey (const uint8_t * sec, bool calculatePublic = false); std::array m_secretKey; std::array m_publicKey; };