本文整理汇总了C++中init_singleton::init方法的典型用法代码示例。如果您正苦于以下问题:C++ init_singleton::init方法的具体用法?C++ init_singleton::init怎么用?C++ init_singleton::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类init_singleton
的用法示例。
在下文中一共展示了init_singleton::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()
);
}
示例2: 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()
);
}
示例3: sign_compact
compact_signature sign_compact(ec_secret secret, hash_digest hash)
{
init.init();
compact_signature out;
ec_secret nonce;
unsigned index = 0;
do {
nonce = create_nonce(secret, hash, index++);
} while (secp256k1_ecdsa_sign_compact(hash.data(), hash.size(),
out.signature.data(), secret.data(), nonce.data(), &out.recid) <= 0);
return out;
}
示例4: secret_to_public_key
ec_point secret_to_public_key(const ec_secret& secret,
bool compressed)
{
init.init();
size_t size = ec_uncompressed_size;
if (compressed)
size = ec_compressed_size;
ec_point out(size);
int out_size;
if (!secp256k1_ecdsa_pubkey_create(out.data(), &out_size, secret.data(),
compressed))
return ec_point();
BITCOIN_ASSERT(size == static_cast<size_t>(out_size));
return out;
}
示例5: 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();
}
示例6: 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;
}
示例7: 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();
}
示例8: 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);
}
}
示例9: create_nonce
ec_secret create_nonce(ec_secret secret, hash_digest hash, unsigned index)
{
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(build_data({V, to_byte(0x00), secret, hash}), K);
V = hmac_sha256_hash(V, K);
K = hmac_sha256_hash(build_data({V, to_byte(0x01), secret, hash}), K);
V = hmac_sha256_hash(V, K);
while (true)
{
V = hmac_sha256_hash(V, K);
if (0 == index)
return V;
--index;
K = hmac_sha256_hash(build_data({V, to_byte(0x00)}), K);
V = hmac_sha256_hash(V, K);
}
}
示例10: ec_multiply
bool ec_multiply(ec_secret& a, const ec_secret& b)
{
init.init();
return secp256k1_ecdsa_privkey_tweak_mul(a.data(), b.data()) == 1;
}
示例11: ec_tweak_add
bool ec_tweak_add(ec_point& a, const ec_secret& b)
{
init.init();
return secp256k1_ecdsa_pubkey_tweak_add(a.data(), a.size(), b.data()) == 1;
}
示例12: ec_add
bool ec_add(ec_secret& a, const ec_secret& b)
{
init.init();
return secp256k1_ec_privkey_tweak_add(a.data(), b.data()) == 1;
}
示例13: verify_public_key
bool verify_public_key(const ec_point& public_key)
{
init.init();
return secp256k1_ecdsa_pubkey_verify(public_key.data(), public_key.size())
== 1;
}
示例14: verify_private_key
bool verify_private_key(const ec_secret& private_key)
{
init.init();
return secp256k1_ecdsa_seckey_verify(private_key.data()) == 1;
}
示例15: ec_multiply
bool ec_multiply(ec_point& a, const ec_secret& b)
{
init.init();
return secp256k1_ec_pubkey_tweak_mul(a.data(), a.size(), b.data()) == 1;
}