BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface 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 )
79  :checksum(checksum),text(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 
memo_message(uint32_t checksum, const std::string &text)
Definition: memo.hpp:78
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:386
Definition: api.cpp:56
defines a message and checksum to enable validation of successful decryption
Definition: memo.hpp:75
public_key_type to
Definition: memo.hpp:43
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:73
contains only the public point of an elliptic curve key.
Definition: elliptic.hpp:35
std::string get_message(const fc::ecc::private_key &priv, const fc::ecc::public_key &pub) const
Definition: memo.cpp:58
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
vector< char > message
Definition: memo.hpp:59
public_key_type from
Definition: memo.hpp:42
an elliptic curve private key.
Definition: elliptic.hpp:89
defines the keys used to derive the shared secret
Definition: memo.hpp:40