本文整理汇总了C++中fc::ecc::private_key类的典型用法代码示例。如果您正苦于以下问题:C++ private_key类的具体用法?C++ private_key怎么用?C++ private_key使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了private_key类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void start(const fc::ip::endpoint& endpoint_to_probe,
const fc::ecc::private_key& my_node_id,
const bts::blockchain::digest_type& chain_id)
{
fc::future<void> connect_task = fc::async([=](){ _connection->connect_to(endpoint_to_probe); }, "connect_task");
try
{
connect_task.wait(fc::seconds(10));
}
catch (const fc::timeout_exception&)
{
ilog("timeout connecting to node ${endpoint}", ("endpoint", endpoint_to_probe));
connect_task.cancel();
throw;
}
fc::sha256::encoder shared_secret_encoder;
fc::sha512 shared_secret = _connection->get_shared_secret();
shared_secret_encoder.write(shared_secret.data(), sizeof(shared_secret));
fc::ecc::compact_signature signature = my_node_id.sign_compact(shared_secret_encoder.result());
bts::net::hello_message hello("map_bts_network",
BTS_NET_PROTOCOL_VERSION,
fc::ip::address(), 0, 0,
my_node_id.get_public_key(),
signature,
chain_id,
fc::variant_object());
_connection->send_message(hello);
}
示例2: TransferMemo
PublicKeyType withdraw_with_escrow::encrypt_memo_data(
const fc::ecc::private_key& one_time_private_key,
const fc::ecc::public_key& to_public_key,
const fc::ecc::private_key& from_private_key,
const std::string& memo_message,
const fc::ecc::public_key& memo_pub_key,
MemoFlagsEnum memo_type)
{
memo = TransferMemo();
const auto secret = one_time_private_key.get_shared_secret(to_public_key);
const auto ext_to_public_key = ExtendedPublicKey(to_public_key);
const auto secret_ext_public_key = ext_to_public_key.child(fc::sha256::hash(secret));
const auto secret_public_key = secret_ext_public_key.get_pub_key();
sender = Address(one_time_private_key.get_public_key());
receiver = Address(secret_public_key);
fc::sha512 check_secret;
if (from_private_key.get_secret() != fc::ecc::private_key().get_secret())
check_secret = from_private_key.get_shared_secret(secret_public_key);
MemoData memo_content;
memo_content.set_message(memo_message);
memo_content.from = memo_pub_key;
memo_content.from_signature = check_secret._hash[0];
memo_content.memo_flags = memo_type;
memo->one_time_key = one_time_private_key.get_public_key();
encrypt_memo_data(secret, memo_content);
return secret_public_key;
}
示例3: start
void start(const fc::ip::endpoint& endpoint_to_probe,
const fc::ecc::private_key& my_node_id,
const graphene::chain::chain_id_type& chain_id)
{
_remote = endpoint_to_probe;
fc::future<void> connect_task = fc::async([this](){ _connection->connect_to(_remote); }, "connect_task");
try
{
connect_task.wait(fc::seconds(10));
}
catch (const fc::timeout_exception&)
{
ilog("timeout connecting to node ${endpoint}", ("endpoint", endpoint_to_probe));
connect_task.cancel(__FUNCTION__);
throw;
}
fc::sha256::encoder shared_secret_encoder;
fc::sha512 shared_secret = _connection->get_shared_secret();
shared_secret_encoder.write(shared_secret.data(), sizeof(shared_secret));
fc::ecc::compact_signature signature = my_node_id.sign_compact(shared_secret_encoder.result());
graphene::net::hello_message hello("network_mapper",
GRAPHENE_NET_PROTOCOL_VERSION,
fc::ip::address(), 0, 0,
my_node_id.get_public_key(),
signature,
chain_id,
fc::variant_object());
_connection->send_message(hello);
}
示例4: titan_transfer
void domain_transfer_operation::titan_transfer( const fc::ecc::private_key& one_time_private_key,
const fc::ecc::public_key& to_public_key,
const fc::ecc::private_key& from_private_key,
const std::string& memo_message,
const fc::ecc::public_key& memo_pub_key,
memo_flags_enum memo_type )
{
memo = titan_memo();
auto secret = one_time_private_key.get_shared_secret( to_public_key );
auto ext_to_public_key = extended_public_key(to_public_key);
auto secret_ext_public_key = ext_to_public_key.child( fc::sha256::hash(secret) );
auto secret_public_key = secret_ext_public_key.get_pub_key();
owner = address( secret_public_key );
auto check_secret = from_private_key.get_shared_secret( secret_public_key );
memo_data memo_content;
memo_content.set_message( memo_message );
memo_content.from = memo_pub_key;
memo_content.from_signature = check_secret._hash[0];
memo_content.memo_flags = memo_type;
memo->one_time_key = one_time_private_key.get_public_key();
FC_ASSERT( memo.valid() );
memo->encrypted_memo_data = fc::aes_encrypt( secret, fc::raw::pack( memo_content ) );
}
示例5: titan_memo
public_key_type withdraw_with_signature::encrypt_memo_data(
const fc::ecc::private_key& one_time_private_key,
const fc::ecc::public_key& to_public_key,
const fc::ecc::private_key& from_private_key,
const std::string& memo_message,
const fc::ecc::public_key& memo_pub_key,
memo_flags_enum memo_type )
{
memo = titan_memo();
const auto secret = one_time_private_key.get_shared_secret( to_public_key );
const auto ext_to_public_key = extended_public_key( to_public_key );
const auto secret_ext_public_key = ext_to_public_key.child( fc::sha256::hash( secret ) );
const auto secret_public_key = secret_ext_public_key.get_pub_key();
owner = address( secret_public_key );
fc::sha512 check_secret;
if( from_private_key.get_secret() != fc::ecc::private_key().get_secret() )
check_secret = from_private_key.get_shared_secret( secret_public_key );
memo_data memo_content;
memo_content.set_message( memo_message );
memo_content.from = memo_pub_key;
memo_content.from_signature = check_secret._hash[0];
memo_content.memo_flags = memo_type;
memo->one_time_key = one_time_private_key.get_public_key();
encrypt_memo_data( secret, memo_content );
return secret_public_key;
}
示例6: encrypt
encrypted_message message::encrypt( const fc::ecc::private_key& onetimekey,
const fc::ecc::public_key& receiver_public_key )const
{
auto shared_secret = onetimekey.get_shared_secret( receiver_public_key );
encrypted_message result;
result.onetimekey = onetimekey.get_public_key();
result.data = fc::aes_encrypt( shared_secret, fc::raw::pack( *this ) );
return result;
}
示例7: FC_ASSERT
omemo_status withdraw_with_signature::decrypt_memo_data( const fc::ecc::private_key& receiver_key, bool ignore_owner )const
{ try {
try {
FC_ASSERT( memo.valid() );
auto secret = receiver_key.get_shared_secret( memo->one_time_key );
extended_private_key ext_receiver_key(receiver_key);
fc::ecc::private_key secret_private_key = ext_receiver_key.child( fc::sha256::hash(secret),
extended_private_key::public_derivation );
auto secret_public_key = secret_private_key.get_public_key();
if( !ignore_owner && owner != address( secret_public_key ) )
return omemo_status();
auto memo = decrypt_memo_data( secret );
bool has_valid_signature = false;
if( memo.memo_flags == from_memo && !( memo.from == public_key_type() && memo.from_signature == 0 ) )
{
auto check_secret = secret_private_key.get_shared_secret( memo.from );
has_valid_signature = check_secret._hash[0] == memo.from_signature;
}
else
{
has_valid_signature = true;
}
return memo_status( memo, has_valid_signature, secret_private_key );
}
catch ( const fc::aes_exception& e )
{
return omemo_status();
}
} FC_CAPTURE_AND_RETHROW( (ignore_owner) ) }
示例8: sign
void signed_block_header::sign( const fc::ecc::private_key& signer, digest_type chain_id )
{ try {
fc::sha256::encoder enc;
fc::raw::pack( enc, *this );
fc::raw::pack( enc, chain_id );
delegate_signature = signer.sign_compact( digest() );
} FC_RETHROW_EXCEPTIONS( warn, "" ) }
示例9: digest
void signed_transaction::sign( const fc::ecc::private_key& k )
{
try {
sigs.insert( k.sign_compact( digest() ) );
}
FC_RETHROW_EXCEPTIONS( warn, "error signing transaction", ("trx", *this ) );
}
示例10: FC_ASSERT
omemo_status domain_transfer_operation::decrypt_memo_data( const fc::ecc::private_key& receiver_key ) const
{ try {
FC_ASSERT( memo.valid() );
// ilog( "receiver_key: ${r}", ("r",receiver_key) );
auto secret = receiver_key.get_shared_secret( memo->one_time_key );
// ilog( "secret: ${secret}", ("secret",secret) );
extended_private_key ext_receiver_key(receiver_key);
// ilog( "ext_receiver_key: ${key}",("key",ext_receiver_key) );
fc::ecc::private_key secret_private_key = ext_receiver_key.child( fc::sha256::hash(secret),
extended_private_key::public_derivation );
// ilog( "secret_private_key: ${k}", ("k",secret_private_key) );
auto secret_public_key = secret_private_key.get_public_key();
// ilog( "secret_public_key: ${k}", ("k",secret_public_key) );
if( owner != address(secret_public_key) )
return omemo_status();
// ilog( "owner: ${o} == ${address}", ("o",owner)("address",address(secret_public_key)) );
auto memo = decrypt_memo_data( secret );
bool has_valid_signature = false;
if( memo.memo_flags == from_memo )
{
auto check_secret = secret_private_key.get_shared_secret( memo.from );
has_valid_signature = check_secret._hash[0] == memo.from_signature;
}
else
{
has_valid_signature = true;
}
return memo_status( memo, has_valid_signature, secret_private_key );
} FC_RETHROW_EXCEPTIONS( warn, "" ) }
示例11: create
void pow::create( const fc::ecc::private_key& w, const digest_type& i ) {
input = i;
signature = w.sign_compact(input,false);
auto sig_hash = fc::sha256::hash( signature );
public_key_type recover = fc::ecc::public_key( signature, sig_hash, false );
work = fc::sha256::hash(recover);
}
示例12: cache_memo
void wallet_db::cache_memo( const memo_status& memo,
const fc::ecc::private_key& account_key,
const fc::sha512& password )
{
key_data data;
data.account_address = address(account_key.get_public_key());
//data.memo = memo_data(memo);
data.valid_from_signature = memo.has_valid_signature;
data.encrypt_private_key( password, memo.owner_private_key );
store_key( data );
}
示例13: key_to_wif
std::string key_to_wif(const fc::ecc::private_key& key)
{
fc::sha256 secret = key.get_secret();
const size_t size_of_data_to_hash = sizeof(secret) + 1;
const size_t size_of_hash_bytes = 4;
char data[size_of_data_to_hash + size_of_hash_bytes];
data[0] = (char)0x80;
memcpy(&data[1], (char*)&secret, sizeof(secret));
fc::sha256 digest = fc::sha256::hash(data, size_of_data_to_hash);
digest = fc::sha256::hash(digest);
memcpy(data + size_of_data_to_hash, (char*)&digest, size_of_hash_bytes);
return fc::to_base58(data, sizeof(data));
}
示例14: launch_bts_server_process
bts_server_process_info_ptr launch_bts_server_process(const genesis_block_config& genesis_block,
const fc::ecc::private_key& trustee_key)
{
bts_server_process_info_ptr server_process_info = std::make_shared<bts_server_process_info>();
server_process_info->server_process = std::make_shared<fc::process>();
std::vector<std::string> options;
options.push_back("--trustee-address");
options.push_back(bts::blockchain::address(trustee_key.get_public_key()));
fc::path server_config_dir = bts_xt_client_test_config::config_directory / "BitSharesX_Server";
fc::remove_all(server_config_dir);
fc::create_directories(server_config_dir);
fc::json::save_to_file(genesis_block, server_config_dir / "genesis.json", true);
server_process_info->server_process->exec(bts_xt_client_test_config::bts_server_exe, options, server_config_dir);
std::shared_ptr<std::ofstream> stdouterrfile = std::make_shared<std::ofstream>((server_config_dir / "stdouterr.txt").string().c_str());
fc::buffered_istream_ptr out_stream = server_process_info->server_process->out_stream();
fc::buffered_istream_ptr err_stream = server_process_info->server_process->err_stream();
server_process_info->stdout_reader_done = fc::async([out_stream,stdouterrfile]()
{
char buf[1024];
for (;;)
{
size_t bytes_read = out_stream->readsome(buf, sizeof(buf));
if (!bytes_read)
break;
stdouterrfile->write(buf, bytes_read);
}
});
server_process_info->stderr_reader_done = fc::async([err_stream,stdouterrfile]()
{
char buf[1024];
for (;;)
{
size_t bytes_read = err_stream->readsome(buf, sizeof(buf));
if (!bytes_read)
break;
stdouterrfile->write(buf, bytes_read);
}
});
return server_process_info;
}
示例15: digest
void subscribe_message::sign( const fc::ecc::private_key& k )
{
sig = k.sign_compact( digest() );
}