From 7dff0a344bbf00d83c7b104eb09df797d3b4ca46 Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Tue, 23 Feb 2021 08:00:38 -0500 Subject: [PATCH 01/18] update bignum --- src/bignum.h | 137 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 94 insertions(+), 43 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index 5e89f0e2c9..9cc552ca9b 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -17,6 +17,8 @@ #include +#include "util.h" // for uint64 + /** Errors thrown by the bignum class */ class bignum_error : public std::runtime_error { @@ -54,38 +56,64 @@ class CAutoBN_CTX /** C++ wrapper for BIGNUM (OpenSSL bignum) */ -class CBigNum : public BIGNUM +class CBigNum { +protected: + BIGNUM *bn; + + void init() + { + bn = BN_new(); + } + public: CBigNum() { - BN_init(this); + init(); } CBigNum(const CBigNum& b) { - BN_init(this); - if (!BN_copy(this, &b)) + init(); + if (!BN_copy(bn, &b)) { - BN_clear_free(this); + BN_clear_free(bn); throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed"); } } CBigNum& operator=(const CBigNum& b) { - if (!BN_copy(this, &b)) + if (!BN_copy(bn, &b)) throw bignum_error("CBigNum::operator= : BN_copy failed"); - return (*this); + return (*bn); } ~CBigNum() { - BN_clear_free(this); + BN_clear_free(bn); } + BIGNUM *operator &() const + { + return bn; + } + + CBigNum(signed char n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(short n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int n) { init(); if (n >= 0) setulong(n); else setint64(n); } +// CBigNum(long n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int64_t n) { init(); setint64(n); } + CBigNum(unsigned char n) { init(); setulong(n); } + CBigNum(unsigned short n) { init(); setulong(n); } + CBigNum(unsigned int n) { init(); setulong(n); } +// CBigNum(unsigned long n) { init(); setulong(n); } + CBigNum(uint64_t n) { init(); setuint64(n); } + CBigNum(long long int n) { init(); setuint64(n); } + explicit CBigNum(uint256 n) { init(); setuint256(n); } + //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'. - CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } + /*CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } @@ -95,34 +123,34 @@ class CBigNum : public BIGNUM CBigNum(unsigned int n) { BN_init(this); setulong(n); } CBigNum(unsigned long n) { BN_init(this); setulong(n); } CBigNum(unsigned long long n) { BN_init(this); setuint64(n); } - explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); } + explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }*/ explicit CBigNum(const std::vector& vch) { - BN_init(this); + init(); setvch(vch); } void setulong(unsigned long n) { - if (!BN_set_word(this, n)) + if (!BN_set_word(bn, n)) throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed"); } unsigned long getulong() const { - return BN_get_word(this); + return BN_get_word(bn); } unsigned int getuint() const { - return BN_get_word(this); + return BN_get_word(bn); } int getint() const { - unsigned long n = BN_get_word(this); - if (!BN_is_negative(this)) + unsigned long n = BN_get_word(bn); + if (!BN_is_negative(bn)) return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::max() : n); else return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); @@ -170,7 +198,22 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, bn); + } + + uint64 getuint64() + { + unsigned int nSize = BN_bn2mpi(bn, NULL); + if (nSize < 4) + return 0; + std::vector vch(nSize); + BN_bn2mpi(bn, &vch[0]); + if (vch.size() > 4) + vch[4] &= 0x7f; + uint64 n = 0; + for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--) + ((unsigned char*)&n)[i] = vch[j]; + return n; } void setuint64(uint64_t n) @@ -197,7 +240,7 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, bn); } void setuint256(uint256 n) @@ -225,16 +268,16 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize >> 0) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, bn); } uint256 getuint256() const { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(bn, NULL); if (nSize < 4) return 0; std::vector vch(nSize); - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(bn, &vch[0]); if (vch.size() > 4) vch[4] &= 0x7f; uint256 n = 0; @@ -255,16 +298,16 @@ class CBigNum : public BIGNUM vch2[3] = (nSize >> 0) & 0xff; // swap data to big endian reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); - BN_mpi2bn(&vch2[0], vch2.size(), this); + BN_mpi2bn(&vch2[0], vch2.size(), bn); } std::vector getvch() const { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(bn, NULL); if (nSize <= 4) return std::vector(); std::vector vch(nSize); - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(bn, &vch[0]); vch.erase(vch.begin(), vch.begin() + 4); reverse(vch.begin(), vch.end()); return vch; @@ -300,28 +343,28 @@ class CBigNum : public BIGNUM if (nSize <= 3) { nWord >>= 8*(3-nSize); - BN_set_word(this, nWord); + BN_set_word(bn, nWord); } else { - BN_set_word(this, nWord); - BN_lshift(this, this, 8*(nSize-3)); + BN_set_word(bn, nWord); + BN_lshift(bn, bn, 8*(nSize-3)); } - BN_set_negative(this, fNegative); + BN_set_negative(bn, fNegative); return *this; } unsigned int GetCompact() const { - unsigned int nSize = BN_num_bytes(this); + unsigned int nSize = BN_num_bytes(bn); unsigned int nCompact = 0; if (nSize <= 3) - nCompact = BN_get_word(this) << 8*(3-nSize); + nCompact = BN_get_word(bn) << 8*(3-nSize); else { - CBigNum bn; - BN_rshift(&bn, this, 8*(nSize-3)); - nCompact = BN_get_word(&bn); + CBigNum bn1; + BN_rshift(&bn1, bn, 8*(nSize-3)); + nCompact = BN_get_word(&bn1); } // The 0x00800000 bit denotes the sign. // Thus, if it is already set, divide the mantissa by 256 and increase the exponent. @@ -331,7 +374,7 @@ class CBigNum : public BIGNUM nSize++; } nCompact |= nSize << 24; - nCompact |= (BN_is_negative(this) ? 0x00800000 : 0); + nCompact |= (BN_is_negative(bn) ? 0x00800000 : 0); return nCompact; } @@ -353,6 +396,14 @@ class CBigNum : public BIGNUM psz++; // hex string to bignum + // static const signed char phexdigit[256] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0xa,0xb,0xc,0xd,0xe,0xf,0,0,0,0,0,0,0,0,0 }; + // *this = 0; + // while (isxdigit(*psz)) + // { + // *this <<= 4; + // int n = phexdigit[(unsigned char)*psz++]; + // *this += n; + // } *this = 0; int n; while ((n = HexDigit(*psz)) != -1) @@ -385,7 +436,7 @@ class CBigNum : public BIGNUM unsigned int c = rem.getulong(); str += "0123456789abcdef"[c]; } - if (BN_is_negative(this)) + if (BN_is_negative(bn)) str += "-"; reverse(str.begin(), str.end()); return str; @@ -418,12 +469,12 @@ class CBigNum : public BIGNUM bool operator!() const { - return BN_is_zero(this); + return BN_is_zero(bn); } CBigNum& operator+=(const CBigNum& b) { - if (!BN_add(this, this, &b)) + if (!BN_add(bn, bn, &b)) throw bignum_error("CBigNum::operator+= : BN_add failed"); return *this; } @@ -437,7 +488,7 @@ class CBigNum : public BIGNUM CBigNum& operator*=(const CBigNum& b) { CAutoBN_CTX pctx; - if (!BN_mul(this, this, &b, pctx)) + if (!BN_mul(bn, bn, &b, pctx)) throw bignum_error("CBigNum::operator*= : BN_mul failed"); return *this; } @@ -456,7 +507,7 @@ class CBigNum : public BIGNUM CBigNum& operator<<=(unsigned int shift) { - if (!BN_lshift(this, this, shift)) + if (!BN_lshift(bn, bn, shift)) throw bignum_error("CBigNum:operator<<= : BN_lshift failed"); return *this; } @@ -467,13 +518,13 @@ class CBigNum : public BIGNUM // if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL CBigNum a = 1; a <<= shift; - if (BN_cmp(&a, this) > 0) + if (BN_cmp(&a, bn) > 0) { *this = 0; return *this; } - if (!BN_rshift(this, this, shift)) + if (!BN_rshift(bn, bn, shift)) throw bignum_error("CBigNum:operator>>= : BN_rshift failed"); return *this; } @@ -482,7 +533,7 @@ class CBigNum : public BIGNUM CBigNum& operator++() { // prefix operator - if (!BN_add(this, this, BN_value_one())) + if (!BN_add(bn, bn, BN_value_one())) throw bignum_error("CBigNum::operator++ : BN_add failed"); return *this; } @@ -499,7 +550,7 @@ class CBigNum : public BIGNUM { // prefix operator CBigNum r; - if (!BN_sub(&r, this, BN_value_one())) + if (!BN_sub(&r, bn, BN_value_one())) throw bignum_error("CBigNum::operator-- : BN_sub failed"); *this = r; return *this; From 5992d189f0c23b14ed8c3eb9602b81e5d09d9db4 Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Tue, 23 Feb 2021 08:07:18 -0500 Subject: [PATCH 02/18] update ssl --- src/bignum.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index 9cc552ca9b..1897a79bc5 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -86,7 +86,7 @@ class CBigNum { if (!BN_copy(bn, &b)) throw bignum_error("CBigNum::operator= : BN_copy failed"); - return (*bn); + return (*this); } ~CBigNum() @@ -422,17 +422,17 @@ class CBigNum CBigNum bnBase = nBase; CBigNum bn0 = 0; std::string str; - CBigNum bn = *this; - BN_set_negative(&bn, false); + CBigNum bn1 = *this; + BN_set_negative(&bn1, false); CBigNum dv; CBigNum rem; - if (BN_cmp(&bn, &bn0) == 0) + if (BN_cmp(&bn1, &bn0) == 0) return "0"; - while (BN_cmp(&bn, &bn0) > 0) + while (BN_cmp(&bn1, &bn0) > 0) { - if (!BN_div(&dv, &rem, &bn, &bnBase, pctx)) + if (!BN_div(&dv, &rem, &bn1, &bnBase, pctx)) throw bignum_error("CBigNum::ToString() : BN_div failed"); - bn = dv; + bn1 = dv; unsigned int c = rem.getulong(); str += "0123456789abcdef"[c]; } From 53af0bdc97b495b8517469125f6683fda948c1e6 Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Tue, 23 Feb 2021 08:34:48 -0500 Subject: [PATCH 03/18] ssl update and fix issue when --disable-wallet --- src/rpcmining.cpp | 2 ++ src/rpcserver.cpp | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 26b90538a4..f2f4d8da49 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -724,6 +724,7 @@ Value submitblock(const Array& params, bool fHelp) return Value::null; } +#ifdef ENABLE_WALLET Value getauxblock(const Array& params, bool fHelp) { if (fHelp || (params.size() != 0 && params.size() != 2)) @@ -874,3 +875,4 @@ Value getauxblock(const Array& params, bool fHelp) return "rejected"; return Value::null; } +#endif diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 615b682dcf..081119346b 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -287,8 +287,6 @@ static const CRPCCommand vRPCCommands[] = { "gnhps", &getnetworkhashps, true, false, false }, { "submitblock", &submitblock, true, false, false }, { "sb", &submitblock, true, false, false }, - { "getauxblock", &getauxblock, true, false, false }, - { "gab", &getauxblock, true, false, false }, /* Raw transactions */ { "createrawtransaction", &createrawtransaction, true, false, false }, @@ -403,6 +401,8 @@ static const CRPCCommand vRPCCommands[] = { "getminingalgo", &getminingalgo, true, true, false }, { "setgenerate", &setgenerate, true, true, false }, { "sg", &setgenerate, true, true, false }, + { "getauxblock", &getauxblock, true, false, false }, + { "gab", &getauxblock, true, false, false }, #endif // ENABLE_WALLET }; From 0bd592546e9121c89571dec1d377bea5325ccc0f Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Tue, 23 Feb 2021 09:12:45 -0500 Subject: [PATCH 04/18] update ssl --- src/crypter.cpp | 24 ++++++++++++------------ src/key.cpp | 41 ++++++++++++++++++++++++++++------------- src/key.h | 5 +++++ 3 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/crypter.cpp b/src/crypter.cpp index 19c640466a..69869e8763 100644 --- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -57,15 +57,15 @@ bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector (nCLen); - EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX *ctx; bool fOk = true; - EVP_CIPHER_CTX_init(&ctx); - if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); - if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); - if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen); - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_init(ctx); + if (fOk) fOk = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_EncryptUpdate(ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); + if (fOk) fOk = EVP_EncryptFinal_ex(ctx, (&vchCiphertext[0])+nCLen, &nFLen); + EVP_CIPHER_CTX_cleanup(ctx); if (!fOk) return false; @@ -84,15 +84,15 @@ bool CCrypter::Decrypt(const std::vector& vchCiphertext, CKeyingM vchPlaintext = CKeyingMaterial(nPLen); - EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX *ctx; bool fOk = true; - EVP_CIPHER_CTX_init(&ctx); - if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); - if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); - if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen); - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_init(ctx); + if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); + if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0])+nPLen, &nFLen); + EVP_CIPHER_CTX_cleanup(ctx); if (!fOk) return false; diff --git a/src/key.cpp b/src/key.cpp index c6eae5547b..2f179ae4aa 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -71,6 +71,7 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch EC_POINT *Q = NULL; BIGNUM *rr = NULL; BIGNUM *zero = NULL; + BIGNUM *s = 0; int n = 0; int i = recid / 2; @@ -82,7 +83,9 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch x = BN_CTX_get(ctx); if (!BN_copy(x, order)) { ret=-1; goto err; } if (!BN_mul_word(x, i)) { ret=-1; goto err; } - if (!BN_add(x, x, ecsig->r)) { ret=-1; goto err; } + ECDSA_SIG_get0(ecsig, (const BIGNUM **)&s, 0); + if (!BN_add(x, x, s)) { ret=-1; goto err; } + // if (!BN_add(x, x, ecsig->r)) { ret=-1; goto err; } field = BN_CTX_get(ctx); if (!EC_GROUP_get_curve_GFp(group, field, NULL, NULL, ctx)) { ret=-2; goto err; } if (BN_cmp(x, field) >= 0) { ret=0; goto err; } @@ -103,9 +106,13 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch if (!BN_zero(zero)) { ret=-1; goto err; } if (!BN_mod_sub(e, zero, e, order, ctx)) { ret=-1; goto err; } rr = BN_CTX_get(ctx); - if (!BN_mod_inverse(rr, ecsig->r, order, ctx)) { ret=-1; goto err; } + ECDSA_SIG_get0(ecsig, (const BIGNUM **)&s, 0); + if (!BN_mod_inverse(rr, s, order, ctx)) { ret=-1; goto err; } + // if (!BN_mod_inverse(rr, ecsig->r, order, ctx)) { ret=-1; goto err; } sor = BN_CTX_get(ctx); - if (!BN_mod_mul(sor, ecsig->s, rr, order, ctx)) { ret=-1; goto err; } + ECDSA_SIG_get0(ecsig, 0, (const BIGNUM **)&s); + if (!BN_mod_mul(sor, s, rr, order, ctx)) { ret=-1; goto err; } + // if (!BN_mod_mul(sor, ecsig->s, rr, order, ctx)) { ret=-1; goto err; } eor = BN_CTX_get(ctx); if (!BN_mod_mul(eor, e, rr, order, ctx)) { ret=-1; goto err; } if (!EC_POINT_mul(group, Q, eor, R, sor, ctx)) { ret=-2; goto err; } @@ -150,8 +157,7 @@ class CECKey { void SetSecretBytes(const unsigned char vch[32]) { bool ret; - BIGNUM bn; - BN_init(&bn); + CBigNum bn; ret = BN_bin2bn(vch, 32, &bn); assert(ret); ret = EC_KEY_regenerate_key(pkey, &bn); @@ -201,6 +207,7 @@ class CECKey { } bool Sign(const uint256 &hash, std::vector& vchSig) { + BIGNUM *s = 0; vchSig.clear(); ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); if (sig == NULL) @@ -212,9 +219,10 @@ class CECKey { BIGNUM *halforder = BN_CTX_get(ctx); EC_GROUP_get_order(group, order, ctx); BN_rshift1(halforder, order); - if (BN_cmp(sig->s, halforder) > 0) { + ECDSA_SIG_get0(sig, 0, (const BIGNUM **)&s); + if (BN_cmp(s, halforder) > 0) { // enforce low S values, by negating the value (modulo the order) if above order/2. - BN_sub(sig->s, order, sig->s); + BN_sub(s, order, s); } BN_CTX_end(ctx); BN_CTX_free(ctx); @@ -278,12 +286,15 @@ class CECKey { bool SignCompact(const uint256 &hash, unsigned char *p64, int &rec) { bool fOk = false; + BIGNUM *s = 0; + BIGNUM *r = 0; ECDSA_SIG *sig = ECDSA_do_sign((unsigned char*)&hash, sizeof(hash), pkey); if (sig==NULL) return false; memset(p64, 0, 64); - int nBitsR = BN_num_bits(sig->r); - int nBitsS = BN_num_bits(sig->s); + ECDSA_SIG_get0(sig, (const BIGNUM **)&r, (const BIGNUM **)&s); + int nBitsR = BN_num_bits(r); + int nBitsS = BN_num_bits(s); if (nBitsR <= 256 && nBitsS <= 256) { CPubKey pubkey; GetPubKey(pubkey, true); @@ -300,8 +311,9 @@ class CECKey { } } assert(fOk); - BN_bn2bin(sig->r,&p64[32-(nBitsR+7)/8]); - BN_bn2bin(sig->s,&p64[64-(nBitsS+7)/8]); + ECDSA_SIG_get0(sig, (const BIGNUM **)&r, (const BIGNUM **)&s); + BN_bn2bin(r,&p64[32-(nBitsR+7)/8]); + BN_bn2bin(s,&p64[64-(nBitsS+7)/8]); } ECDSA_SIG_free(sig); return fOk; @@ -313,11 +325,14 @@ class CECKey { // (the signature is a valid signature of the given data for that key) bool Recover(const uint256 &hash, const unsigned char *p64, int rec) { + BIGNUM *s = 0; + BIGNUM *r = 0; if (rec<0 || rec>=3) return false; ECDSA_SIG *sig = ECDSA_SIG_new(); - BN_bin2bn(&p64[0], 32, sig->r); - BN_bin2bn(&p64[32], 32, sig->s); + ECDSA_SIG_get0(sig, (const BIGNUM **)&r, (const BIGNUM **)&s); + BN_bin2bn(&p64[0], 32, r); + BN_bin2bn(&p64[32], 32, s); bool ret = ECDSA_SIG_recover_key_GFp(pkey, sig, (unsigned char*)&hash, sizeof(hash), rec, 0) == 1; ECDSA_SIG_free(sig); return ret; diff --git a/src/key.h b/src/key.h index 921b1e2e73..90b822e6d1 100644 --- a/src/key.h +++ b/src/key.h @@ -15,6 +15,11 @@ #include #include +#if OPENSSL_VERSION_NUMBER < 0x10100000L +#include + void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); +#endif + // secp256k1: // const unsigned int PRIVATE_KEY_SIZE = 279; // const unsigned int PUBLIC_KEY_SIZE = 65; From 39e6eaa667ae2832a5cccb0ee7646774cb39bca3 Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Tue, 23 Feb 2021 09:31:10 -0500 Subject: [PATCH 05/18] update ssl --- src/key.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/key.cpp b/src/key.cpp index 2f179ae4aa..d1d2f46255 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -157,12 +157,15 @@ class CECKey { void SetSecretBytes(const unsigned char vch[32]) { bool ret; - CBigNum bn; - ret = BN_bin2bn(vch, 32, &bn); + // BIGNUM bn; + // BN_init(&bn); + BIGNUM *bn; + bn = BN_new(); + ret = BN_bin2bn(vch, 32, bn); assert(ret); - ret = EC_KEY_regenerate_key(pkey, &bn); + ret = EC_KEY_regenerate_key(pkey, bn); assert(ret); - BN_clear_free(&bn); + BN_clear_free(bn); } void GetPrivKey(CPrivKey &privkey, bool fCompressed) { From e20fc8aaf6eee2b99e4a10be171dbcb613f2f184 Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Tue, 23 Feb 2021 10:13:31 -0500 Subject: [PATCH 06/18] fix ssl errors --- src/bignum.h | 24 +++++------------------- src/crypter.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/src/bignum.h b/src/bignum.h index 1897a79bc5..8a186012f4 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -102,29 +102,15 @@ class CBigNum CBigNum(signed char n) { init(); if (n >= 0) setulong(n); else setint64(n); } CBigNum(short n) { init(); if (n >= 0) setulong(n); else setint64(n); } CBigNum(int n) { init(); if (n >= 0) setulong(n); else setint64(n); } -// CBigNum(long n) { init(); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int64_t n) { init(); setint64(n); } + CBigNum(long n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(long long n) { init(); setint64(n); } + CBigNum(unsigned char n) { init(); setulong(n); } CBigNum(unsigned short n) { init(); setulong(n); } CBigNum(unsigned int n) { init(); setulong(n); } -// CBigNum(unsigned long n) { init(); setulong(n); } - CBigNum(uint64_t n) { init(); setuint64(n); } - CBigNum(long long int n) { init(); setuint64(n); } + CBigNum(unsigned long n) { init(); setulong(n); } + CBigNum(unsigned long long n) { init(); setuint64(n); } explicit CBigNum(uint256 n) { init(); setuint256(n); } - - //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'. - /*CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(long long n) { BN_init(this); setint64(n); } - CBigNum(unsigned char n) { BN_init(this); setulong(n); } - CBigNum(unsigned short n) { BN_init(this); setulong(n); } - CBigNum(unsigned int n) { BN_init(this); setulong(n); } - CBigNum(unsigned long n) { BN_init(this); setulong(n); } - CBigNum(unsigned long long n) { BN_init(this); setuint64(n); } - explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); }*/ - explicit CBigNum(const std::vector& vch) { init(); diff --git a/src/crypter.cpp b/src/crypter.cpp index 69869e8763..ccdb9e9d72 100644 --- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -61,12 +61,12 @@ bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector& vchCiphertext, CKeyingM bool fOk = true; - EVP_CIPHER_CTX_init(ctx); + ctx = EVP_CIPHER_CTX_new(); if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0])+nPLen, &nFLen); - EVP_CIPHER_CTX_cleanup(ctx); + EVP_CIPHER_CTX_free(ctx); if (!fOk) return false; From 60e5b3c0cce56b4d816398be804c0d3ec16ba736 Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Wed, 24 Feb 2021 07:40:41 -0500 Subject: [PATCH 07/18] update for boost 1.7 --- src/rpcserver.cpp | 4 ++-- src/rpcserver.h | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 081119346b..8805bf25bc 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -537,8 +537,8 @@ static void RPCListen(boost::shared_ptr< basic_socket_acceptor > accep const bool fUseSSL) { // Accept connection - boost::shared_ptr< AcceptedConnectionImpl > conn(new AcceptedConnectionImpl(acceptor->get_io_service(), context, fUseSSL)); - + boost::shared_ptr< AcceptedConnectionImpl > conn(new AcceptedConnectionImpl(GetIOServiceFromPtr(acceptor), context, fUseSSL)); + acceptor->async_accept( conn->sslStream.lowest_layer(), conn->peer, diff --git a/src/rpcserver.h b/src/rpcserver.h index caff029422..1bf3b0790f 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -19,6 +19,16 @@ #include "json/json_spirit_utils.h" #include "json/json_spirit_writer_template.h" +#include +#include + +// Boost Support for 1.70+ +#if BOOST_VERSION >= 107000 + #define GetIOServiceFromPtr(s) ((boost::asio::io_context&)(s->get_executor().context())) // this one +#else + #define GetIOServiceFromPtr(s) ((s)->get_io_service()) +#endif + class CBlockIndex; /* Start RPC threads */ From 0906d86599a5aad5492e74b0029e66039592f92f Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Wed, 24 Feb 2021 08:48:09 -0500 Subject: [PATCH 08/18] update for boost 1.7 --- src/rpcprotocol.h | 2 +- src/rpcserver.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h index 9252744f07..1bf27802c9 100644 --- a/src/rpcprotocol.h +++ b/src/rpcprotocol.h @@ -104,7 +104,7 @@ class SSLIOStreamDevice : public boost::iostreams::device= 107000 + #define GetIOService(s) ((boost::asio::io_context&)(s).get_executor().context()) #define GetIOServiceFromPtr(s) ((boost::asio::io_context&)(s->get_executor().context())) // this one + typedef boost::asio::io_context ioContext; #else + #define GetIOService(s) ((s).get_io_service()) #define GetIOServiceFromPtr(s) ((s)->get_io_service()) + typedef boost::asio::io_service ioContext; #endif class CBlockIndex; From 4ff88587bb20997a04d6bb3e3680fc72add5bfd0 Mon Sep 17 00:00:00 2001 From: DBKeys Date: Sun, 21 Mar 2021 12:28:59 +0000 Subject: [PATCH 09/18] fix issue with GetIOService --- src/rpcprotocol.h | 14 ++++++++++++++ src/rpcserver.h | 13 ------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h index 1bf27802c9..6f5c0eb146 100644 --- a/src/rpcprotocol.h +++ b/src/rpcprotocol.h @@ -20,6 +20,20 @@ #include "json/json_spirit_utils.h" #include "json/json_spirit_writer_template.h" +#include + #include + + // Boost Support for 1.70+ + #if BOOST_VERSION >= 107000 + #define GetIOService(s) ((boost::asio::io_context&)(s).get_executor().context()) + #define GetIOServiceFromPtr(s) ((boost::asio::io_context&)(s->get_executor().context())) // this one + typedef boost::asio::io_context ioContext; + #else + #define GetIOService(s) ((s).get_io_service()) + #define GetIOServiceFromPtr(s) ((s)->get_io_service()) + typedef boost::asio::io_service ioContext; + #endif + // HTTP status codes enum HTTPStatusCode { diff --git a/src/rpcserver.h b/src/rpcserver.h index 36487cf664..fb4d134ca8 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -19,19 +19,6 @@ #include "json/json_spirit_utils.h" #include "json/json_spirit_writer_template.h" -#include -#include - -// Boost Support for 1.70+ -#if BOOST_VERSION >= 107000 - #define GetIOService(s) ((boost::asio::io_context&)(s).get_executor().context()) - #define GetIOServiceFromPtr(s) ((boost::asio::io_context&)(s->get_executor().context())) // this one - typedef boost::asio::io_context ioContext; -#else - #define GetIOService(s) ((s).get_io_service()) - #define GetIOServiceFromPtr(s) ((s)->get_io_service()) - typedef boost::asio::io_service ioContext; -#endif class CBlockIndex; From d92bdfcbe66b6e037d7e0c669a7f33e8055e5dfe Mon Sep 17 00:00:00 2001 From: DBKeys Date: Sun, 21 Mar 2021 17:07:22 +0000 Subject: [PATCH 10/18] Update README.md Better wording Updated nodes and seeders; CLI --version command; Emission comments; remove main & appinit messages --- README.md | 4 +++- src/bitmarkd.cpp | 13 +++++++++++-- src/chainparams.cpp | 45 +++++++++++++++++++++++++++++---------------- src/chainparams.h | 17 ++++++++++++++++- src/main.cpp | 15 ++++++++++----- 5 files changed, 69 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 296fbde0b1..15230da9a6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Project Bitmark is a multi faceted project which aims to provide: 1. A ** stable cryptographic currency network** which balances the requirements of all parties involved. -2. A **far reaching adoption initiative** under the guise of novel reputation+currency system called [Marking](https://github.com/project-bitmark/marking/wiki) +2. A **far reaching adoption initiative** guided by the vision of a novel reputation+currency system called [Marking](https://github.com/project-bitmark/marking/wiki) This repository contains the Bitmark cryptograpic currency software, and a wiki which provides all details pertaining to the software, it's configuration and the rationale of all design decisions. @@ -35,6 +35,8 @@ Bitmark aims to be a relatively stable, user focused crypto currency, which refi All Bitmark software releases are published through the github release process, you can download the [latest release](https://github.com/project-bitmark/bitmark/releases) from the releases tab above. +## v0.9.7.3 Compatibility with newer TLS / SSL libraries in Ubutnu 18-20 and Debian 10 + ## Eight Algortihm mPoW Hard Fork (v0.9.7) The hard fork for multiple proof-of-work algorithms (SCRYPT, SHA256D, YESCRYPT, ARGON2D, X17, LYRA2REv2, EQUIHASH, CRYPTONIGHT) under DGWv3 was adopted by the Bitmark community by supermajority consensus after block 450946. The first block where v0.9.7 rules are in effect is 450947. diff --git a/src/bitmarkd.cpp b/src/bitmarkd.cpp index 95450b31dc..f9a98a2ce8 100644 --- a/src/bitmarkd.cpp +++ b/src/bitmarkd.cpp @@ -55,7 +55,7 @@ void DetectShutdownThread(boost::thread_group* threadGroup) // bool AppInit(int argc, char* argv[]) { - printf("appinit\n"); + //printf("appinit\n"); boost::thread_group threadGroup; boost::thread* detectShutdownThread = NULL; @@ -103,6 +103,15 @@ bool AppInit(int argc, char* argv[]) return false; } + if (mapArgs.count("-v") || mapArgs.count("--version")) + { + // First part of help message is specific to bitmarkd / RPC client + std::string strUsage = _("Bitmark Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n"; + fprintf(stdout, "%s", strUsage.c_str()); + return false; + } + + // Command-line RPC bool fCommandLine = false; for (int i = 1; i < argc; i++) @@ -174,7 +183,7 @@ bool AppInit(int argc, char* argv[]) int main(int argc, char* argv[]) { - printf("main"); + //printf("main"); SetupEnvironment(); bool fRet = false; diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7fccc17b0a..435802d006 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -22,18 +22,12 @@ using namespace boost::assign; // Hard-Coded (Fixed) Network Nodes unsigned int pnSeed[] = { -// 0xac1f1f0a, // *** inoperative: historical IP with IBM / SoftLayer *** -// 0x253b1359, // *** inoperative: historical IP with IBM / SoftLayer *** -// 0xAE240982, // *** inoperative: historical IP with IBM / SoftLayer *** 0xADFFFC8C, // seed.bitmark.co IP = 173.255.252.140 sam 0x8BA2805C, // eu.bitmark.io IP = 139.162.128.92 frank 0x5E89B1E3, // ge.bitmark.io IP = 94.137.177.227 anton 0x8BA27A8A, // jp.bitmark.io IP = 139.162.122.138 akio 0x2D2141A1, // us.bitmark.io IP = 45.33.65.161 joe - 0xCC447A12, // tx.bitmark.io IP = 204.68.122.18 tex - 0xCC447A07, // seed.bitmark.mx IP = 204.68.122.7 jules - 0xCC447A0B, // one.zmark.org IP = 204.68.122.11 per - 0x8BA2E8F2 // uk.bitmark.one IP = 139.162.232.242 jim + 0x8BA223AA, // sg.bitmark.co IP = 139.162.35.170 ben }; class CMainParams : public CChainParams { @@ -80,15 +74,34 @@ class CMainParams : public CChainParams { // DNS Seeders - Verified, December 15, 2017 - dBKeys - vSeeds.push_back(CDNSSeedData("bitmark.one", "biji.bitmark.one")); - vSeeds.push_back(CDNSSeedData("bitmark.one", "shido.bitmark.one")); - vSeeds.push_back(CDNSSeedData("zmark.org", "ra.zmark.org")); - vSeeds.push_back(CDNSSeedData("zmark.org", "shiba.zmark.org")); - vSeeds.push_back(CDNSSeedData("zmark.org", "btmk.zmark.org")); - vSeeds.push_back(CDNSSeedData("bitmark.guru", "btmk.bitmark.guru")); - vSeeds.push_back(CDNSSeedData("bitmark.guru", "da.bitmark.guru")); - vSeeds.push_back(CDNSSeedData("bitmark.one", "da.bitmark.mx")); - vSeeds.push_back(CDNSSeedData("zmark.org", "btm.zmark.org")); +// vSeeds.push_back(CDNSSeedData("bitmark.one", "biji.bitmark.one")); +// vSeeds.push_back(CDNSSeedData("bitmark.one", "shido.bitmark.one")); +// vSeeds.push_back(CDNSSeedData("zmark.org", "ra.zmark.org")); +// vSeeds.push_back(CDNSSeedData("zmark.org", "shiba.zmark.org")); +// vSeeds.push_back(CDNSSeedData("zmark.org", "btmk.zmark.org")); +// vSeeds.push_back(CDNSSeedData("bitmark.guru", "btmk.bitmark.guru")); +// vSeeds.push_back(CDNSSeedData("bitmark.guru", "da.bitmark.guru")); +// vSeeds.push_back(CDNSSeedData("bitmark.one", "da.bitmark.mx")); +// vSeeds.push_back(CDNSSeedData("zmark.org", "btm.zmark.org")); + + // DNS Seeders - Verified 03 08 21 March 8, 2021 + // Domain Sub-Domain Location + vSeeds.push_back(CDNSSeedData("bitmark.guru", "da.bitmark.guru")); // DE Frank + vSeeds.push_back(CDNSSeedData("openmarks.com", "btm.openmarks.com")); // IL eli + vSeeds.push_back(CDNSSeedData("bitmark.one", "shido.bitmark.one")); // JP akio + + vSeeds.push_back(CDNSSeedData("openmarks.com", "dnsseed.openmarks.com")); // DE omar + vSeeds.push_back(CDNSSeedData("zmark.org", "ra.zmark.org")); // CA sam + vSeeds.push_back(CDNSSeedData("chainetics.com", "marks.chainetics.com")); // SG ben + + vSeeds.push_back(CDNSSeedData("bitmark.one", "biji.bitmark.one")); // CA marks + vSeeds.push_back(CDNSSeedData("avalax.com", "marks.avalax.com")); // JP jin + vSeeds.push_back(CDNSSeedData("zmark.org", "shiba.zmark.org")); // NJ j2 + + vSeeds.push_back(CDNSSeedData("zmark.org", "btmk.zmark.org")); // CA zappa + vSeeds.push_back(CDNSSeedData("bitmark.cc", "dnsseed.bitmark.cc")); // NJ joe + vSeeds.push_back(CDNSSeedData("zmark.org", "btm.zmark.org")); // NJ vinny j0 + base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,85); // b base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,5); diff --git a/src/chainparams.h b/src/chainparams.h index 11d14b46e3..1c530a3b12 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -73,7 +73,22 @@ class CChainParams unsigned int EquihashN() const { return nEquihashN; } unsigned int EquihashK() const { return nEquihashK; } bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } - + int64_t GetFork2Height() const { return nForkHeight2; } + bool OnFork2(int64_t blockHeight) const { return blockHeight >= nForkHeight2; } + + // CEM Look-Back time frame (from which to find the refrence highest or peak hashrate) Policy is relaxed to ~ 25% of original value. + // CEM v0.1 looks back 365 days. CEM v0.2 looks back only 90 days + // This allow the maximum emission rate to be resumed that much sooner. + int CEM_WindowLength(int64_t blockHeight) const { return OnFork2(blockHeight) ? 90 : 365; } + + // CEM is allowed to affect this portion of the epoch nominal block reward. + // CEM v0.1 scales 50% of the max epoch reward. CEM v0.2 scales 80% of the max epoch reward. + // Both versions allow maximum theoretical emission rate if current hashrate is at peak performance, + // but CEM v0.2 has a stronger emission rate reduction if current hashrate is any less than reference peak performance. + // + int CEM_MaxNativeBlockRewardReduction(int64_t blockHeight) const { return OnFork2(blockHeight) ? 80 : 50; } + + protected: CChainParams() {} diff --git a/src/main.cpp b/src/main.cpp index b50979dd41..272dcd7ca6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1216,14 +1216,13 @@ int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool noScale) if (halvings >= 18) return nFees; - // Subsidy is cut in half every 788,000 blocks which will occur approximately every 3 years. - // Subsidy has an interim reduction every 394,000 blocks (18 months) + // Halving: Subsidy is cut in half every 788,000 blocks which will occur approximately every 3 years (36 months). + // Quartering: Subsidy has an interim reduction every 394,000 blocks, approximately every 1.5 years (18 months) nSubsidy = (nHalfReward>>halvings) + (nHalfReward>>((nHeight+Params().SubsidyInterimInterval())/Params().SubsidyHalvingInterval())); return nSubsidy + nFees; } - // And after the fork we will halve based on how many coins have been - // emitted + // And after fork 1, we will halve & quarter based on how many coins have been emitted uint256 emitted; CBlockIndex * pprev_algo = get_pprev_algo(pindex,-1); @@ -1370,7 +1369,13 @@ int64_t GetBlockValue(CBlockIndex* pindex, int64_t nFees, bool noScale) else if (emitted < 2757984964566000) { // Q 18 H 17 height 13790000 baseSubsidy = 15258; } - // total of 2757989473108000 coins emitted + + // Total Emission 27579894.73108000 + // ------------------------------------------------------------------------------------------------------------------- + // Total of 27,579,894.73,108,000 coins emitted + // Twenty seven million, five hundred seventy nine thousand, eight hundred ninety four Bitmarks (MARKS) and + // Seventy three million, one hundred and eight thousand Bitmark-Satoshis. + if (!scalingFactor) return nFees + baseSubsidy; return nFees + baseSubsidy - ((CBigNum(baseSubsidy)*CBigNum(100000000))/scalingFactor).getuint() / 2; } From c111891a1c8d1f872c7aeb6ecf36175051a999f2 Mon Sep 17 00:00:00 2001 From: DBKeys Date: Sun, 21 Mar 2021 17:23:41 +0000 Subject: [PATCH 11/18] Fork2 suspended 'TFN (3/21/21) --- src/chainparams.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/chainparams.h b/src/chainparams.h index 1c530a3b12..0dfa412723 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -73,8 +73,9 @@ class CChainParams unsigned int EquihashN() const { return nEquihashN; } unsigned int EquihashK() const { return nEquihashK; } bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } - int64_t GetFork2Height() const { return nForkHeight2; } - bool OnFork2(int64_t blockHeight) const { return blockHeight >= nForkHeight2; } + // Fork2 in suspension (3/21/21) + //int64_t GetFork2Height() const { return nForkHeight2; } + //bool OnFork2(int64_t blockHeight) const { return blockHeight >= nForkHeight2; } // CEM Look-Back time frame (from which to find the refrence highest or peak hashrate) Policy is relaxed to ~ 25% of original value. // CEM v0.1 looks back 365 days. CEM v0.2 looks back only 90 days From dd583e807731159d572b8fc1d434e82a58883fe3 Mon Sep 17 00:00:00 2001 From: DBKeys Date: Sun, 21 Mar 2021 17:29:59 +0000 Subject: [PATCH 12/18] Fork2 in suspension --- src/chainparams.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/chainparams.h b/src/chainparams.h index 0dfa412723..c2257e109c 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -73,6 +73,7 @@ class CChainParams unsigned int EquihashN() const { return nEquihashN; } unsigned int EquihashK() const { return nEquihashK; } bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; } + // Fork2 in suspension (3/21/21) //int64_t GetFork2Height() const { return nForkHeight2; } //bool OnFork2(int64_t blockHeight) const { return blockHeight >= nForkHeight2; } @@ -80,14 +81,14 @@ class CChainParams // CEM Look-Back time frame (from which to find the refrence highest or peak hashrate) Policy is relaxed to ~ 25% of original value. // CEM v0.1 looks back 365 days. CEM v0.2 looks back only 90 days // This allow the maximum emission rate to be resumed that much sooner. - int CEM_WindowLength(int64_t blockHeight) const { return OnFork2(blockHeight) ? 90 : 365; } - + // int CEM_WindowLength(int64_t blockHeight) const { return OnFork2(blockHeight) ? 90 : 365; } + // // CEM is allowed to affect this portion of the epoch nominal block reward. // CEM v0.1 scales 50% of the max epoch reward. CEM v0.2 scales 80% of the max epoch reward. // Both versions allow maximum theoretical emission rate if current hashrate is at peak performance, // but CEM v0.2 has a stronger emission rate reduction if current hashrate is any less than reference peak performance. // - int CEM_MaxNativeBlockRewardReduction(int64_t blockHeight) const { return OnFork2(blockHeight) ? 80 : 50; } + //int CEM_MaxNativeBlockRewardReduction(int64_t blockHeight) const { return OnFork2(blockHeight) ? 80 : 50; } protected: From 5919305b1f018527b25c9bcc0f9b47f66e7320d0 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 22 Mar 2021 12:49:23 +0000 Subject: [PATCH 13/18] This is development v0.9.7.3 --- README.md | 5 ++++- configure.ac | 6 +++--- src/clientversion.h | 4 ++-- vimver | 2 ++ 4 files changed, 11 insertions(+), 6 deletions(-) create mode 100755 vimver diff --git a/README.md b/README.md index 15230da9a6..a75c1ea18f 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,10 @@ Bitmark aims to be a relatively stable, user focused crypto currency, which refi All Bitmark software releases are published through the github release process, you can download the [latest release](https://github.com/project-bitmark/bitmark/releases) from the releases tab above. -## v0.9.7.3 Compatibility with newer TLS / SSL libraries in Ubutnu 18-20 and Debian 10 +## v0.9.7.3 Update to compile with newer TLS / SSL libraries in Ubutnu 18-20 and Debian 10 +March 7, 2021 This branches off Master's tag v0.9.7.2 to develop use of the latest TLS/SSL libraries in Ubuntu 20 +The goal are a) stable release v0.9.7.4, to be compatible with all previous 0.9.7.x series versions. +and b) binary releases for the latest major OS's: Ubuntu 16-20, Debian 10, CentOS 7-8, Mac & Windows. ## Eight Algortihm mPoW Hard Fork (v0.9.7) diff --git a/configure.ac b/configure.ac index 9214c251bf..ba735dadd6 100644 --- a/configure.ac +++ b/configure.ac @@ -3,9 +3,9 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 9) define(_CLIENT_VERSION_REVISION, 7) -define(_CLIENT_VERSION_BUILD, 2) -define(_CLIENT_VERSION_IS_RELEASE, true) -define(_COPYRIGHT_YEAR, 2018) +define(_CLIENT_VERSION_BUILD, 3) +define(_CLIENT_VERSION_IS_RELEASE, false) +define(_COPYRIGHT_YEAR, 2021) AC_INIT([Bitmark Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitmark.org],[bitmark]) AC_CONFIG_AUX_DIR([src/build-aux]) AC_CONFIG_MACRO_DIR([src/m4]) diff --git a/src/clientversion.h b/src/clientversion.h index 2f62104010..c6d11bd065 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -12,14 +12,14 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 9 #define CLIENT_VERSION_REVISION 7 -#define CLIENT_VERSION_BUILD 2 +#define CLIENT_VERSION_BUILD 3 // Set to true for release, false for prerelease (rc: release candidate) or test build #define CLIENT_VERSION_IS_RELEASE false // Copyright year (2009-this) -#define COPYRIGHT_YEAR 2018 +#define COPYRIGHT_YEAR 2021 #endif //HAVE_CONFIG_H diff --git a/vimver b/vimver new file mode 100755 index 0000000000..ded9ae80a7 --- /dev/null +++ b/vimver @@ -0,0 +1,2 @@ +#!/bin/bash +vim configure.ac src/clientversion.h src/version.h README.md From 1b17a96c6fef6170acd611fcc2808a181ae65756 Mon Sep 17 00:00:00 2001 From: 1notchdev Date: Tue, 23 Mar 2021 03:34:14 +0800 Subject: [PATCH 14/18] fix issue under SSL 1.1.0 --- src/key.cpp | 9 +++++++++ src/key.h | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/key.cpp b/src/key.cpp index d1d2f46255..6bc2a68f84 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -13,6 +13,15 @@ // anonymous namespace with local implementation code (OpenSSL interaction) namespace { +#if OPENSSL_VERSION_NUMBER < 0x10100000L + void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps) + { + if (pr != NULL) + *pr = sig->r; + if (ps != NULL) + *ps = sig->s; + } +#endif // Generate a private key from just the secret parameter int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key) { diff --git a/src/key.h b/src/key.h index 90b822e6d1..5c83876fd1 100644 --- a/src/key.h +++ b/src/key.h @@ -15,10 +15,10 @@ #include #include -#if OPENSSL_VERSION_NUMBER < 0x10100000L -#include - void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); -#endif +// #if OPENSSL_VERSION_NUMBER < 0x10100000L +// #include +// void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); +// #endif // secp256k1: // const unsigned int PRIVATE_KEY_SIZE = 279; From ab0044ac04af7b9e36702a405c9ef7031e99b41f Mon Sep 17 00:00:00 2001 From: dbkeys Date: Sat, 10 Apr 2021 17:44:05 +0000 Subject: [PATCH 15/18] Stable Release v0.9.7.4 --- README.md | 7 +++---- configure.ac | 2 +- src/clientversion.h | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a75c1ea18f..0345817c47 100644 --- a/README.md +++ b/README.md @@ -35,10 +35,9 @@ Bitmark aims to be a relatively stable, user focused crypto currency, which refi All Bitmark software releases are published through the github release process, you can download the [latest release](https://github.com/project-bitmark/bitmark/releases) from the releases tab above. -## v0.9.7.3 Update to compile with newer TLS / SSL libraries in Ubutnu 18-20 and Debian 10 -March 7, 2021 This branches off Master's tag v0.9.7.2 to develop use of the latest TLS/SSL libraries in Ubuntu 20 -The goal are a) stable release v0.9.7.4, to be compatible with all previous 0.9.7.x series versions. -and b) binary releases for the latest major OS's: Ubuntu 16-20, Debian 10, CentOS 7-8, Mac & Windows. +## v0.9.7.4 Works with newer TLS / SSL libraries in Ubuntu 18-20 and Debian 10 +This release branches off Master's tag v0.9.7.2 to use the latest TLS/SSL libraries. +v0.9.7.4, is compatible with all previous 0.9.7.x series versions. ## Eight Algortihm mPoW Hard Fork (v0.9.7) diff --git a/configure.ac b/configure.ac index ba735dadd6..17827b9cb3 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 9) define(_CLIENT_VERSION_REVISION, 7) -define(_CLIENT_VERSION_BUILD, 3) +define(_CLIENT_VERSION_BUILD, 4) define(_CLIENT_VERSION_IS_RELEASE, false) define(_COPYRIGHT_YEAR, 2021) AC_INIT([Bitmark Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitmark.org],[bitmark]) diff --git a/src/clientversion.h b/src/clientversion.h index c6d11bd065..173eb99676 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -12,10 +12,10 @@ #define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MINOR 9 #define CLIENT_VERSION_REVISION 7 -#define CLIENT_VERSION_BUILD 3 +#define CLIENT_VERSION_BUILD 4 // Set to true for release, false for prerelease (rc: release candidate) or test build -#define CLIENT_VERSION_IS_RELEASE false +#define CLIENT_VERSION_IS_RELEASE true // Copyright year (2009-this) From 07a40e3ad109f5a0d1bbdece120dfc2dda965eb1 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Sun, 11 Apr 2021 12:15:45 +0000 Subject: [PATCH 16/18] Remove "beta" suffix --- configure.ac | 2 +- src/version.cpp | 4 +++- vimver | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 17827b9cb3..4a6dee8033 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ define(_CLIENT_VERSION_MAJOR, 0) define(_CLIENT_VERSION_MINOR, 9) define(_CLIENT_VERSION_REVISION, 7) define(_CLIENT_VERSION_BUILD, 4) -define(_CLIENT_VERSION_IS_RELEASE, false) +define(_CLIENT_VERSION_IS_RELEASE, true) define(_COPYRIGHT_YEAR, 2021) AC_INIT([Bitmark Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@bitmark.org],[bitmark]) AC_CONFIG_AUX_DIR([src/build-aux]) diff --git a/src/version.cpp b/src/version.cpp index 0d8952d77d..0d214ec1d1 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -12,8 +12,10 @@ // target servers or GUI users specifically. const std::string CLIENT_NAME("Pfennig"); +// https://github.com/bitcoin/bitcoin/issues/4221 +// Standard convention in software release cycles: dev, alpha, beta, rc & stable. // Client version number -#define CLIENT_VERSION_SUFFIX "-beta" +#define CLIENT_VERSION_SUFFIX "" // The following part of the code determines the CLIENT_BUILD variable. diff --git a/vimver b/vimver index ded9ae80a7..50a34936a6 100755 --- a/vimver +++ b/vimver @@ -1,2 +1,4 @@ #!/bin/bash -vim configure.ac src/clientversion.h src/version.h README.md +echo "set CLIENT_VERSION_IS_RELEASE in Makefile" +read +vim Makefile configure.ac src/clientversion.h src/version.h README.md From 73e8e96c42e7b8737f4b872f9d3c3509c1920d74 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Sun, 11 Apr 2021 06:12:40 -0700 Subject: [PATCH 17/18] Version naming --- src/version.cpp | 2 +- vimver | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.cpp b/src/version.cpp index 0d214ec1d1..1c47c4c78e 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -15,7 +15,7 @@ const std::string CLIENT_NAME("Pfennig"); // https://github.com/bitcoin/bitcoin/issues/4221 // Standard convention in software release cycles: dev, alpha, beta, rc & stable. // Client version number -#define CLIENT_VERSION_SUFFIX "" +#define CLIENT_VERSION_SUFFIX "Phi" // The following part of the code determines the CLIENT_BUILD variable. diff --git a/vimver b/vimver index 50a34936a6..63cf793fbd 100755 --- a/vimver +++ b/vimver @@ -1,4 +1,4 @@ #!/bin/bash echo "set CLIENT_VERSION_IS_RELEASE in Makefile" read -vim Makefile configure.ac src/clientversion.h src/version.h README.md +vim Makefile configure.ac src/clientversion.h src/version.h src/versin.cpp README.md From dc617fb4949f335ac3fd6c3aeb9af78a5aaed298 Mon Sep 17 00:00:00 2001 From: dbkeys Date: Sun, 11 Apr 2021 14:38:14 +0000 Subject: [PATCH 18/18] Typos --- src/version.cpp | 2 +- vimver | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/version.cpp b/src/version.cpp index 1c47c4c78e..2e888778dc 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -15,7 +15,7 @@ const std::string CLIENT_NAME("Pfennig"); // https://github.com/bitcoin/bitcoin/issues/4221 // Standard convention in software release cycles: dev, alpha, beta, rc & stable. // Client version number -#define CLIENT_VERSION_SUFFIX "Phi" +#define CLIENT_VERSION_SUFFIX "-Phi" // The following part of the code determines the CLIENT_BUILD variable. diff --git a/vimver b/vimver index 63cf793fbd..ea85c2ba70 100755 --- a/vimver +++ b/vimver @@ -1,4 +1,4 @@ #!/bin/bash echo "set CLIENT_VERSION_IS_RELEASE in Makefile" read -vim Makefile configure.ac src/clientversion.h src/version.h src/versin.cpp README.md +vim Makefile configure.ac src/clientversion.h src/version.h src/version.cpp README.md