Skip to content

Commit af1b5b2

Browse files
alexalex
authored andcommitted
Add trusted N for MainNet and TestNet, set denomination value to 50 coins
1 parent c0f84a8 commit af1b5b2

File tree

7 files changed

+34
-16
lines changed

7 files changed

+34
-16
lines changed

src/init.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,6 @@ bool AppInit2()
361361
nNodeLifespan = GetArg("-addrlifespan", 7);
362362
fStakeUsePooledKeys = GetBoolArg("-stakepooledkeys", false);
363363

364-
if (GetBoolArg("-zerotest", false))
365-
{
366-
Test_RunAllTests();
367-
}
368-
369364
CheckpointsMode = Checkpoints::STRICT;
370365
std::string strCpMode = GetArg("-cppolicy", "strict");
371366

@@ -707,6 +702,7 @@ bool AppInit2()
707702
if (!LoadBlockIndex())
708703
return InitError(_("Error loading blkindex.dat"));
709704

705+
710706
// as LoadBlockIndex can take several minutes, it's possible the user
711707
// requested to kill bitcoin-qt during the last operation. If so, exit.
712708
// As the program has not fully started yet, Shutdown() is possibly overkill.
@@ -746,6 +742,16 @@ bool AppInit2()
746742
return false;
747743
}
748744

745+
// ********************************************************* Testing Zerocoin
746+
747+
748+
if (GetBoolArg("-zerotest", false))
749+
{
750+
printf("\n=== ZeroCoin tests start ===\n");
751+
Test_RunAllTests();
752+
printf("=== ZeroCoin tests end ===\n\n");
753+
}
754+
749755
// ********************************************************* Step 8: load wallet
750756

751757
uiInterface.InitMessage(_("Loading wallet..."));

src/main.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
#include "init.h"
1212
#include "ui_interface.h"
1313
#include "kernel.h"
14+
#include "zerocoin/Zerocoin.h"
1415
#include <boost/algorithm/string/replace.hpp>
1516
#include <boost/filesystem.hpp>
1617
#include <boost/filesystem/fstream.hpp>
1718

19+
1820
using namespace std;
1921
using namespace boost;
2022

@@ -32,6 +34,7 @@ unsigned int nTransactionsUpdated = 0;
3234

3335
map<uint256, CBlockIndex*> mapBlockIndex;
3436
set<pair<COutPoint, unsigned int> > setStakeSeen;
37+
libzerocoin::Params* ZCParams;
3538

3639
CBigNum bnProofOfWorkLimit(~uint256(0) >> 20); // "standard" scrypt target limit for proof of work, results with 0,000244140625 proof-of-work difficulty
3740
CBigNum bnProofOfStakeLegacyLimit(~uint256(0) >> 24); // proof of stake target limit from block #15000 and until 20 June 2013, results with 0,00390625 proof of stake difficulty
@@ -2689,19 +2692,29 @@ FILE* AppendBlockFile(unsigned int& nFileRet)
26892692

26902693
bool LoadBlockIndex(bool fAllowNew)
26912694
{
2695+
CBigNum bnTrustedModulus;
2696+
26922697
if (fTestNet)
26932698
{
26942699
pchMessageStart[0] = 0xcd;
26952700
pchMessageStart[1] = 0xf2;
26962701
pchMessageStart[2] = 0xc0;
26972702
pchMessageStart[3] = 0xef;
26982703

2704+
bnTrustedModulus.SetHex("f0d14cf72623dacfe738d0892b599be0f31052239cddd95a3f25101c801dc990453b38c9434efe3f372db39a32c2bb44cbaea72d62c8931fa785b0ec44531308df3e46069be5573e49bb29f4d479bfc3d162f57a5965db03810be7636da265bfced9c01a6b0296c77910ebdc8016f70174f0f18a57b3b971ac43a934c6aedbc5c866764a3622b5b7e3f9832b8b3f133c849dbcc0396588abcd1e41048555746e4823fb8aba5b3d23692c6857fccce733d6bb6ec1d5ea0afafecea14a0f6f798b6b27f77dc989c557795cc39a0940ef6bb29a7fc84135193a55bcfc2f01dd73efad1b69f45a55198bd0e6bef4d338e452f6a420f1ae2b1167b923f76633ab6e55");
26992705
bnProofOfWorkLimit = bnProofOfWorkLimitTestNet; // 16 bits PoW target limit for testnet
27002706
nStakeMinAge = 2 * 60 * 60; // test net min age is 2 hours
27012707
nModifierInterval = 20 * 60; // test modifier interval is 20 minutes
27022708
nCoinbaseMaturity = 10; // test maturity is 10 blocks
27032709
nStakeTargetSpacing = 5 * 60; // test block spacing is 5 minutes
27042710
}
2711+
else
2712+
{
2713+
bnTrustedModulus.SetHex("d01f952e1090a5a72a3eda261083256596ccc192935ae1454c2bafd03b09e6ed11811be9f3a69f5783bbbced8c6a0c56621f42c2d19087416facf2f13cc7ed7159d1c5253119612b8449f0c7f54248e382d30ecab1928dbf075c5425dcaee1a819aa13550e0f3227b8c685b14e0eae094d65d8a610a6f49fff8145259d1187e4c6a472fa5868b2b67f957cb74b787f4311dbc13c97a2ca13acdb876ff506ebecbb904548c267d68868e07a32cd9ed461fbc2f920e9940e7788fed2e4817f274df5839c2196c80abe5c486df39795186d7bc86314ae1e8342f3c884b158b4b05b4302754bf351477d35370bad6639b2195d30006b77bf3dbb28b848fd9ecff5662bf39dde0c974e83af51b0d3d642d43834827b8c3b189065514636b8f2a59c42ba9b4fc4975d4827a5d89617a3873e4b377b4d559ad165748632bd928439cfbc5a8ef49bc2220e0b15fb0aa302367d5e99e379a961c1bc8cf89825da5525e3c8f14d7d8acca2fa9c133a2176ae69874d8b1d38b26b9c694e211018005a97b40848681b9dd38feb2de141626fb82591aad20dc629b2b6421cef1227809551a0e4e943ab99841939877f18f2d9c0addc93cf672e26b02ed94da3e6d329e8ac8f3736eebbf37bb1a21e5aadf04ee8e3b542f876aa88b2adf2608bd86329b7f7a56fd0dc1c40b48188731d11082aea360c62a0840c2db3dad7178fd7e359317ae081");
2714+
}
2715+
2716+
// Set up the Zerocoin Params object
2717+
ZCParams = new libzerocoin::Params(bnTrustedModulus);
27052718

27062719
//
27072720
// Load block index

src/main.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "net.h"
1111
#include "script.h"
1212
#include "scrypt.h"
13+
#include "zerocoin/Zerocoin.h"
1314

1415
#include <list>
1516

@@ -57,12 +58,10 @@ static const int fHaveUPnP = false;
5758

5859
static const uint256 hashGenesisBlock("0x00000a060336cbb72fe969666d337b87198b1add2abaa59cca226820b32933a4");
5960
static const uint256 hashGenesisBlockTestNet("0x000c763e402f2436da9ed36c7286f62c3f6e5dbafce9ff289bd43d7459327eb");
60-
6161
static const int64 nMaxClockDrift = 2 * 60 * 60; // two hours
6262

63+
extern libzerocoin::Params* ZCParams;
6364
extern CScript COINBASE_FLAGS;
64-
65-
6665
extern CCriticalSection cs_main;
6766
extern std::map<uint256, CBlockIndex*> mapBlockIndex;
6867
extern std::set<std::pair<COutPoint, unsigned int> > setStakeSeen;
@@ -532,7 +531,7 @@ class CTransaction
532531
bool IsCoinStake() const
533532
{
534533
// ppcoin: the coin stake transaction is marked with the first output empty
535-
return (vin.size() > 0 && (!vin[0].prevout.IsNull()) && vout.size() >= 2 && vout[0].IsEmpty());
534+
return (vin.size() > 0 && (!vin[0].prevout.IsNull()) && vout.size() >= 2 && vout[0].IsEmpty() && !vout[1].IsEmpty());
536535
}
537536

538537
/** Check for standard transaction types

src/zerocoin/Accumulator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class Accumulator {
4343
* @param d the denomination of coins we are accumulating
4444
* @throw Zerocoin exception in case of invalid parameters
4545
**/
46-
Accumulator(const AccumulatorAndProofParams* p, const CoinDenomination d = ZQ_LOVELACE);
46+
Accumulator(const AccumulatorAndProofParams* p, const CoinDenomination d = ZQ_PEDERSEN);
4747

48-
Accumulator(const Params* p, const CoinDenomination d = ZQ_LOVELACE);
48+
Accumulator(const Params* p, const CoinDenomination d = ZQ_PEDERSEN);
4949

5050
/**
5151
* Accumulate a coin into the accumulator. Validates

src/zerocoin/Coin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace libzerocoin {
1717

1818
//PublicCoin class
1919
PublicCoin::PublicCoin(const Params* p):
20-
params(p), denomination(ZQ_LOVELACE) {
20+
params(p), denomination(ZQ_PEDERSEN) {
2121
if(this->params->initialized == false) {
2222
throw std::invalid_argument("Params are not initialized");
2323
}

src/zerocoin/Coin.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class PublicCoin {
4545
*
4646
* @param p cryptographic paramters
4747
* @param coin the value of the commitment.
48-
* @param denomination The denomination of the coin. Defaults to ZQ_LOVELACE
48+
* @param denomination The denomination of the coin. Defaults to ZQ_PEDERSEN
4949
*/
50-
PublicCoin( const Params* p, const Bignum& coin, const CoinDenomination d = ZQ_LOVELACE);
50+
PublicCoin( const Params* p, const Bignum& coin, const CoinDenomination d = ZQ_PEDERSEN);
5151
const Bignum& getValue() const;
5252
const CoinDenomination getDenomination() const;
5353
bool operator==(const PublicCoin& rhs) const;
@@ -88,7 +88,7 @@ class PrivateCoin {
8888
PrivateCoin(const Params* p, Stream& strm): params(p) {
8989
strm >> *this;
9090
}
91-
PrivateCoin(const Params* p,const CoinDenomination denomination = ZQ_LOVELACE);
91+
PrivateCoin(const Params* p,const CoinDenomination denomination = ZQ_PEDERSEN);
9292
const PublicCoin& getPublicCoin() const;
9393
const Bignum& getSerialNumber() const;
9494
const Bignum& getRandomness() const;

src/zerocoin/CoinSpend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace libzerocoin {
3232
class CoinSpend {
3333
public:
3434
template<typename Stream>
35-
CoinSpend(const Params* p, Stream& strm):denomination(ZQ_LOVELACE),
35+
CoinSpend(const Params* p, Stream& strm):denomination(ZQ_PEDERSEN),
3636
accumulatorPoK(&p->accumulatorParams),
3737
serialNumberSoK(p),
3838
commitmentPoK(&p->serialNumberSoKCommitmentGroup, &p->accumulatorParams.accumulatorPoKCommitmentGroup) {

0 commit comments

Comments
 (0)