Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_cypher_suites.cpp
Go to the documentation of this file.
1#define BOOST_TEST_MODULE cypher_suites
2#include <boost/test/included/unit_test.hpp>
3
7#include <fc/utility.hpp>
8
9using namespace fc::crypto;
10using namespace fc;
11
12BOOST_AUTO_TEST_SUITE(cypher_suites)
14 auto private_key_string = std::string("5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3");
15 auto expected_public_key = std::string("SYS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV");
16 auto test_private_key = private_key(private_key_string);
17 auto test_public_key = test_private_key.get_public_key();
18
19 BOOST_CHECK_EQUAL(private_key_string, test_private_key.to_string());
20 BOOST_CHECK_EQUAL(expected_public_key, test_public_key.to_string());
22
24 auto private_key_string = std::string("PVT_R1_iyQmnyPEGvFd8uffnk152WC2WryBjgTrg22fXQryuGL9mU6qW");
25 auto expected_public_key = std::string("PUB_R1_6EPHFSKVYHBjQgxVGQPrwCxTg7BbZ69H9i4gztN9deKTEXYne4");
26 auto test_private_key = private_key(private_key_string);
27 auto test_public_key = test_private_key.get_public_key();
28
29 BOOST_CHECK_EQUAL(private_key_string, test_private_key.to_string());
30 BOOST_CHECK_EQUAL(expected_public_key, test_public_key.to_string());
32
33BOOST_AUTO_TEST_CASE(test_k1_recovery) try {
34 auto payload = "Test Cases";
35 auto digest = sha256::hash(payload, const_strlen(payload));
37 auto pub = key.get_public_key();
38 auto sig = key.sign(digest);
39
40 auto recovered_pub = public_key(sig, digest);
41 std::cout << recovered_pub << std::endl;
42
43 BOOST_CHECK_EQUAL(recovered_pub.to_string(), pub.to_string());
45
46BOOST_AUTO_TEST_CASE(test_r1_recovery) try {
47 auto payload = "Test Cases";
48 auto digest = sha256::hash(payload, const_strlen(payload));
50 auto pub = key.get_public_key();
51 auto sig = key.sign(digest);
52
53 auto recovered_pub = public_key(sig, digest);
54 std::cout << recovered_pub << std::endl;
55
56 BOOST_CHECK_EQUAL(recovered_pub.to_string(), pub.to_string());
58
59BOOST_AUTO_TEST_CASE(test_k1_recyle) try {
61 auto pub = key.get_public_key();
62 auto pub_str = pub.to_string();
63 auto recycled_pub = public_key(pub_str);
64
65 std::cout << pub << " -> " << recycled_pub << std::endl;
66
67 BOOST_CHECK_EQUAL(pub.to_string(), recycled_pub.to_string());
69
70BOOST_AUTO_TEST_CASE(test_r1_recyle) try {
72 auto pub = key.get_public_key();
73 auto pub_str = pub.to_string();
74 auto recycled_pub = public_key(pub_str);
75
76 std::cout << pub << " -> " << recycled_pub << std::endl;
77
78 BOOST_CHECK_EQUAL(pub.to_string(), recycled_pub.to_string());
80
81
82BOOST_AUTO_TEST_SUITE_END()
static private_key generate()
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
const uint8_t expected_public_key[]
Definition import_ed.c:45
namespace sysio::chain
Definition authority.cpp:3
fc::sha256 digest(const T &value)
Definition digest.hpp:9
constexpr size_t const_strlen(const char *str)
Definition utility.hpp:142
BOOST_AUTO_TEST_CASE(test_k1)
FC_LOG_AND_RETHROW()
bool pub