MCPcopy Create free account
hub / github.com/WaykiChain/WaykiChain / SignCompact

Method SignCompact

src/entities/key.cpp:118–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118bool CKey::SignCompact(const uint256 &hash, vector<uint8_t> &vchSig) const {
119 if (!fValid) return false;
120
121 vchSig.resize(CPubKey::COMPACT_SIGNATURE_SIZE);
122 int32_t rec = -1;
123 secp256k1_ecdsa_recoverable_signature sig;
124 int32_t ret = secp256k1_ecdsa_sign_recoverable(secp256k1_context_sign, &sig, hash.begin(), begin(),
125 secp256k1_nonce_function_rfc6979, nullptr);
126 assert(ret);
127 ret = secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, &vchSig[1], &rec, &sig);
128 assert(ret);
129 assert(rec != -1);
130 vchSig[0] = 27 + rec + (fCompressed ? 4 : 0);
131
132 return true;
133}
134
135bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck = false) {
136 if (!ec_privkey_import_der(secp256k1_context_sign, (uint8_t *)begin(), privkey.data(), privkey.size()))

Callers 2

BOOST_AUTO_TEST_CASEFunction · 0.45
signmessageFunction · 0.45

Calls 4

resizeMethod · 0.45
beginMethod · 0.45

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.36