You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ecwrapper.h 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright (c) 2009-2014 The Bitcoin developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #ifndef BITCOIN_ECWRAPPER_H
  5. #define BITCOIN_ECWRAPPER_H
  6. #include <cstddef>
  7. #include <vector>
  8. #include <openssl/ec.h>
  9. class uint256;
  10. // RAII Wrapper around OpenSSL's EC_KEY
  11. class CECKey {
  12. private:
  13. EC_KEY *pkey;
  14. public:
  15. CECKey();
  16. ~CECKey();
  17. void GetPubKey(std::vector<unsigned char>& pubkey, bool fCompressed);
  18. bool SetPubKey(const unsigned char* pubkey, size_t size);
  19. bool Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig);
  20. // reconstruct public key from a compact signature
  21. // This is only slightly more CPU intensive than just verifying it.
  22. // If this function succeeds, the recovered public key is guaranteed to be valid
  23. // (the signature is a valid signature of the given data for that key)
  24. bool Recover(const uint256 &hash, const unsigned char *p64, int rec);
  25. bool TweakPublic(const unsigned char vchTweak[32]);
  26. static bool SanityCheck();
  27. };
  28. #endif // BITCOIN_ECWRAPPER_H