1 // Copyright (c) 2009-2014 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #ifndef BITCOIN_EC_WRAPPER_H
6 #define BITCOIN_EC_WRAPPER_H
11 #include <openssl/ec.h>
15 // RAII Wrapper around OpenSSL's EC_KEY
24 void GetSecretBytes(unsigned char vch[32]) const;
25 void SetSecretBytes(const unsigned char vch[32]);
26 int GetPrivKeySize(bool fCompressed);
27 int GetPrivKey(unsigned char* privkey, bool fCompressed);
28 bool SetPrivKey(const unsigned char* privkey, size_t size, bool fSkipCheck=false);
29 void GetPubKey(std::vector<unsigned char>& pubkey, bool fCompressed);
30 bool SetPubKey(const unsigned char* pubkey, size_t size);
31 bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig, bool lowS);
32 bool Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig);
33 bool SignCompact(const uint256 &hash, unsigned char *p64, int &rec);
35 // reconstruct public key from a compact signature
36 // This is only slightly more CPU intensive than just verifying it.
37 // If this function succeeds, the recovered public key is guaranteed to be valid
38 // (the signature is a valid signature of the given data for that key)
39 bool Recover(const uint256 &hash, const unsigned char *p64, int rec);
41 static bool TweakSecret(unsigned char vchSecretOut[32], const unsigned char vchSecretIn[32], const unsigned char vchTweak[32]);
42 bool TweakPublic(const unsigned char vchTweak[32]);
43 static bool SanityCheck();