lokinet/test/routing/test_llarp_routing_obtainexitmessage.cpp
Jason Rhinelander f4f5ab0109 "Refactor" aka delete Crypto/CryptoManager
- Get rid of CryptoManager.
- Get rid of Crypto.
- Move all the Crypto instance methods to llarp::crypto functions.
  (None of them needed to be methods at all, so this is simple).
- Move sodium/ntru initialization into static initialization.
- Add llarp::csrng, which is an available llarp::CSRNG instance which is
  a bit easier than needing to construct a `CSRNG rng{};` in various
  places.
- Various related small simplifications/cleanups.
2023-10-24 08:40:18 -07:00

32 lines
678 B
C++

#include <llarp/exit/exit_messages.hpp>
#include <llarp/crypto/crypto.hpp>
#include <llarp/crypto/crypto_libsodium.hpp>
#include <catch2/catch.hpp>
using namespace ::llarp;
using namespace ::llarp::test;
using ObtainExitMessage = routing::ObtainExitMessage;
void
fill(Signature& s)
{
s.Fill(0xFF);
}
TEST_CASE("Sign-verify")
{
SecretKey alice{};
crypto::identity_keygen(alice);
REQUIRE(not alice.IsZero());
ObtainExitMessage msg{};
msg.S = randint();
msg.T = randint();
CHECK(msg.Sign(alice));
CHECK(msg.Verify());
CHECK(msg.I == PubKey{seckey_topublic(alice)});
CHECK(msg.version == llarp::constants::proto_version);
CHECK_FALSE(msg.Z.IsZero());
}