From 29f0e10411aba79d68fdf80fb0fd67b8b101cfa1 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 4 Dec 2019 15:37:24 -0500 Subject: [PATCH] Elligator added --- build/CMakeLists.txt | 1 + libi2pd/Elligator.cpp | 30 ++++++++++++++++++++++++++++++ libi2pd/Elligator.h | 25 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 libi2pd/Elligator.cpp create mode 100644 libi2pd/Elligator.h diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 949f6a46..a9cf3a83 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -82,6 +82,7 @@ set (LIBI2PD_SRC "${LIBI2PD_SRC_DIR}/Ed25519.cpp" "${LIBI2PD_SRC_DIR}/NTCP2.cpp" "${LIBI2PD_SRC_DIR}/Blinding.cpp" + "${LIBI2PD_SRC_DIR}/Elligator.cpp" ) if (WITH_WEBSOCKETS) diff --git a/libi2pd/Elligator.cpp b/libi2pd/Elligator.cpp new file mode 100644 index 00000000..cc49adbf --- /dev/null +++ b/libi2pd/Elligator.cpp @@ -0,0 +1,30 @@ +#include "Elligator.h" + +namespace i2p +{ +namespace crypto +{ + Elligator2::Elligator2 () + { + } + + Elligator2::~Elligator2 () + { + } + + static std::unique_ptr g_Elligator; + std::unique_ptr& GetElligator () + { + if (!g_Elligator) + { + auto el = new Elligator2(); + if (!g_Elligator) // make sure it was not created already + g_Elligator.reset (el); + else + delete el; + } + return g_Elligator; + } +} +} + diff --git a/libi2pd/Elligator.h b/libi2pd/Elligator.h new file mode 100644 index 00000000..7993ccb9 --- /dev/null +++ b/libi2pd/Elligator.h @@ -0,0 +1,25 @@ +#ifndef ELLIGATOR_H__ +#define ELLIGATOR_H__ + +#include + +namespace i2p +{ +namespace crypto +{ + + class Elligator2 + { + public: + + Elligator2 (); + ~Elligator2 (); + }; + + std::unique_ptr& GetElligator (); +} +} + +#endif + +