i2pd/libi2pd/Elligator.h

39 lines
577 B
C
Raw Normal View History

2019-12-04 20:37:24 +00:00
#ifndef ELLIGATOR_H__
#define ELLIGATOR_H__
2019-12-05 21:03:11 +00:00
#include <inttypes.h>
2019-12-04 20:37:24 +00:00
#include <memory>
2019-12-05 21:03:11 +00:00
#include <openssl/bn.h>
2019-12-04 20:37:24 +00:00
namespace i2p
{
namespace crypto
{
class Elligator2
{
public:
Elligator2 ();
~Elligator2 ();
2019-12-05 21:03:11 +00:00
void Encode (const uint8_t * key, uint8_t * encoded) const;
2019-12-09 21:11:46 +00:00
void Decode (const uint8_t * encoded, uint8_t * key) const;
2019-12-05 21:03:11 +00:00
2019-12-07 01:29:03 +00:00
private:
void SquareRoot (const BIGNUM * x, BIGNUM * r, BN_CTX * ctx) const;
2019-12-05 21:03:11 +00:00
private:
2019-12-07 01:29:03 +00:00
BIGNUM * p, * p38, * p12, * p14, * sqrtn1, * A, * nA, * u, * iu;
2019-12-04 20:37:24 +00:00
};
std::unique_ptr<Elligator2>& GetElligator ();
}
}
#endif