本文整理汇总了C++中hash_digest::size方法的典型用法代码示例。如果您正苦于以下问题:C++ hash_digest::size方法的具体用法?C++ hash_digest::size怎么用?C++ hash_digest::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hash_digest
的用法示例。
在下文中一共展示了hash_digest::size方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slice_block_hash
leveldb::Slice slice_block_hash(const hash_digest& block_hash)
{
// Cut first 16 bytes of block hash
BITCOIN_ASSERT(block_hash.size() == 32);
return leveldb::Slice(
reinterpret_cast<const char*>(block_hash.data() + 16), 16);
}
示例2: verify_signature
bool verify_signature(const ec_point& public_key, hash_digest hash,
const endorsement& signature)
{
init.init();
return 1 == secp256k1_ecdsa_verify(hash.data(), hash.size(),
signature.data(), signature.size(), public_key.data(),
public_key.size()
);
}
示例3: read_hash
bool read_hash(hash_digest& hash, const data_chunk& raw_hash)
{
if (raw_hash.size() != hash.size())
{
log_warning(LOG_SUBSCRIBER) << "Wrong size for hash. Dropping.";
return false;
}
std::copy(raw_hash.begin(), raw_hash.end(), hash.begin());
return true;
}
示例4: verify
bool elliptic_curve_key::verify(hash_digest hash, const data_chunk& signature)
{
BITCOIN_ASSERT(key_ != nullptr);
// SSL likes a reversed hash
std::reverse(hash.begin(), hash.end());
// -1 = error, 0 = bad sig, 1 = good
if (ECDSA_verify(0, hash.data(), hash.size(),
signature.data(), signature.size(), key_) == 1)
return true;
return false;
}
示例5: verify_signature
bool verify_signature(const ec_point& public_key, hash_digest hash,
const data_chunk& signature)
{
std::reverse(hash.begin(), hash.end());
init.init();
return 1 == secp256k1_ecdsa_verify(
hash.data(), hash.size(),
signature.data(), signature.size(),
public_key.data(), public_key.size()
);
}
示例6: get_block_hash
int get_block_hash(Db*, const Dbt*, const Dbt* data, Dbt* second_key)
{
std::stringstream ss(std::string(
reinterpret_cast<const char*>(data->get_data()), data->get_size()));
protobuf::Block proto_block;
proto_block.ParseFromIstream(&ss);
message::block serial_block = protobuf_to_block_header(proto_block);
second_hash = hash_block_header(serial_block);
second_key->set_data(second_hash.data());
second_key->set_size(second_hash.size());
return 0;
}
示例7: sign
data_chunk elliptic_curve_key::sign(hash_digest hash) const
{
BITCOIN_ASSERT(key_ != nullptr);
// SSL likes a reversed hash
std::reverse(hash.begin(), hash.end());
data_chunk signature(ECDSA_size(key_));
unsigned int signature_length = signature.size();
if (!ECDSA_sign(0, hash.data(), hash.size(),
signature.data(), &signature_length, key_))
return data_chunk();
signature.resize(signature_length);
return signature;
}
示例8: sign_compact
compact_signature sign_compact(ec_secret secret, hash_digest hash,
ec_secret nonce)
{
init.init();
compact_signature out;
if (0 < secp256k1_ecdsa_sign_compact(hash.data(), hash.size(),
out.signature.data(), secret.data(), nonce.data(), &out.recid))
{
return out;
}
// Error case:
return compact_signature{{{0}}, 0};
}
示例9: sign
endorsement sign(ec_secret secret, hash_digest hash, ec_secret nonce)
{
init.init();
int out_size = max_endorsement_size;
endorsement signature(out_size);
if (0 < secp256k1_ecdsa_sign(hash.data(), hash.size(), signature.data(),
&out_size, secret.data(), nonce.data()))
{
signature.resize(out_size);
return signature;
}
// Error case:
return endorsement();
}
示例10: sign
data_chunk sign(ec_secret secret, hash_digest hash, ec_secret nonce)
{
std::reverse(hash.begin(), hash.end());
init.init();
int out_size = 72;
data_chunk signature(out_size);
if (!verify_private_key(nonce)) // Needed because of upstream bug
return data_chunk();
bool valid = secp256k1_ecdsa_sign(hash.data(), hash.size(),
signature.data(), &out_size, secret.data(), nonce.data()) == 1;
if (!valid)
return data_chunk();
signature.resize(out_size);
return signature;
}
示例11: recover_compact
ec_point recover_compact(compact_signature signature,
hash_digest hash, bool compressed)
{
init.init();
size_t public_key_size = ec_uncompressed_size;
if (compressed)
public_key_size = ec_compressed_size;
ec_point out(public_key_size);
int out_size;
if (0 < secp256k1_ecdsa_recover_compact(hash.data(), hash.size(),
signature.signature.data(), out.data(), &out_size, compressed,
signature.recid))
{
BITCOIN_ASSERT(public_key_size == static_cast<size_t>(out_size));
return out;
}
// Error case:
return ec_point();
}