]> Git Repo - VerusCoin.git/blob - src/ecwrapper.h
Merge pull request #5100
[VerusCoin.git] / src / ecwrapper.h
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.
4
5 #ifndef BITCOIN_EC_WRAPPER_H
6 #define BITCOIN_EC_WRAPPER_H
7
8 #include <cstddef>
9 #include <vector>
10
11 #include <openssl/ec.h>
12
13 class uint256;
14
15 // RAII Wrapper around OpenSSL's EC_KEY
16 class CECKey {
17 private:
18     EC_KEY *pkey;
19
20 public:
21     CECKey();
22     ~CECKey();
23
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);
34
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);
40
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();
44 };
45
46 #endif
This page took 0.024569 seconds and 4 git commands to generate.