BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
memo.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
26 
27 namespace graphene { namespace protocol {
28 
40  struct memo_data
41  {
55  uint64_t nonce = 0;
59  vector<char> message;
60 
62  void set_message(const fc::ecc::private_key& priv,
63  const fc::ecc::public_key& pub, const string& msg, uint64_t custom_nonce = 0);
64 
65  std::string get_message(const fc::ecc::private_key& priv,
66  const fc::ecc::public_key& pub)const;
67  };
68 
75  struct memo_message
76  {
78  memo_message( uint32_t checksum, const std::string& text )
80 
81  uint32_t checksum = 0;
82  std::string text;
83 
84  string serialize() const;
85  static memo_message deserialize(const string& serial);
86  };
87 
88 } } // namespace graphene::protocol
89 
91 FC_REFLECT( graphene::protocol::memo_data, (from)(to)(nonce)(message) )
92 
graphene::protocol::memo_data::get_message
std::string get_message(const fc::ecc::private_key &priv, const fc::ecc::public_key &pub) const
Definition: memo.cpp:61
graphene::protocol::memo_message::memo_message
memo_message(uint32_t checksum, const std::string &text)
Definition: memo.hpp:78
graphene::protocol::memo_data::nonce
uint64_t nonce
Definition: memo.hpp:55
fc::ecc::public_key
contains only the public point of an elliptic curve key.
Definition: elliptic.hpp:35
graphene::protocol::public_key_type
Definition: types.hpp:312
graphene::protocol::memo_message::memo_message
memo_message()
Definition: memo.hpp:77
graphene::protocol::memo_data::to
public_key_type to
Definition: memo.hpp:43
graphene::protocol::memo_message::serialize
string serialize() const
Definition: memo.cpp:79
fc::ecc::private_key
an elliptic curve private key.
Definition: elliptic.hpp:89
graphene::protocol::memo_message::checksum
uint32_t checksum
Definition: memo.hpp:81
types.hpp
graphene::protocol::memo_message::deserialize
static memo_message deserialize(const string &serial)
Definition: memo.cpp:86
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::protocol::memo_data::set_message
void set_message(const fc::ecc::private_key &priv, const fc::ecc::public_key &pub, const string &msg, uint64_t custom_nonce=0)
Definition: memo.cpp:31
graphene::protocol::memo_data::message
vector< char > message
Definition: memo.hpp:59
graphene::protocol::memo_message
defines a message and checksum to enable validation of successful decryption
Definition: memo.hpp:75
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
graphene::protocol::memo_data
defines the keys used to derive the shared secret
Definition: memo.hpp:40
graphene::protocol::memo_message::text
std::string text
Definition: memo.hpp:82
graphene::protocol::memo_data::from
public_key_type from
Definition: memo.hpp:42
graphene
Definition: api.cpp:48