Blinding.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef BLINDING_H__
  2. #define BLINDING_H__
  3. #include <inttypes.h>
  4. #include <string>
  5. #include <vector>
  6. #include "Identity.h"
  7. namespace i2p
  8. {
  9. namespace data
  10. {
  11. class BlindedPublicKey // for encrypted LS2
  12. {
  13. public:
  14. BlindedPublicKey (std::shared_ptr<const IdentityEx> identity);
  15. BlindedPublicKey (const std::string& b33); // from b33 without .b32.i2p
  16. std::string ToB33 () const;
  17. const uint8_t * GetPublicKey () const { return m_PublicKey.data (); };
  18. size_t GetPublicKeyLen () const { return m_PublicKey.size (); };
  19. SigningKeyType GetSigType () const { return m_SigType; };
  20. SigningKeyType GetBlindedSigType () const { return m_BlindedSigType; };
  21. void GetSubcredential (const uint8_t * blinded, size_t len, uint8_t * subcredential) const; // 32 bytes
  22. size_t GetBlindedKey (const char * date, uint8_t * blindedKey) const; // date is 8 chars "YYYYMMDD", return public key length
  23. size_t BlindPrivateKey (const uint8_t * priv, const char * date, uint8_t * blindedPriv, uint8_t * blindedPub) const; // date is 8 chars "YYYYMMDD", return public key length
  24. i2p::data::IdentHash GetStoreHash (const char * date = nullptr) const; // date is 8 chars "YYYYMMDD", use current if null
  25. private:
  26. void GetCredential (uint8_t * credential) const; // 32 bytes
  27. void GenerateAlpha (const char * date, uint8_t * seed) const; // 64 bytes, date is 8 chars "YYYYMMDD"
  28. void H (const std::string& p, const std::vector<std::pair<const uint8_t *, size_t> >& bufs, uint8_t * hash) const;
  29. private:
  30. std::vector<uint8_t> m_PublicKey;
  31. i2p::data::SigningKeyType m_SigType, m_BlindedSigType;
  32. };
  33. }
  34. }
  35. #endif