FormatMoney cleanup
[novacoin.git] / src / key.cpp
index dafffcf..c11da92 100644 (file)
@@ -6,12 +6,9 @@
 
 #include <openssl/ecdsa.h>
 #include <openssl/obj_mac.h>
-#include <openssl/ssl.h>
-#include <openssl/ecdh.h>
 
 #include "key.h"
 #include "base58.h"
-#include "ies.h"
 
 // Generate a private key from just the secret parameter
 int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key)
@@ -714,6 +711,15 @@ std::string CMalleablePubKey::ToString() const
     return EncodeBase58Check(vch);
 }
 
+std::vector<unsigned char> CMalleablePubKey::Raw() const
+{
+    CDataStream ssKey(SER_NETWORK, PROTOCOL_VERSION);
+    ssKey << *this;
+    std::vector<unsigned char> vch(ssKey.begin(), ssKey.end());
+
+    return vch;
+}
+
 bool CMalleablePubKey::SetString(const std::string& strMalleablePubKey)
 {
     std::vector<unsigned char> vchTemp;
@@ -774,13 +780,6 @@ CMalleableKey::CMalleableKey(const CSecret &L, const CSecret &H)
     SetSecrets(L, H);
 }
 
-CMalleableKey& CMalleableKey::operator=(const CMalleableKey &b)
-{
-    SetSecrets(b.vchSecretL, b.vchSecretH);
-
-    return (*this);
-}
-
 CMalleableKey::~CMalleableKey()
 {
 }
@@ -795,7 +794,7 @@ bool CMalleableKey::SetSecrets(const CSecret &pvchSecretL, const CSecret &pvchSe
     Reset();
     CKey L, H;
 
-    if (pvchSecretL.size() != 32 || !pvchSecretH.size() != 32 || !L.SetSecret(pvchSecretL, true) || !H.SetSecret(pvchSecretH, true))
+    if (pvchSecretL.size() != 32 || pvchSecretH.size() != 32 || !L.SetSecret(pvchSecretL, true) || !H.SetSecret(pvchSecretH, true))
     {
         nVersion = 0;
         return false;
@@ -808,12 +807,6 @@ bool CMalleableKey::SetSecrets(const CSecret &pvchSecretL, const CSecret &pvchSe
     return true;
 }
 
-void CMalleableKey::GetSecrets(CSecret &pvchSecretL, CSecret &pvchSecretH) const
-{
-    pvchSecretL = vchSecretL;
-    pvchSecretH = vchSecretH;
-}
-
 CMalleablePubKey CMalleableKey::GetMalleablePubKey() const
 {
     CKey L, H;
@@ -985,6 +978,15 @@ std::string CMalleableKey::ToString() const
     return EncodeBase58Check(vch);
 }
 
+std::vector<unsigned char> CMalleableKey::Raw() const
+{
+    CDataStream ssKey(SER_NETWORK, PROTOCOL_VERSION);
+    ssKey << *this;
+    std::vector<unsigned char> vch(ssKey.begin(), ssKey.end());
+
+    return vch;
+}
+
 bool CMalleableKey::SetString(const std::string& strMutableKey)
 {
     std::vector<unsigned char> vchTemp;
@@ -995,7 +997,7 @@ bool CMalleableKey::SetString(const std::string& strMutableKey)
     CDataStream ssKey(vchTemp, SER_NETWORK, PROTOCOL_VERSION);
     ssKey >> *this;
 
-    return IsNull();
+    return IsValid();
 }
 
 // CMalleableKeyView
@@ -1024,13 +1026,6 @@ CMalleableKeyView::CMalleableKeyView(const CMalleableKeyView &b)
     nVersion = CURRENT_VERSION;
 }
 
-CMalleableKeyView::CMalleableKeyView(const CSecret &L, const CPubKey &pvchPubKeyH)
-{
-    vchSecretL = L;
-    vchPubKeyH = pvchPubKeyH.Raw();
-    nVersion = CURRENT_VERSION;
-}
-
 CMalleableKeyView& CMalleableKeyView::operator=(const CMalleableKey &b)
 {
     vchSecretL = b.vchSecretL;
@@ -1135,9 +1130,19 @@ bool CMalleableKeyView::SetString(const std::string& strMutableKey)
     CDataStream ssKey(vchTemp, SER_NETWORK, PROTOCOL_VERSION);
     ssKey >> *this;
 
-    return IsNull();
+    return IsValid();
 }
 
+std::vector<unsigned char> CMalleableKeyView::Raw() const
+{
+    CDataStream ssKey(SER_NETWORK, PROTOCOL_VERSION);
+    ssKey << *this;
+    std::vector<unsigned char> vch(ssKey.begin(), ssKey.end());
+
+    return vch;
+}
+
+
 bool CMalleableKeyView::IsNull() const
 {
     return nVersion != CURRENT_VERSION;