//
#include "base58.h"
+#include "hash.h"
static const std::array<char, 58> digits = {
'1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
#include "bignum.h"
+#include "uint256.h"
CAutoBN_CTX::CAutoBN_CTX() {
BN_clear_free(bn);
}
+CBigNum::CBigNum(uint256 n) { bn = BN_new(); setuint256(n); }
+
void CBigNum::setuint32(uint32_t n) {
if (!BN_set_word(bn, n))
throw bignum_error("CBigNum conversion from uint32_t : BN_set_word failed");
#include "serialize.h"
-#include "uint256.h"
#include "version.h"
#include <openssl/bn.h>
#include <vector>
#include <algorithm>
+class uint160;
+class uint256;
+
/** Errors thrown by the bignum class */
class bignum_error : public std::runtime_error
{
CBigNum(uint32_t n) { bn = BN_new(); setuint32(n); }
CBigNum(uint64_t n) { bn = BN_new(); setuint64(n); }
- explicit CBigNum(uint256 n) { bn = BN_new(); setuint256(n); }
+ explicit CBigNum(uint256 n);
explicit CBigNum(const std::vector<uint8_t>& vch) { bn = BN_new(); setvch(vch); }
void setuint32(uint32_t n);
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <openssl/evp.h>
-#include <vector>
-#include <string>
-
#include "crypter.h"
+#include <openssl/evp.h>
+
bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
{
#include "util.h"
#include "addrman.h"
#include "random.h"
+#include "hash.h"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <map>
+#include "key.h"
+#include "base58.h"
+#include "streams.h"
+#include "hash.h"
#include <openssl/ecdsa.h>
#include <openssl/evp.h>
-#include "key.h"
-#include "base58.h"
-#include "streams.h"
// Generate a private key from just the secret parameter
int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key)
return fSuccessful;
}
+CKeyID CPubKey::GetID() const
+{
+ return CKeyID(Hash160(vbytes, vbytes + size()));
+}
+
+uint256 CPubKey::GetHash() const
+{
+ return Hash(vbytes, vbytes + size());
+}
+
bool CPubKey::Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) const
{
if (vchSig.empty() || !IsValid())
return true;
}
+bool CMalleableKeyView::operator <(const CMalleableKeyView &kv) const { return vchPubKeyH.GetID() < kv.vchPubKeyH.GetID(); }
+
std::string CMalleableKeyView::ToString() const
{
CDataStream ssKey(SER_NETWORK, PROTOCOL_VERSION);
{
return vchSecretL.size() == 32 && GetMalleablePubKey().IsValid();
}
+
+CScriptID::CScriptID() : uint160(0) { }
+
+CScriptID::CScriptID(const uint160 &in) : uint160(in) { }
+
+CKeyID::CKeyID() : uint160(0) { }
+
+CKeyID::CKeyID(const uint160 &in) : uint160(in) { }
#include "allocators.h"
#include "serialize.h"
#include "uint256.h"
-#include "hash.h"
#include "bignum.h"
#include <openssl/ec.h> // for EC_KEY definition
#include <openssl/obj_mac.h>
+
// secp160k1
// const unsigned int PRIVATE_KEY_SIZE = 192;
// const unsigned int PUBLIC_KEY_SIZE = 41;
class CKeyID : public uint160
{
public:
- CKeyID() : uint160(0) { }
- CKeyID(const uint160 &in) : uint160(in) { }
+ CKeyID();
+ CKeyID(const uint160 &in);
};
/** A reference to a CScript: the Hash160 of its serialization (see script.h) */
class CScriptID : public uint160
{
public:
- CScriptID() : uint160(0) { }
- CScriptID(const uint160 &in) : uint160(in) { }
+ CScriptID();
+ CScriptID(const uint160 &in);
};
/** An encapsulated OpenSSL Elliptic Curve key (public) */
}
}
- CKeyID GetID() const
- {
- return CKeyID(Hash160(vbytes, vbytes + size()));
- }
-
- uint256 GetHash() const
- {
- return Hash(vbytes, vbytes + size());
- }
+ CKeyID GetID() const;
+ uint256 GetHash() const;
/*
* Check syntactic correctness.
CMalleableKey GetMalleableKey(const CSecret &vchSecretH) const { return CMalleableKey(vchSecretL, vchSecretH); }
bool CheckKeyVariant(const CPubKey &R, const CPubKey &vchPubKeyVariant) const;
- bool operator <(const CMalleableKeyView& kv) const { return vchPubKeyH.GetID() < kv.vchPubKeyH.GetID(); }
+ bool operator <(const CMalleableKeyView& kv) const;
};
#endif
#include "crypter.h"
#include "sync.h"
+
#include <boost/signals2/signal.hpp>
#include <variant>
*this << key;
*this << EncodeOP_N((int)(keys.size())) << OP_CHECKMULTISIG;
}
+
+CScriptID CScript::GetID() const
+{
+ return CScriptID(Hash160(*this));
+}
printf("%s\n", ToString().c_str());
}
- CScriptID GetID() const
- {
- return CScriptID(Hash160(*this));
- }
+ CScriptID GetID() const;
};
bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey, unsigned int flags);