• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ hash_digest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中hash_digest的典型用法代码示例。如果您正苦于以下问题:C++ hash_digest类的具体用法?C++ hash_digest怎么用?C++ hash_digest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了hash_digest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:7,代码来源:leveldb_common.cpp


示例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;
}
开发者ID:kaostao,项目名称:libbitcoin,代码行数:9,代码来源:leveldb_common.cpp


示例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()
    );
}
开发者ID:genjix,项目名称:libbitcoin,代码行数:9,代码来源:ec_keys.cpp


示例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;
}
开发者ID:grazcoin,项目名称:obelisk,代码行数:10,代码来源:interface.cpp


示例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()
    );
}
开发者ID:Airbitz,项目名称:libbitcoin,代码行数:11,代码来源:ec_keys.cpp


示例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;
		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:11,代码来源:elliptic_curve_key.cpp


示例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;
		}
开发者ID:ballisticwhisper,项目名称:decentralised,代码行数:13,代码来源:elliptic_curve_key.cpp


示例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};
}
开发者ID:genjix,项目名称:libbitcoin,代码行数:15,代码来源:ec_keys.cpp


示例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();
}
开发者ID:genjix,项目名称:libbitcoin,代码行数:16,代码来源:ec_keys.cpp


示例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;
}
开发者ID:libmetrocoin,项目名称:libmetrocoin-protocol,代码行数:11,代码来源:converter.cpp


示例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;
}
开发者ID:Airbitz,项目名称:libbitcoin,代码行数:17,代码来源:ec_keys.cpp


示例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);
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:8,代码来源:encrypted_keys.cpp


示例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;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:12,代码来源:stealth.cpp


示例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;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:12,代码来源:elliptic_curve.cpp


示例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);
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:12,代码来源:elliptic_curve.cpp


示例16: 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();
}
开发者ID:genjix,项目名称:libbitcoin,代码行数:22,代码来源:ec_keys.cpp


示例17: 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;
}
开发者ID:Groestlcoin,项目名称:libgroestlcoin,代码行数:13,代码来源:base16.cpp


示例18: verify_signature

bool verify_signature(const secp256k1_context* context,
    const secp256k1_pubkey point, const hash_digest& hash,
    const ec_signature& signature)
{
    // Copy to avoid exposing external types.
    secp256k1_ecdsa_signature parsed;
    std::copy(signature.begin(), signature.end(), std::begin(parsed.data));

    // secp256k1_ecdsa_verify rejects non-normalized (low-s) signatures, but
    // bitcoin does not have such a limitation, so we always normalize.
    secp256k1_ecdsa_signature normal;
    secp256k1_ecdsa_signature_normalize(context, &normal, &parsed);
    return secp256k1_ecdsa_verify(context, &normal, hash.data(), &point) == 1;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:14,代码来源:elliptic_curve.cpp


示例19: 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);
    }
}
开发者ID:Airbitz,项目名称:libbitcoin,代码行数:36,代码来源:ec_keys.cpp


示例20: sign_recoverable

bool sign_recoverable(recoverable_signature& out, const ec_secret& secret,
    const hash_digest& hash)
{
    int recovery_id;
    const auto context = signing.context();
    secp256k1_ecdsa_recoverable_signature signature;

    const auto result =
        secp256k1_ecdsa_sign_recoverable(context, &signature, hash.data(),
            secret.data(), secp256k1_nonce_function_rfc6979, nullptr) == 1 &&
        secp256k1_ecdsa_recoverable_signature_serialize_compact(context,
            out.signature.data(), &recovery_id, &signature) == 1;

    BITCOIN_ASSERT(recovery_id >= 0 && recovery_id <= 3);
    out.recovery_id = static_cast<uint8_t>(recovery_id);
    return result;
}
开发者ID:GeopaymeEE,项目名称:libbitcoin,代码行数:17,代码来源:elliptic_curve.cpp



注:本文中的hash_digest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ hash_map类代码示例发布时间:2022-05-31
下一篇:
C++ hash_collection类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap