Electroneum
Loading...
Searching...
No Matches
hw::trezor::protocol Namespace Reference

Namespaces

namespace  crypto
namespace  ki
namespace  tx

Functions

std::string key_to_string (const ::crypto::ec_point &key)
std::string key_to_string (const ::crypto::ec_scalar &key)
std::string key_to_string (const ::crypto::hash &key)
std::string key_to_string (const ::rct::key &key)
void string_to_key (::crypto::ec_scalar &key, const std::string &str)
void string_to_key (::crypto::ec_point &key, const std::string &str)
void string_to_key (::rct::key &key, const std::string &str)
template<class sub_t, class InputIterator>
void assign_to_repeatable (::google::protobuf::RepeatedField< sub_t > *dst, const InputIterator begin, const InputIterator end)
template<class sub_t, class InputIterator>
void assign_from_repeatable (std::vector< sub_t > *dst, const InputIterator begin, const InputIterator end)
template<typename T>
bool cn_deserialize (const void *buff, size_t len, T &dst)
template<typename T>
bool cn_deserialize (const std::string &str, T &dst)
template<typename T>
std::string cn_serialize (T &obj)

Function Documentation

◆ assign_from_repeatable()

template<class sub_t, class InputIterator>
void hw::trezor::protocol::assign_from_repeatable ( std::vector< sub_t > * dst,
const InputIterator begin,
const InputIterator end )

Definition at line 61 of file protocol.hpp.

61 {
62 for (InputIterator it = begin; it != end; it++) {
63 dst->push_back(*it);
64 }
65 };
Here is the caller graph for this function:

◆ assign_to_repeatable()

template<class sub_t, class InputIterator>
void hw::trezor::protocol::assign_to_repeatable ( ::google::protobuf::RepeatedField< sub_t > * dst,
const InputIterator begin,
const InputIterator end )

Definition at line 53 of file protocol.hpp.

53 {
54 for (InputIterator it = begin; it != end; it++) {
55 auto s = dst->Add();
56 *s = *it;
57 }
58 }
Here is the caller graph for this function:

◆ cn_deserialize() [1/2]

template<typename T>
bool hw::trezor::protocol::cn_deserialize ( const std::string & str,
T & dst )

Definition at line 77 of file protocol.hpp.

77 {
78 return cn_deserialize(str.data(), str.size(), dst);
79 }
bool cn_deserialize(const void *buff, size_t len, T &dst)
Definition protocol.hpp:68
Here is the call graph for this function:

◆ cn_deserialize() [2/2]

template<typename T>
bool hw::trezor::protocol::cn_deserialize ( const void * buff,
size_t len,
T & dst )

Definition at line 68 of file protocol.hpp.

68 {
69 std::stringstream ss;
70 ss.write(static_cast<const char *>(buff), len); //ss << tx_blob;
72 bool r = ::serialization::serialize(ba, dst);
73 return r;
74 }
bool serialize(Archive &ar, T &v)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cn_serialize()

template<typename T>
std::string hw::trezor::protocol::cn_serialize ( T & obj)

Definition at line 82 of file protocol.hpp.

82 {
83 std::ostringstream oss;
84 binary_archive<true> oar(oss);
85 bool success = ::serialization::serialize(oar, obj);
86 if (!success){
87 throw exc::EncodingException("Could not CN serialize given object");
88 }
89 return oss.str();
90 }
Here is the call graph for this function:

◆ key_to_string() [1/4]

std::string hw::trezor::protocol::key_to_string ( const ::crypto::ec_point & key)

Definition at line 80 of file protocol.cpp.

80 {
81 return std::string(key.data, sizeof(key.data));
82 }
const char * key
Here is the caller graph for this function:

◆ key_to_string() [2/4]

std::string hw::trezor::protocol::key_to_string ( const ::crypto::ec_scalar & key)

Definition at line 84 of file protocol.cpp.

84 {
85 return std::string(key.data, sizeof(key.data));
86 }

◆ key_to_string() [3/4]

std::string hw::trezor::protocol::key_to_string ( const ::crypto::hash & key)

Definition at line 88 of file protocol.cpp.

88 {
89 return std::string(key.data, sizeof(key.data));
90 }

◆ key_to_string() [4/4]

std::string hw::trezor::protocol::key_to_string ( const ::rct::key & key)

Definition at line 92 of file protocol.cpp.

92 {
93 return std::string(reinterpret_cast<const char*>(key.bytes), sizeof(key.bytes));
94 }

◆ string_to_key() [1/3]

void hw::trezor::protocol::string_to_key ( ::crypto::ec_point & key,
const std::string & str )

Definition at line 103 of file protocol.cpp.

103 {
104 if (str.size() != sizeof(key.data)){
105 throw std::invalid_argument(std::string("Key has to have ") + std::to_string(sizeof(key.data)) + " B");
106 }
107 memcpy(key.data, str.data(), sizeof(key.data));
108 }
void * memcpy(void *a, const void *b, size_t c)
Here is the call graph for this function:

◆ string_to_key() [2/3]

void hw::trezor::protocol::string_to_key ( ::crypto::ec_scalar & key,
const std::string & str )

Definition at line 96 of file protocol.cpp.

96 {
97 if (str.size() != sizeof(key.data)){
98 throw std::invalid_argument(std::string("Key has to have ") + std::to_string(sizeof(key.data)) + " B");
99 }
100 memcpy(key.data, str.data(), sizeof(key.data));
101 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ string_to_key() [3/3]

void hw::trezor::protocol::string_to_key ( ::rct::key & key,
const std::string & str )

Definition at line 110 of file protocol.cpp.

110 {
111 if (str.size() != sizeof(key.bytes)){
112 throw std::invalid_argument(std::string("Key has to have ") + std::to_string(sizeof(key.bytes)) + " B");
113 }
114 memcpy(key.bytes, str.data(), sizeof(key.bytes));
115 }
Here is the call graph for this function: