| 313 | } |
| 314 | |
| 315 | bool CKey::SignCompact(const uint256 &hash, |
| 316 | std::vector<uint8_t> &vchSig) const { |
| 317 | if (!fValid) { |
| 318 | return false; |
| 319 | } |
| 320 | vchSig.resize(CPubKey::COMPACT_SIGNATURE_SIZE); |
| 321 | int rec = -1; |
| 322 | secp256k1_ecdsa_recoverable_signature sig; |
| 323 | int ret = secp256k1_ecdsa_sign_recoverable( |
| 324 | secp256k1_context_sign, &sig, hash.begin(), begin(), |
| 325 | secp256k1_nonce_function_rfc6979, nullptr); |
| 326 | assert(ret); |
| 327 | ret = secp256k1_ecdsa_recoverable_signature_serialize_compact( |
| 328 | secp256k1_context_sign, &vchSig[1], &rec, &sig); |
| 329 | assert(ret); |
| 330 | assert(rec != -1); |
| 331 | vchSig[0] = 27 + rec + (fCompressed ? 4 : 0); |
| 332 | return true; |
| 333 | } |
| 334 | |
| 335 | bool CKey::Load(const CPrivKey &seckey, const CPubKey &vchPubKey, |
| 336 | bool fSkipCheck = false) { |