-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...i_network/dapi/tests/blockchain/consensus/quantum_resistant/lattice_based/test_crypto.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |