Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
pke.hpp
Go to the documentation of this file.
1#pragma once
2#include <memory>
3#include <vector>
4#include <fc/crypto/sha1.hpp>
6#include <fc/io/raw_fwd.hpp>
7#include <fc/array.hpp>
8
9namespace fc {
10 namespace detail { class pke_impl; }
11
12 class private_key;
13 class public_key;
14 void generate_key_pair( public_key&, private_key& );
15
16 typedef std::vector<char> bytes;
18
20 {
21 public:
22 public_key();
23 explicit public_key( const bytes& d );
24 public_key( const public_key& k );
27
28 operator bool()const;
29
32
33 bool verify( const sha1& digest, const array<char,2048/8>& sig )const;
34 bool verify( const sha1& digest, const signature& sig )const;
35 bool verify( const sha256& digest, const signature& sig )const;
36 bytes encrypt( const char* data, size_t len )const;
37 bytes encrypt( const bytes& )const;
38 bytes decrypt( const bytes& )const;
39
40 bytes serialize()const;
42 private:
43 std::shared_ptr<detail::pke_impl> my;
44 };
45
47 {
48 public:
50 explicit private_key( const bytes& d );
51 private_key( const private_key& k );
54
55 operator bool()const;
56
59
60 void sign( const sha1& digest, array<char,2048/8>& sig )const;
61 signature sign( const sha1& digest )const;
62 signature sign( const sha256& digest )const;
63
64 bytes decrypt( const char* bytes, size_t len )const;
65 bytes decrypt( const bytes& )const;
66 bytes encrypt( const bytes& )const;
67
68 bytes serialize()const;
70
71 private:
72 std::shared_ptr<detail::pke_impl> my;
73 };
74 bool operator==( const private_key& a, const private_key& b );
75
76 namespace raw
77 {
78 template<typename Stream>
80 {
81 bytes ser;
82 fc::raw::unpack(s,ser);
83 pk = fc::public_key( ser );
84 }
85
86 template<typename Stream>
87 void pack( Stream& s, const fc::public_key& pk)
88 {
89 fc::raw::pack( s, pk.serialize() );
90 }
91
92 template<typename Stream>
94 {
95 bytes ser;
96 fc::raw::unpack(s,ser);
97 pk = fc::private_key( ser );
98 }
99
100 template<typename Stream>
101 void pack( Stream& s, const fc::private_key& pk)
102 {
103 fc::raw::pack( s, pk.serialize() );
104 }
105 }
106 class variant;
107 void to_variant( const public_key& bi, variant& v );
108 void from_variant( const variant& v, public_key& bi );
109 void to_variant( const private_key& bi, variant& v );
110 void from_variant( const variant& v, private_key& bi );
111
112} // fc
113
const mie::Vuint & p
Definition bn.cpp:27
bytes encrypt(const bytes &) const
Definition pke.cpp:246
friend void generate_key_pair(public_key &, private_key &)
Definition pke.cpp:329
void sign(const sha1 &digest, array< char, 2048/8 > &sig) const
Definition pke.cpp:205
bytes decrypt(const char *bytes, size_t len) const
Definition pke.cpp:263
private_key & operator=(const private_key &p)
Definition pke.cpp:196
bytes serialize() const
Definition pke.cpp:294
public_key & operator=(const public_key &p)
Definition pke.cpp:61
bool verify(const sha1 &digest, const array< char, 2048/8 > &sig) const
Definition pke.cpp:69
bytes encrypt(const char *data, size_t len) const
Definition pke.cpp:87
friend void generate_key_pair(public_key &, private_key &)
Definition pke.cpp:329
bytes decrypt(const bytes &) const
Definition pke.cpp:117
bytes serialize() const
Definition pke.cpp:132
Concept for reading and writing characters.
void unpack(Stream &s, std::deque< T > &value)
Definition raw.hpp:540
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
namespace sysio::chain
Definition authority.cpp:3
fc::sha256 digest(const T &value)
Definition digest.hpp:9
std::vector< char > bytes
Definition alt_bn128.hpp:10
bytes signature
Definition pke.hpp:17
bool operator==(const array< T, N > &a, const array< T, N > &b)
Definition array.hpp:91
void generate_key_pair(public_key &, private_key &)
Definition pke.cpp:329
void from_variant(const fc::variant &v, sysio::chain::chain_id_type &cid)
void to_variant(const sysio::chain::shared_public_key &var, fc::variant &vo)
Definition authority.cpp:4
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
CK_ULONG d
char * s
size_t len