Commit 2eba425d by Unsigned

Intermission

parent 4fe8f298
......@@ -134,6 +134,7 @@ void CQKey::SetCompressedPubKey()
void CQKey::Reset()
{
fCompressedPubKey = false;
entropy_init_auto(ent);
if (pkey != NULL)
EC_KEY_free(pkey);
pkey = EC_KEY_new_by_curve_name(NID_secp256k1);
......@@ -186,8 +187,7 @@ void CQKey::MakeNewKey(bool fCompressed)
// throw key_error("CQKey::MakeNewKey() : EC_KEY_generate_key failed");
// if (fCompressed)
// SetCompressedPubKey();
bliss_private_key_t key;
entropy_t *ent;
entropy_init_auto(ent);
int ret_val;
......@@ -196,19 +196,12 @@ void CQKey::MakeNewKey(bool fCompressed)
fSet = true;
}
bool CQKey::SetPrivKey(const CPrivKey& vchPrivKey)
bool CQKey::SetPrivKey(const bliss_private_key_t vchPrivKey)
{
const unsigned char* pbegin = &vchPrivKey[0];
if (d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size()))
{
// In testing, d2i_ECPrivateKey can return true
// but fill in pkey with a key that fails
// EC_KEY_check_key, so:
if (EC_KEY_check_key(pkey))
{
fSet = true;
return true;
}
if (EC_KEY_check_key(pkey))
{// TODO: do Sign pub/priv key check
fSet = true;
return true;
}
// If vchPrivKey data is bad d2i_ECPrivateKey() can
// leave pkey in a state where calling EC_KEY_free()
......@@ -296,16 +289,15 @@ CPubKey CQKey::GetPubKey() const
return CPubKey(vchPubKey);
}
bool CQKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)
bool CQKey::Sign(std:vector<unsigned char> msg, bliss_signature_t& signature)
{
unsigned int nSize = ECDSA_size(pkey);
vchSig.resize(nSize); // Make sure it is big enough
if (!ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey))
{
vchSig.clear();
// unsigned int nSize = ECDSA_size(pkey);
// vchSig.resize(nSize); // Make sure it is big enough
if (!bliss_b_sign(signature, &pkey, (uint8_t*)&msg, sizeof(msg), ent)){
// TODO: vchSig.clear();
return false;
}
vchSig.resize(nSize); // Shrink to fit actual size
//vchSig.resize(nSize); // Shrink to fit actual size
return true;
}
......
......@@ -113,6 +113,7 @@ class CQKey : CKey
protected:
//EC_KEY* pkey;
bliss_private_key_t pkey;
entropy_t *ent;
bool fSet;
bool fCompressedPubKey;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment