contains only the public point of an elliptic curve key.
More...
#include <elliptic_em.hpp>
Definition at line 37 of file elliptic_em.hpp.
◆ public_key() [1/7]
fc::em::public_key::public_key |
( |
| ) |
|
◆ public_key() [2/7]
fc::em::public_key::public_key |
( |
const public_key & | k | ) |
|
◆ ~public_key()
fc::em::public_key::~public_key |
( |
| ) |
|
◆ public_key() [3/7]
◆ public_key() [4/7]
Definition at line 120 of file elliptic_em.cpp.
121 {
122 const char* front = &dat.data[0];
123 if( *front == 0 ){}
124 else
125 {
126 EC_KEY *key = EC_KEY_new_by_curve_name( NID_secp256k1 );
127 key = o2i_ECPublicKey( &key, (const unsigned char**)&front, sizeof(dat) );
129 EC_KEY_set_conv_form( key, POINT_CONVERSION_COMPRESSED );
130 unsigned char* buffer = (unsigned char*) my->_key.begin();
131 i2o_ECPublicKey( key, &buffer );
132 EC_KEY_free( key );
133 }
134 }
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
◆ public_key() [5/7]
Definition at line 141 of file elliptic_em.cpp.
142 {
143 int nV = c.data[0];
144 if (nV<27 || nV>=35)
146
147 if( check_canonical )
148 {
149 FC_ASSERT( is_canonical( c ),
"signature is not canonical" );
150 }
151
154
157
158 size_t serialized_result_sz = my->_key.size();
160 FC_ASSERT( serialized_result_sz == my->_key.size() );
161 }
const char * data() const
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
const secp256k1_context * _get_context()
fc::sha256 digest(const T &value)
SECP256K1_API int secp256k1_ec_pubkey_serialize(const secp256k1_context *ctx, unsigned char *output, size_t *outputlen, const secp256k1_pubkey *pubkey, unsigned int flags) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
#define SECP256K1_EC_COMPRESSED
SECP256K1_API int secp256k1_ecdsa_recoverable_signature_parse_compact(const secp256k1_context *ctx, secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *input64, int recid) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3)
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_recover(const secp256k1_context *ctx, secp256k1_pubkey *pubkey, const secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *msghash32) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
◆ public_key() [6/7]
fc::em::public_key::public_key |
( |
const compact_signature & | c, |
|
|
const unsigned char * | digest, |
|
|
bool | check_canonical = true ) |
Definition at line 163 of file elliptic_em.cpp.
163 {
164 int nV = c.data[0];
165 if (nV < 27 || nV >= 35) {
167 }
168
169 if (check_canonical) {
170 FC_ASSERT(is_canonical(c),
"signature is not canonical");
171 }
172
173
176
177
180 &secp_sig,
181 (unsigned char*)c.begin() + 1,
182 (*c.begin() - 27) & 3));
183
184
187 &secp_pub,
188 &secp_sig,
190
191
192 size_t serialized_result_sz = my->_key.size();
195 (unsigned char*)&my->_key.data,
196 &serialized_result_sz,
197 &secp_pub,
199
200
201 FC_ASSERT(serialized_result_sz == my->_key.size());
202 }
◆ public_key() [7/7]
fc::em::public_key::public_key |
( |
public_key && | pk | ) |
|
◆ child()
◆ fingerprint()
unsigned int fc::em::public_key::fingerprint |
( |
| ) |
const |
Definition at line 145 of file elliptic_em_common.cpp.
146 {
149 unsigned char* fp = (unsigned char*) hash._hash;
150 return (fp[0] << 24) | (fp[1] << 16) | (fp[2] << 8) | fp[3];
151 }
public_key_data serialize() const
static ripemd160 hash(const fc::sha512 &h)
static sha256 hash(const char *d, uint32_t dlen)
fc::array< char, 33 > public_key_data
constexpr const char ripemd160[]
◆ from_base58()
public_key fc::em::public_key::from_base58 |
( |
const std::string & | b58 | ) |
|
|
static |
Definition at line 132 of file elliptic_em_common.cpp.
133 {
134 array<char, 37> data;
137
140 FC_ASSERT( memcmp( (
char*)&check, data.data +
sizeof(key),
sizeof(check) ) == 0 );
141 memcpy( (
char*)key.data, data.data,
sizeof(key) );
142 return from_key_data(key);
143 }
std::vector< char > from_base58(const std::string &base58_str)
memcpy((char *) pInfo->slotDescription, s, l)
◆ operator public_key_data()
◆ operator=() [1/2]
Definition at line 91 of file elliptic_em.cpp.
92 {
93 my = pk.my;
94 return *this;
95 }
◆ operator=() [2/2]
Definition at line 97 of file elliptic_em.cpp.
98 {
99 my = pk.my;
100 return *this;
101 }
◆ serialize()
◆ serialize_ecc_point()
Definition at line 282 of file elliptic_em_impl_pub.cpp.
283 {
285 if( !my->_key ) return dat;
286 EC_KEY_set_conv_form( my->_key, POINT_CONVERSION_UNCOMPRESSED );
287 char* front = &dat.data[0];
288 i2o_ECPublicKey( my->_key, (unsigned char**)&front );
289 return dat;
290 }
fc::array< char, 65 > public_key_point_data
the full non-compressed version of the ECC point
◆ to_base58() [1/2]
std::string fc::em::public_key::to_base58 |
( |
| ) |
const |
Definition at line 108 of file elliptic_em.cpp.
109 {
112 }
std::string to_base58() const
Allows to convert current public key object into base58 number.
◆ to_base58() [2/2]
Definition at line 122 of file elliptic_em_common.cpp.
123 {
125 static_assert(
sizeof(
key) +
sizeof(check) == 37,
"");
126 array<char, 37> data;
127 memcpy(data.data, key.begin(), key.size());
128 memcpy(data.begin() + key.size(), (
const char*)&check,
sizeof(check));
130 }
std::string to_base58(const char *d, size_t s, const fc::yield_function_t &yield)
◆ valid()
bool fc::em::public_key::valid |
( |
| ) |
const |
Definition at line 103 of file elliptic_em.cpp.
104 {
105 return my->_key != empty_pub;
106 }
◆ operator!=
Definition at line 67 of file elliptic_em.hpp.
68 {
69 return a.serialize() != b.serialize();
70 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
◆ operator==
Definition at line 63 of file elliptic_em.hpp.
64 {
65 return a.serialize() == b.serialize();
66 }
◆ private_key
The documentation for this class was generated from the following files: