| 196 | } |
| 197 | |
| 198 | bool CKey::SignCompact(const uint256 &hash, std::vector<unsigned char>& vchSig) const { |
| 199 | if (!fValid) |
| 200 | return false; |
| 201 | vchSig.resize(65); |
| 202 | int rec = -1; |
| 203 | secp256k1_ecdsa_recoverable_signature sig; |
| 204 | int ret = secp256k1_ecdsa_sign_recoverable(secp256k1_context_sign, &sig, hash.begin(), begin(), secp256k1_nonce_function_rfc6979, NULL); |
| 205 | assert(ret); |
| 206 | secp256k1_ecdsa_recoverable_signature_serialize_compact(secp256k1_context_sign, (unsigned char*)&vchSig[1], &rec, &sig); |
| 207 | assert(ret); |
| 208 | assert(rec != -1); |
| 209 | vchSig[0] = 27 + rec + (fCompressed ? 4 : 0); |
| 210 | return true; |
| 211 | } |
| 212 | |
| 213 | bool CKey::Load(CPrivKey &privkey, CPubKey &vchPubKey, bool fSkipCheck=false) { |
| 214 | if (!ec_privkey_import_der(secp256k1_context_sign, (unsigned char*)begin(), &privkey[0], privkey.size())) |