#pragma once #include "sodium/crypto_hash_sha256.h" #include "sodium/crypto_sign.h" #include #include #include namespace Protocol { struct SignedMessage { unsigned char sender_key_fingerprint[crypto_hash_sha256_BYTES]; std::string plaintext; int64_t timestamp; unsigned char signature[crypto_sign_BYTES]; // signs fields 1-3 // Fills the fields and signs the plaintext SignedMessage(unsigned char sender_pub_key[crypto_sign_PUBLICKEYBYTES], unsigned char sender_priv_key[crypto_sign_SECRETKEYBYTES], std::string plaintext); std::vector serialize(); bool valid(unsigned char pub_key[crypto_sign_PUBLICKEYBYTES]); }; struct StunReplay { uint32_t addr; // ipv4 only support! uint16_t port; bool is_behind_symmetric_nat = false; StunReplay(std::string ip, uint16_t port); StunReplay(uint32_t ip, uint16_t port); }; } // namespace Protocol