本文整理汇总了C++中hash_digest::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ hash_digest::begin方法的具体用法?C++ hash_digest::begin怎么用?C++ hash_digest::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hash_digest
的用法示例。
在下文中一共展示了hash_digest::begin方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例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: 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;
}
示例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: decode_hash
bool decode_hash(hash_digest& out, const std::string& in)
{
if (in.size() != 2 * hash_size)
return false;
hash_digest result;
if (!decode_base16_private(result.data(), result.size(), in.data()))
return false;
// Reverse:
std::reverse_copy(result.begin(), result.end(), out.begin());
return true;
}
示例9: 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;
}
示例10: create_nonce
BC_API ec_secret create_nonce(ec_secret secret, hash_digest hash)
{
std::reverse(hash.begin(), hash.end());
init.init();
hash_digest K
{{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}};
hash_digest V
{{
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
}};
K = hmac_sha256_hash(V + byte_array<1>{{0x00}} + secret + hash, K);
V = hmac_sha256_hash(V, K);
K = hmac_sha256_hash(V + byte_array<1>{{0x01}} + secret + hash, K);
V = hmac_sha256_hash(V, K);
while (true)
{
V = hmac_sha256_hash(V, K);
if (verify_private_key(V))
return V;
K = hmac_sha256_hash(V + byte_array<1>{{0x00}}, K);
V = hmac_sha256_hash(V, K);
}
}
示例11: string
static std::string pack_hash(hash_digest in)
{
return std::string(in.begin(), in.end());
}
示例12: set_hash
void hash_number::set_hash(const hash_digest& hash)
{
std::copy(hash.begin(), hash.end(), hash_.begin());
}
示例13: append_hash
void append_hash(czmqpp::message& message, const hash_digest& hash)
{
message.append(data_chunk(hash.begin(), hash.end()));
}
示例14: encode_hash
// Bitcoin hash format (these are all reversed):
std::string encode_hash(hash_digest hash)
{
std::reverse(hash.begin(), hash.end());
return encode_base16(hash);
}