本文整理汇总了C++中ec_point::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ec_point::empty方法的具体用法?C++ ec_point::empty怎么用?C++ ec_point::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ec_point
的用法示例。
在下文中一共展示了ec_point::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
if (argc != 4)
{
std::cerr << "Usage: pp_unlock CHUNKFILE BLOCK_HASH PUBKEY"
<< std::endl;
return -1;
}
const std::string chunk_filename = argv[1];
const data_chunk hash = decode_hex(argv[2]);
if (hash.empty() || hash.size() != hash_size)
{
std::cerr << "pp_unlock: not a valid BLOCK_HASH." << std::endl;
return -1;
}
const ec_point pubkey = decode_hex(argv[3]);
if (pubkey.empty() || pubkey.size() != ec_compressed_size)
{
std::cerr << "pp_unlock: not a valid PUBKEY." << std::endl;
return -1;
}
std::ifstream infile(chunk_filename, std::ifstream::binary);
infile.seekg(0, std::ifstream::end);
size_t file_size = infile.tellg();
BITCOIN_ASSERT(file_size % 16 == 0);
infile.seekg(0, std::ifstream::beg);
// Read entire file in.
data_chunk cipher(file_size);
// Copy chunk to public chunk file.
char* data = reinterpret_cast<char*>(cipher.data());
infile.read(data, file_size);
infile.close();
// Get seed.
payment_address bid_addr = bidding_address(pubkey);
hash_digest seed = derive_seed(pubkey);
// Decrypt chunk.
aes256_context ctx;
BITCOIN_ASSERT(seed.size() == 32);
aes256_init(&ctx, seed.data());
BITCOIN_ASSERT(cipher.size() % 16 == 0);
for (size_t i = 0; i < cipher.size(); i += 16)
aes256_decrypt_ecb(&ctx, cipher.data() + i);
aes256_done(&ctx);
// Write out.
const fs::path new_chunk_filename = (chunk_filename + ".decrypted");
std::ofstream outfile(new_chunk_filename.native(), std::ifstream::binary);
char* dec_data = reinterpret_cast<char*>(cipher.data());
outfile.write(dec_data, cipher.size());
return 0;
}