Skip to content

Commit

Permalink
Update test_crypto.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Aug 6, 2024
1 parent 40f5441 commit 64e201f
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
#include "crypto.h"
#include <catch2/catch.hpp>

TEST_CASE("Lattice-based cryptography tests") {
SECTION("Key generation") {
LatticeCrypto crypto;
crypto.generate_keys();
REQUIRE(crypto.public_key() != "");
REQUIRE(crypto.private_key() != "");
}

SECTION("Encryption and decryption") {
LatticeCrypto crypto;
crypto.generate_keys();
std::string plaintext = "Hello, lattice-based cryptography!";
std::string ciphertext = crypto.encrypt(plaintext);
std::string decrypted_text = crypto.decrypt(ciphertext);
REQUIRE(decrypted_text == plaintext);
}

SECTION("Digital signatures") {
LatticeCrypto crypto;
crypto.generate_keys();
std::string message = "This is a test message";
std::string signature = crypto.sign(message);
bool verified = crypto.verify(message, signature);
REQUIRE(verified);
}
}

0 comments on commit 64e201f

Please sign in to comment.