contains only the public point of an elliptic curve key.
More...
#include <elliptic.hpp>
Definition at line 35 of file elliptic.hpp.
◆ public_key() [1/6]
fc::ecc::public_key::public_key |
( |
| ) |
|
◆ public_key() [2/6]
fc::ecc::public_key::public_key |
( |
const public_key & | k | ) |
|
◆ ~public_key()
fc::ecc::public_key::~public_key |
( |
| ) |
|
◆ public_key() [3/6]
Definition at line 306 of file elliptic_impl_pub.cpp.
307 {
308 const char* front = &dat.data[0];
309 if( *front == 0 ){}
310 else
311 {
312 my->_key = EC_KEY_new_by_curve_name( NID_secp256k1 );
313 my->_key = o2i_ECPublicKey( &my->_key, (
const unsigned char**)&front,
sizeof(
public_key_data) );
314 if( !my->_key )
315 {
316 FC_THROW_EXCEPTION( exception,
"error decoding public key", (
"s", ERR_error_string( ERR_get_error(),
nullptr) ) );
317 }
318 }
319 }
#define FC_THROW_EXCEPTION(EXCEPTION, FORMAT,...)
fc::array< char, 33 > public_key_data
◆ public_key() [4/6]
Definition at line 292 of file elliptic_impl_pub.cpp.
293 {
294 const char* front = &dat.data[0];
295 if( *front == 0 ){}
296 else
297 {
298 my->_key = EC_KEY_new_by_curve_name( NID_secp256k1 );
299 my->_key = o2i_ECPublicKey( &my->_key, (const unsigned char**)&front, sizeof(dat) );
300 if( !my->_key )
301 {
302 FC_THROW_EXCEPTION( exception,
"error decoding public key", (
"s", ERR_error_string( ERR_get_error(),
nullptr) ) );
303 }
304 }
305 }
◆ public_key() [5/6]
Definition at line 326 of file elliptic_impl_pub.cpp.
327 {
328 int nV = c.data[0];
329 if (nV<27 || nV>=35)
331
332 ECDSA_SIG *sig = ECDSA_SIG_new();
333 BN_bin2bn(&c.data[1],32,sig->r);
334 BN_bin2bn(&c.data[33],32,sig->s);
335
336 if( check_canonical )
337 {
338 FC_ASSERT( is_canonical( c ),
"signature is not canonical" );
339 }
340
341 my->_key = EC_KEY_new_by_curve_name(NID_secp256k1);
342
343 if (nV >= 31)
344 {
345 EC_KEY_set_conv_form( my->_key, POINT_CONVERSION_COMPRESSED );
346 nV -= 4;
347
348 }
349
351 {
352 ECDSA_SIG_free(sig);
353 return;
354 }
355 ECDSA_SIG_free(sig);
357 }
static int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned char *msg, int msglen, int recid, int check)
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
fc::sha256 digest(const T &value)
◆ public_key() [6/6]
fc::ecc::public_key::public_key |
( |
public_key && | pk | ) |
|
◆ child()
◆ fingerprint()
unsigned int fc::ecc::public_key::fingerprint |
( |
| ) |
const |
Definition at line 144 of file elliptic_common.cpp.
145 {
148 unsigned char* fp = (unsigned char*) hash._hash;
149 return (fp[0] << 24) | (fp[1] << 16) | (fp[2] << 8) | fp[3];
150 }
public_key_data serialize() const
static ripemd160 hash(const fc::sha512 &h)
static sha256 hash(const char *d, uint32_t dlen)
constexpr const char ripemd160[]
◆ from_base58()
public_key fc::ecc::public_key::from_base58 |
( |
const std::string & | b58 | ) |
|
|
static |
Definition at line 131 of file elliptic_common.cpp.
132 {
133 array<char, 37> data;
136
139 FC_ASSERT( memcmp( (
char*)&check, data.data +
sizeof(key),
sizeof(check) ) == 0 );
140 memcpy( (
char*)key.data, data.data,
sizeof(key) );
141 return from_key_data(key);
142 }
std::vector< char > from_base58(const std::string &base58_str)
memcpy((char *) pInfo->slotDescription, s, l)
◆ operator public_key_data()
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ serialize()
Definition at line 266 of file elliptic_impl_pub.cpp.
267 {
269 if( !my->_key ) return dat;
270 EC_KEY_set_conv_form( my->_key, POINT_CONVERSION_COMPRESSED );
271
272
273 char* front = &dat.data[0];
274 i2o_ECPublicKey( my->_key, (unsigned char**)&front );
275 return dat;
276
277
278
279
280
281 }
◆ serialize_ecc_point()
Definition at line 282 of file elliptic_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::ecc::public_key::to_base58 |
( |
| ) |
const |
Definition at line 238 of file elliptic_impl_pub.cpp.
239 {
242 }
std::string to_base58() const
Allows to convert current public key object into base58 number.
◆ to_base58() [2/2]
Definition at line 121 of file elliptic_common.cpp.
122 {
124 static_assert(
sizeof(
key) +
sizeof(check) == 37,
"");
125 array<char, 37> data;
126 memcpy(data.data, key.begin(), key.size());
127 memcpy(data.begin() + key.size(), (
const char*)&check,
sizeof(check));
129 }
std::string to_base58(const char *d, size_t s, const fc::yield_function_t &yield)
◆ valid()
bool fc::ecc::public_key::valid |
( |
| ) |
const |
◆ operator!=
Definition at line 64 of file elliptic.hpp.
65 {
66 return a.serialize() != b.serialize();
67 }
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
◆ operator==
Definition at line 60 of file elliptic.hpp.
61 {
62 return a.serialize() == b.serialize();
63 }
◆ private_key
The documentation for this class was generated from the following files: