本文整理汇总了C++中hash_digest类的典型用法代码示例。如果您正苦于以下问题:C++ hash_digest类的具体用法?C++ hash_digest怎么用?C++ hash_digest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了hash_digest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: calculate_bitfield
stealth_bitfield calculate_bitfield(const data_chunk& stealth_data)
{
// Calculate stealth bitfield
const hash_digest index = generate_sha256_hash(stealth_data);
auto deserial = make_deserializer(
index.begin(), index.begin() + bitfield_size);
stealth_bitfield bitfield = deserial.read_uint_auto<stealth_bitfield>();
return bitfield;
}
示例3: 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()
);
}
示例4: 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;
}
示例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: 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;
}
示例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: unpack_hash
/**
* Copy `binary` data from protobuf's storage format (std::string)
* to libbitcoin's storage format (hash_digest).
*/
static bool unpack_hash(hash_digest& out, const std::string& in)
{
if (in.size() != hash_size)
return false;
std::copy(in.begin(), in.end(), out.begin());
return true;
}
示例11: 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;
}
示例12: point_sign
static one_byte point_sign(uint8_t byte, const hash_digest& hash)
{
static constexpr uint8_t low_bit_mask = 0x01;
const uint8_t last_byte = hash.back();
const uint8_t last_byte_odd_field = last_byte & low_bit_mask;
const uint8_t sign_byte = byte ^ last_byte_odd_field;
return to_array(sign_byte);
}
示例13: extract_ephemeral_key
bool extract_ephemeral_key(hash_digest& out_unsigned_ephemeral_key,
const script& script)
{
if (!is_stealth_script(script))
return false;
const auto& data = script.operations[1].data;
std::copy(data.begin(), data.begin() + hash_size,
out_unsigned_ephemeral_key.begin());
return true;
}
示例14: sign
bool sign(ec_signature& out, const ec_secret& secret, const hash_digest& hash)
{
secp256k1_ecdsa_signature signature;
const auto context = signing.context();
if (secp256k1_ecdsa_sign(context, &signature, hash.data(), secret.data(),
secp256k1_nonce_function_rfc6979, nullptr) != 1)
return false;
std::copy_n(std::begin(signature.data), out.size(), out.begin());
return true;
}
示例15: recover_public
bool recover_public(const secp256k1_context* context, byte_array<Size>& out,
const recoverable_signature& recoverable, const hash_digest& hash)
{
secp256k1_pubkey pubkey;
secp256k1_ecdsa_recoverable_signature sign;
const auto recovery_id = static_cast<int>(recoverable.recovery_id);
return
secp256k1_ecdsa_recoverable_signature_parse_compact(context,
&sign, recoverable.signature.data(), recovery_id) == 1 &&
secp256k1_ecdsa_recover(context, &pubkey, &sign, hash.data()) == 1 &&
serialize(context, out, pubkey);
}