Electroneum
Loading...
Searching...
No Matches
device.cpp File Reference
#include "gtest/gtest.h"
#include "ringct/rctOps.h"
#include "device/device_default.hpp"
Include dependency graph for device.cpp:

Go to the source code of this file.

Functions

 TEST (device, name)
 TEST (device, open_close)
 TEST (device, ops)
 TEST (device, ecdh32)

Function Documentation

◆ TEST() [1/4]

TEST ( device ,
ecdh32  )

Definition at line 117 of file device.cpp.

118{
120 rct::ecdhTuple tuple, tuple2;
122 tuple.mask = rct::skGen();
123 tuple.amount = rct::skGen();
124 tuple2 = tuple;
125 dev.ecdhEncode(tuple, key, false);
126 dev.ecdhDecode(tuple, key, false);
127 ASSERT_EQ(tuple2.mask, tuple.mask);
128 ASSERT_EQ(tuple2.amount, tuple.amount);
129}
bool ecdhDecode(rct::ecdhTuple &masked, const rct::key &sharedSec, bool short_amount) override
bool ecdhEncode(rct::ecdhTuple &unmasked, const rct::key &sharedSec, bool short_amount) override
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
const char * key
key skGen()
Definition rctOps.cpp:258
Here is the call graph for this function:

◆ TEST() [2/4]

TEST ( device ,
name  )

Definition at line 33 of file device.cpp.

34{
36 ASSERT_TRUE(dev.set_name("test"));
37 ASSERT_EQ(dev.get_name(), "test");
38}
const std::string get_name() const override
bool set_name(const std::string &name) override
#define ASSERT_TRUE(condition)
Definition gtest.h:1865
Here is the call graph for this function:

◆ TEST() [3/4]

TEST ( device ,
open_close  )

Definition at line 57 of file device.cpp.

58{
62 ASSERT_TRUE(dev.close_tx());
63}
bool close_tx(void) override
bool open_tx(crypto::secret_key &tx_key) override
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
Definition crypto.h:82
Here is the call graph for this function:

◆ TEST() [4/4]

TEST ( device ,
ops  )

Definition at line 65 of file device.cpp.

66{
68 rct::key resd, res;
69 crypto::key_derivation derd, der;
70 rct::key sk, pk;
71 crypto::secret_key sk0, sk1;
72 crypto::public_key pk0, pk1;
73 crypto::ec_scalar ressc0, ressc1;
74 crypto::key_image ki0, ki1;
75
76 rct::skpkGen(sk, pk);
79
80 dev.scalarmultKey(resd, pk, sk);
81 rct::scalarmultKey(res, pk, sk);
82 ASSERT_EQ(resd, res);
83
84 dev.scalarmultBase(resd, sk);
86 ASSERT_EQ(resd, res);
87
88 dev.sc_secret_add((crypto::secret_key&)resd, sk0, sk1);
89 sc_add((unsigned char*)&res, (unsigned char*)&sk0, (unsigned char*)&sk1);
90 ASSERT_EQ(resd, res);
91
92 dev.generate_key_derivation(pk0, sk0, derd);
94 ASSERT_FALSE(memcmp(&derd, &der, sizeof(der)));
95
96 dev.derivation_to_scalar(der, 0, ressc0);
97 crypto::derivation_to_scalar(der, 0, ressc1);
98 ASSERT_FALSE(memcmp(&ressc0, &ressc1, sizeof(ressc1)));
99
100 dev.derive_secret_key(der, 0, rct::rct2sk(sk), sk0);
101 crypto::derive_secret_key(der, 0, rct::rct2sk(sk), sk1);
102 ASSERT_EQ(sk0, sk1);
103
104 dev.derive_public_key(der, 0, rct::rct2pk(pk), pk0);
105 crypto::derive_public_key(der, 0, rct::rct2pk(pk), pk1);
106 ASSERT_EQ(pk0, pk1);
107
108 dev.secret_key_to_public_key(rct::rct2sk(sk), pk0);
109 crypto::secret_key_to_public_key(rct::rct2sk(sk), pk1);
110 ASSERT_EQ(pk0, pk1);
111
112 dev.generate_key_image(pk0, sk0, ki0);
113 crypto::generate_key_image(pk0, sk0, ki1);
114 ASSERT_EQ(ki0, ki1);
115}
bool sc_secret_add(crypto::secret_key &r, const crypto::secret_key &a, const crypto::secret_key &b) override
bool derive_public_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::public_key &pub, crypto::public_key &derived_pub) override
bool scalarmultKey(rct::key &aP, const rct::key &P, const rct::key &a) override
bool secret_key_to_public_key(const crypto::secret_key &sec, crypto::public_key &pub) override
bool generate_key_derivation(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_derivation &derivation) override
bool generate_key_image(const crypto::public_key &pub, const crypto::secret_key &sec, crypto::key_image &image) override
bool scalarmultBase(rct::key &aG, const rct::key &a) override
bool derivation_to_scalar(const crypto::key_derivation &derivation, const size_t output_index, crypto::ec_scalar &res) override
bool derive_secret_key(const crypto::key_derivation &derivation, const std::size_t output_index, const crypto::secret_key &sec, crypto::secret_key &derived_sec) override
void sc_add(unsigned char *, const unsigned char *, const unsigned char *)
#define ASSERT_FALSE(condition)
Definition gtest.h:1868
const char * res
POD_CLASS key_derivation
Definition crypto.h:101
void derive_secret_key(const key_derivation &derivation, std::size_t output_index, const secret_key &base, secret_key &derived_key)
Definition crypto.h:282
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
Definition crypto.h:272
POD_CLASS public_key
Definition crypto.h:79
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
Definition crypto.h:275
POD_CLASS key_image
Definition crypto.h:105
POD_CLASS ec_scalar
Definition crypto.h:74
bool secret_key_to_public_key(const secret_key &sec, public_key &pub)
Definition crypto.h:262
void generate_key_image(const public_key &pub, const secret_key &sec, key_image &image)
Definition crypto.h:324
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
Definition crypto.h:279
void scalarmultBase(key &aG, const key &a)
Definition rctOps.cpp:350
tuple< key, key > skpkGen()
Definition rctOps.cpp:290
void scalarmultKey(key &aP, const key &P, const key &a)
Definition rctOps.cpp:368
Here is the call graph for this function: