Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
test_cypher_suites.cpp File Reference
#include <boost/test/included/unit_test.hpp>
#include <fc/crypto/public_key.hpp>
#include <fc/crypto/private_key.hpp>
#include <fc/crypto/signature.hpp>
#include <fc/utility.hpp>
Include dependency graph for test_cypher_suites.cpp:

Go to the source code of this file.

Macros

#define BOOST_TEST_MODULE   cypher_suites
 

Functions

 BOOST_AUTO_TEST_CASE (test_k1)
 
 FC_LOG_AND_RETHROW ()
 
 BOOST_AUTO_TEST_CASE (test_r1)
 
 BOOST_AUTO_TEST_CASE (test_k1_recovery)
 
 BOOST_AUTO_TEST_CASE (test_r1_recovery)
 
 BOOST_AUTO_TEST_CASE (test_k1_recyle)
 
 BOOST_AUTO_TEST_CASE (test_r1_recyle)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   cypher_suites

Definition at line 1 of file test_cypher_suites.cpp.

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/6]

BOOST_AUTO_TEST_CASE ( test_k1 )

Definition at line 13 of file test_cypher_suites.cpp.

13 {
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());
const uint8_t expected_public_key[]
Definition import_ed.c:45
FC_LOG_AND_RETHROW()

◆ BOOST_AUTO_TEST_CASE() [2/6]

BOOST_AUTO_TEST_CASE ( test_k1_recovery )

Definition at line 33 of file test_cypher_suites.cpp.

33 {
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());
static private_key generate()
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
fc::sha256 digest(const T &value)
Definition digest.hpp:9
constexpr size_t const_strlen(const char *str)
Definition utility.hpp:142
bool pub
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/6]

BOOST_AUTO_TEST_CASE ( test_k1_recyle )

Definition at line 59 of file test_cypher_suites.cpp.

59 {
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());
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [4/6]

BOOST_AUTO_TEST_CASE ( test_r1 )

Definition at line 23 of file test_cypher_suites.cpp.

23 {
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());

◆ BOOST_AUTO_TEST_CASE() [5/6]

BOOST_AUTO_TEST_CASE ( test_r1_recovery )

Definition at line 46 of file test_cypher_suites.cpp.

46 {
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());
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [6/6]

BOOST_AUTO_TEST_CASE ( test_r1_recyle )

Definition at line 70 of file test_cypher_suites.cpp.

70 {
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());
Here is the call graph for this function:

◆ FC_LOG_AND_RETHROW()

FC_LOG_AND_RETHROW ( )