Commit 73cf414a authored by barrystyle's avatar barrystyle

zerocoin removal squashed

parent f856a036
...@@ -29,7 +29,6 @@ LIBBITCOIN_CLI=libbitcoin_cli.a ...@@ -29,7 +29,6 @@ LIBBITCOIN_CLI=libbitcoin_cli.a
LIBBITCOIN_UTIL=libbitcoin_util.a LIBBITCOIN_UTIL=libbitcoin_util.a
LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
LIBBITCOIN_UNIVALUE=univalue/libbitcoin_univalue.a LIBBITCOIN_UNIVALUE=univalue/libbitcoin_univalue.a
LIBBITCOIN_ZEROCOIN=libzerocoin/libbitcoin_zerocoin.a
LIBBITCOINQT=qt/libbitcoinqt.a LIBBITCOINQT=qt/libbitcoinqt.a
LIBSECP256K1=secp256k1/libsecp256k1.la LIBSECP256K1=secp256k1/libsecp256k1.la
...@@ -43,7 +42,6 @@ EXTRA_LIBRARIES = \ ...@@ -43,7 +42,6 @@ EXTRA_LIBRARIES = \
libbitcoin_util.a \ libbitcoin_util.a \
libbitcoin_common.a \ libbitcoin_common.a \
univalue/libbitcoin_univalue.a \ univalue/libbitcoin_univalue.a \
libzerocoin/libbitcoin_zerocoin.a \
libbitcoin_server.a \ libbitcoin_server.a \
libbitcoin_cli.a libbitcoin_cli.a
if ENABLE_WALLET if ENABLE_WALLET
...@@ -98,10 +96,8 @@ BITCOIN_CORE_H = \ ...@@ -98,10 +96,8 @@ BITCOIN_CORE_H = \
compressor.h \ compressor.h \
primitives/block.h \ primitives/block.h \
primitives/transaction.h \ primitives/transaction.h \
primitives/zerocoin.h \
core_io.h \ core_io.h \
crypter.h \ crypter.h \
denomination_functions.h \
obfuscation.h \ obfuscation.h \
obfuscation-relay.h \ obfuscation-relay.h \
db.h \ db.h \
...@@ -242,7 +238,6 @@ libbitcoin_wallet_a_CPPFLAGS = $(BITCOIN_INCLUDES) ...@@ -242,7 +238,6 @@ libbitcoin_wallet_a_CPPFLAGS = $(BITCOIN_INCLUDES)
libbitcoin_wallet_a_SOURCES = \ libbitcoin_wallet_a_SOURCES = \
activemasternode.cpp \ activemasternode.cpp \
bip38.cpp \ bip38.cpp \
denomination_functions.cpp \
obfuscation.cpp \ obfuscation.cpp \
obfuscation-relay.cpp \ obfuscation-relay.cpp \
db.cpp \ db.cpp \
...@@ -255,7 +250,6 @@ libbitcoin_wallet_a_SOURCES = \ ...@@ -255,7 +250,6 @@ libbitcoin_wallet_a_SOURCES = \
masternodeconfig.cpp \ masternodeconfig.cpp \
masternodeman.cpp \ masternodeman.cpp \
rpcdump.cpp \ rpcdump.cpp \
primitives/zerocoin.cpp \
rpcwallet.cpp \ rpcwallet.cpp \
kernel.cpp \ kernel.cpp \
wallet.cpp \ wallet.cpp \
...@@ -297,8 +291,8 @@ crypto_libbitcoin_crypto_a_SOURCES = \ ...@@ -297,8 +291,8 @@ crypto_libbitcoin_crypto_a_SOURCES = \
crypto/argon2d/thread.h \ crypto/argon2d/thread.h \
crypto/blake2/blake2b.c \ crypto/blake2/blake2b.c \
crypto/blake2/blake2.h \ crypto/blake2/blake2.h \
crypto/blake2/blake2-impl.h \ crypto/blake2/blake2-impl.h \
crypto/blake2/blamka-round-opt.h crypto/blake2/blamka-round-opt.h
# univalue JSON library # univalue JSON library
univalue_libbitcoin_univalue_a_SOURCES = \ univalue_libbitcoin_univalue_a_SOURCES = \
...@@ -308,29 +302,6 @@ univalue_libbitcoin_univalue_a_SOURCES = \ ...@@ -308,29 +302,6 @@ univalue_libbitcoin_univalue_a_SOURCES = \
univalue/univalue_escapes.h \ univalue/univalue_escapes.h \
univalue/univalue.h univalue/univalue.h
# libzerocoin library
libzerocoin_libbitcoin_zerocoin_a_SOURCES = \
libzerocoin/Accumulator.h \
libzerocoin/AccumulatorProofOfKnowledge.h \
libzerocoin/bignum.h \
libzerocoin/Coin.h \
libzerocoin/CoinSpend.h \
libzerocoin/Commitment.h \
libzerocoin/Denominations.h \
libzerocoin/ParamGeneration.h \
libzerocoin/Params.h \
libzerocoin/SerialNumberSignatureOfKnowledge.h \
libzerocoin/ZerocoinDefines.h \
libzerocoin/Accumulator.cpp \
libzerocoin/AccumulatorProofOfKnowledge.cpp \
libzerocoin/Coin.cpp \
libzerocoin/Denominations.cpp \
libzerocoin/CoinSpend.cpp \
libzerocoin/Commitment.cpp \
libzerocoin/ParamGeneration.cpp \
libzerocoin/Params.cpp \
libzerocoin/SerialNumberSignatureOfKnowledge.cpp
# common: shared between merged, and merge-qt and non-server tools # common: shared between merged, and merge-qt and non-server tools
libbitcoin_common_a_CPPFLAGS = $(BITCOIN_INCLUDES) libbitcoin_common_a_CPPFLAGS = $(BITCOIN_INCLUDES)
libbitcoin_common_a_SOURCES = \ libbitcoin_common_a_SOURCES = \
...@@ -343,7 +314,6 @@ libbitcoin_common_a_SOURCES = \ ...@@ -343,7 +314,6 @@ libbitcoin_common_a_SOURCES = \
compressor.cpp \ compressor.cpp \
primitives/block.cpp \ primitives/block.cpp \
primitives/transaction.cpp \ primitives/transaction.cpp \
primitives/zerocoin.cpp \
core_read.cpp \ core_read.cpp \
core_write.cpp \ core_write.cpp \
eccryptoverify.cpp \ eccryptoverify.cpp \
......
...@@ -47,14 +47,12 @@ QT_FORMS_UI = \ ...@@ -47,14 +47,12 @@ QT_FORMS_UI = \
qt/forms/optionsdialog.ui \ qt/forms/optionsdialog.ui \
qt/forms/overviewpage.ui \ qt/forms/overviewpage.ui \
qt/forms/receivecoinsdialog.ui \ qt/forms/receivecoinsdialog.ui \
qt/forms/privacydialog.ui \
qt/forms/receiverequestdialog.ui \ qt/forms/receiverequestdialog.ui \
qt/forms/rpcconsole.ui \ qt/forms/rpcconsole.ui \
qt/forms/sendcoinsdialog.ui \ qt/forms/sendcoinsdialog.ui \
qt/forms/sendcoinsentry.ui \ qt/forms/sendcoinsentry.ui \
qt/forms/signverifymessagedialog.ui \ qt/forms/signverifymessagedialog.ui \
qt/forms/transactiondescdialog.ui \ qt/forms/transactiondescdialog.ui
qt/forms/zpivcontroldialog.ui
QT_MOC_CPP = \ QT_MOC_CPP = \
qt/moc_addressbookpage.cpp \ qt/moc_addressbookpage.cpp \
...@@ -89,7 +87,6 @@ QT_MOC_CPP = \ ...@@ -89,7 +87,6 @@ QT_MOC_CPP = \
qt/moc_qvalidatedlineedit.cpp \ qt/moc_qvalidatedlineedit.cpp \
qt/moc_qvaluecombobox.cpp \ qt/moc_qvaluecombobox.cpp \
qt/moc_receivecoinsdialog.cpp \ qt/moc_receivecoinsdialog.cpp \
qt/moc_privacydialog.cpp \
qt/moc_receiverequestdialog.cpp \ qt/moc_receiverequestdialog.cpp \
qt/moc_recentrequeststablemodel.cpp \ qt/moc_recentrequeststablemodel.cpp \
qt/moc_rpcconsole.cpp \ qt/moc_rpcconsole.cpp \
...@@ -106,8 +103,7 @@ QT_MOC_CPP = \ ...@@ -106,8 +103,7 @@ QT_MOC_CPP = \
qt/moc_utilitydialog.cpp \ qt/moc_utilitydialog.cpp \
qt/moc_walletframe.cpp \ qt/moc_walletframe.cpp \
qt/moc_walletmodel.cpp \ qt/moc_walletmodel.cpp \
qt/moc_walletview.cpp \ qt/moc_walletview.cpp
qt/moc_zpivcontroldialog.cpp
BITCOIN_MM = \ BITCOIN_MM = \
qt/macdockiconhandler.mm \ qt/macdockiconhandler.mm \
...@@ -166,7 +162,6 @@ BITCOIN_QT_H = \ ...@@ -166,7 +162,6 @@ BITCOIN_QT_H = \
qt/qvalidatedlineedit.h \ qt/qvalidatedlineedit.h \
qt/qvaluecombobox.h \ qt/qvaluecombobox.h \
qt/receivecoinsdialog.h \ qt/receivecoinsdialog.h \
qt/privacydialog.h \
qt/receiverequestdialog.h \ qt/receiverequestdialog.h \
qt/recentrequeststablemodel.h \ qt/recentrequeststablemodel.h \
qt/rpcconsole.h \ qt/rpcconsole.h \
...@@ -186,8 +181,7 @@ BITCOIN_QT_H = \ ...@@ -186,8 +181,7 @@ BITCOIN_QT_H = \
qt/walletmodel.h \ qt/walletmodel.h \
qt/walletmodeltransaction.h \ qt/walletmodeltransaction.h \
qt/walletview.h \ qt/walletview.h \
qt/winshutdownmonitor.h \ qt/winshutdownmonitor.h
qt/zpivcontroldialog.h
RES_ICONS = \ RES_ICONS = \
qt/res/icons/add.png \ qt/res/icons/add.png \
...@@ -227,7 +221,6 @@ RES_ICONS = \ ...@@ -227,7 +221,6 @@ RES_ICONS = \
qt/res/icons/qrcode.png \ qt/res/icons/qrcode.png \
qt/res/icons/quit.png \ qt/res/icons/quit.png \
qt/res/icons/receive.png \ qt/res/icons/receive.png \
qt/res/icons/privacy.png \
qt/res/icons/remove.png \ qt/res/icons/remove.png \
qt/res/icons/send.png \ qt/res/icons/send.png \
qt/res/icons/staking_active.png \ qt/res/icons/staking_active.png \
...@@ -292,7 +285,6 @@ BITCOIN_QT_CPP += \ ...@@ -292,7 +285,6 @@ BITCOIN_QT_CPP += \
qt/paymentrequestplus.cpp \ qt/paymentrequestplus.cpp \
qt/paymentserver.cpp \ qt/paymentserver.cpp \
qt/receivecoinsdialog.cpp \ qt/receivecoinsdialog.cpp \
qt/privacydialog.cpp \
qt/receiverequestdialog.cpp \ qt/receiverequestdialog.cpp \
qt/recentrequeststablemodel.cpp \ qt/recentrequeststablemodel.cpp \
qt/sendcoinsdialog.cpp \ qt/sendcoinsdialog.cpp \
...@@ -307,8 +299,7 @@ BITCOIN_QT_CPP += \ ...@@ -307,8 +299,7 @@ BITCOIN_QT_CPP += \
qt/walletframe.cpp \ qt/walletframe.cpp \
qt/walletmodel.cpp \ qt/walletmodel.cpp \
qt/walletmodeltransaction.cpp \ qt/walletmodeltransaction.cpp \
qt/walletview.cpp \ qt/walletview.cpp
qt/zpivcontroldialog.cpp
endif endif
......
// Copyright (c) 2017 The PIVX developers
// Copyright (c) 2018 -2019 MERGE Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "accumulatormap.h"
#include "accumulators.h"
#include "main.h"
#include "txdb.h"
#include "libzerocoin/Denominations.h"
using namespace libzerocoin;
using namespace std;
//Construct accumulators for all denominations
AccumulatorMap::AccumulatorMap()
{
for (auto& denom : zerocoinDenomList) {
unique_ptr<Accumulator> uptr(new Accumulator(Params().Zerocoin_Params(), denom));
mapAccumulators.insert(make_pair(denom, std::move(uptr)));
}
}
//Reset each accumulator to its default state
void AccumulatorMap::Reset()
{
mapAccumulators.clear();
for (auto& denom : zerocoinDenomList) {
unique_ptr<Accumulator> uptr(new Accumulator(Params().Zerocoin_Params(), denom));
mapAccumulators.insert(make_pair(denom, std::move(uptr)));
}
}
//Load a checkpoint containing 8 32bit checksums of accumulator values.
bool AccumulatorMap::Load(uint256 nCheckpoint)
{
for (auto& denom : zerocoinDenomList) {
uint32_t nChecksum = ParseChecksum(nCheckpoint, denom);
CBigNum bnValue;
if (!zerocoinDB->ReadAccumulatorValue(nChecksum, bnValue)) {
LogPrintf("%s : cannot find checksum %d", __func__, nChecksum);
return false;
}
mapAccumulators.at(denom)->setValue(bnValue);
}
return true;
}
//Add a zerocoin to the accumulator of its denomination.
bool AccumulatorMap::Accumulate(PublicCoin pubCoin, bool fSkipValidation)
{
CoinDenomination denom = pubCoin.getDenomination();
if (denom == CoinDenomination::ZQ_ERROR)
return false;
if (fSkipValidation)
mapAccumulators.at(denom)->increment(pubCoin.getValue());
else
mapAccumulators.at(denom)->accumulate(pubCoin);
return true;
}
//Get the value of a specific accumulator
CBigNum AccumulatorMap::GetValue(CoinDenomination denom)
{
if (denom == CoinDenomination::ZQ_ERROR)
return CBigNum(0);
return mapAccumulators.at(denom)->getValue();
}
//Calculate a 32bit checksum of each accumulator value. Concatenate checksums into uint256
uint256 AccumulatorMap::GetCheckpoint()
{
uint256 nCheckpoint;
//Prevent possible overflows from future changes to the list and forgetting to update this code
assert(zerocoinDenomList.size() == 8);
for (auto& denom : zerocoinDenomList) {
CBigNum bnValue = mapAccumulators.at(denom)->getValue();
uint32_t nCheckSum = GetChecksum(bnValue);
nCheckpoint = nCheckpoint << 32 | nCheckSum;
}
return nCheckpoint;
}
// Copyright (c) 2017 The PIVX developers
// Copyright (c) 2018 -2019 MERGE Developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef MERGE_ACCUMULATORMAP_H
#define MERGE_ACCUMULATORMAP_H
#include "libzerocoin/Accumulator.h"
#include "libzerocoin/Coin.h"
//A map with an accumulator for each denomination
class AccumulatorMap
{
private:
std::map<libzerocoin::CoinDenomination, std::unique_ptr<libzerocoin::Accumulator> > mapAccumulators;
public:
AccumulatorMap();
bool Load(uint256 nCheckpoint);
bool Accumulate(libzerocoin::PublicCoin pubCoin, bool fSkipValidation = false);
CBigNum GetValue(libzerocoin::CoinDenomination denom);
uint256 GetCheckpoint();
void Reset();
};
#endif //MERGE_ACCUMULATORMAP_H
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "tinyformat.h" #include "tinyformat.h"
#include "uint256.h" #include "uint256.h"
#include "util.h" #include "util.h"
#include "libzerocoin/Denominations.h"
#include <vector> #include <vector>
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
// Distributed under the MIT software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "libzerocoin/Params.h"
#include "chainparams.h" #include "chainparams.h"
#include "random.h" #include "random.h"
#include "util.h" #include "util.h"
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include "protocol.h" #include "protocol.h"
#include "uint256.h" #include "uint256.h"
#include "libzerocoin/Params.h"
#include <vector> #include <vector>
typedef unsigned char MessageStartChars[MESSAGE_START_SIZE]; typedef unsigned char MessageStartChars[MESSAGE_START_SIZE];
......
This diff is collapsed.
/**
* @file denominations_functions.h
*
* @brief Denomination functions for the Zerocoin library.
*
* @copyright Copyright 2017 PIVX Developers
* @license This project is released under the MIT license.
**/
// Copyright (c) 2015-2018 PIVX Developers
// Copyright (c) 2018 -2019 MERGE Developers
#include "reverse_iterate.h"
#include "util.h"
#include "libzerocoin/Denominations.h"
#include "primitives/zerocoin.h"
#include <list>
#include <map>
std::vector<CZerocoinMint> SelectMintsFromList(const CAmount nValueTarget, CAmount& nSelectedValue,
int nMaxNumberOfSpends,
bool fMinimizeChange,
int& nCoinsReturned,
const std::list<CZerocoinMint>& listMints,
const std::map<libzerocoin::CoinDenomination, CAmount> mapDenomsHeld,
int& nNeededSpends
);
int calculateChange(
int nMaxNumberOfSpends,
bool fMinimizeChange,
const CAmount nValueTarget,
const std::map<libzerocoin::CoinDenomination, CAmount>& mapOfDenomsHeld,
std::map<libzerocoin::CoinDenomination, CAmount>& mapOfDenomsUsed);
void listSpends(const std::vector<CZerocoinMint>& vSelectedMints);
...@@ -1669,20 +1669,8 @@ bool AppInit2(boost::thread_group& threadGroup) ...@@ -1669,20 +1669,8 @@ bool AppInit2(boost::thread_group& threadGroup)
nPreferredDenom = 0; nPreferredDenom = 0;
} }
// XX42 Remove/refactor code below. Until then provide safe defaults
nAnonymizeMergeAmount = 2; nAnonymizeMergeAmount = 2;
// nLiquidityProvider = GetArg("-liquidityprovider", 0); //0-100
// if (nLiquidityProvider != 0) {
// obfuScationPool.SetMinBlockSpacing(std::min(nLiquidityProvider, 100) * 15);
// fEnableZeromint = true;
// nZeromintPercentage = 99999;
// }
//
// nAnonymizeMergeAmount = GetArg("-anonymizemergeamount", 0);
// if (nAnonymizeMergeAmount > 999999) nAnonymizeMergeAmount = 999999;
// if (nAnonymizeMergeAmount < 2) nAnonymizeMergeAmount = 2;
fEnableSwiftTX = GetBoolArg("-enableswifttx", fEnableSwiftTX); fEnableSwiftTX = GetBoolArg("-enableswifttx", fEnableSwiftTX);
nSwiftTXDepth = GetArg("-swifttxdepth", nSwiftTXDepth); nSwiftTXDepth = GetArg("-swifttxdepth", nSwiftTXDepth);
nSwiftTXDepth = std::min(std::max(nSwiftTXDepth, 0), 60); nSwiftTXDepth = std::min(std::max(nSwiftTXDepth, 0), 60);
......
/**
* @file Accumulator.cpp
*
* @brief Accumulator and AccumulatorWitness classes for the Zerocoin library.
*
* @author Ian Miers, Christina Garman and Matthew Green
* @date June 2013
*
* @copyright Copyright 2013 Ian Miers, Christina Garman and Matthew Green
* @license This project is released under the MIT license.
**/
// Copyright (c) 2017 The PIVX developers
// Copyright (c) 2018 -2019 MERGE Developers
#include <sstream>
#include <iostream>
#include "Accumulator.h"
#include "ZerocoinDefines.h"
namespace libzerocoin {
//Accumulator class
Accumulator::Accumulator(const AccumulatorAndProofParams* p, const CoinDenomination d): params(p) {
if (!(params->initialized)) {
throw std::runtime_error("Invalid parameters for accumulator");
}
denomination = d;
this->value = this->params->accumulatorBase;
}
Accumulator::Accumulator(const ZerocoinParams* p, const CoinDenomination d, const Bignum bnValue) {
this->params = &(p->accumulatorParams);
denomination = d;
if (!(params->initialized)) {
throw std::runtime_error("Invalid parameters for accumulator");
}
if(bnValue != 0)
this->value = bnValue;
else
this->value = this->params->accumulatorBase;
}
void Accumulator::increment(const CBigNum& bnValue) {
// Compute new accumulator = "old accumulator"^{element} mod N
this->value = this->value.pow_mod(bnValue, this->params->accumulatorModulus);
}
void Accumulator::accumulate(const PublicCoin& coin) {
// Make sure we're initialized
if(!(this->value)) {
std::cout << "Accumulator is not initialized" << "\n";
throw std::runtime_error("Accumulator is not initialized");
}
if(this->denomination != coin.getDenomination()) {
std::cout << "Wrong denomination for coin. Expected coins of denomination: ";
std::cout << this->denomination;
std::cout << ". Instead, got a coin of denomination: ";
std::cout << coin.getDenomination();
std::cout << "\n";
throw std::runtime_error("Wrong denomination for coin");
}
if(coin.validate()) {
increment(coin.getValue());
} else {
std::cout << "Coin not valid\n";
throw std::runtime_error("Coin is not valid");
}
}
CoinDenomination Accumulator::getDenomination() const {
return this->denomination;
}
const CBigNum& Accumulator::getValue() const {
return this->value;
}
//Manually set accumulator value
void Accumulator::setValue(CBigNum bnValue) {
this->value = bnValue;
}
Accumulator& Accumulator::operator += (const PublicCoin& c) {
this->accumulate(c);
return *this;
}
Accumulator& Accumulator::operator = (Accumulator rhs) {
if (this != &rhs) std::swap(*this, rhs);
return *this;
}
bool Accumulator::operator == (const Accumulator rhs) const {
return this->value == rhs.value;
}
//AccumulatorWitness class
AccumulatorWitness::AccumulatorWitness(const ZerocoinParams* p,
const Accumulator& checkpoint, const PublicCoin coin): witness(checkpoint), element(coin) {
}
void AccumulatorWitness::resetValue(const Accumulator& checkpoint, const PublicCoin coin) {
this->witness.setValue(checkpoint.getValue());
this->element = coin;
}
void AccumulatorWitness::AddElement(const PublicCoin& c) {
if(element != c) {
witness += c;
}
}
//warning check pubcoin value & denom outside of this function!
void AccumulatorWitness::addRawValue(const CBigNum& bnValue) {
witness.increment(bnValue);
}
const CBigNum& AccumulatorWitness::getValue() const {
return this->witness.getValue();
}
bool AccumulatorWitness::VerifyWitness(const Accumulator& a, const PublicCoin &publicCoin) const {
Accumulator temp(witness);
temp += element;
return (temp == a && this->element == publicCoin);
}
AccumulatorWitness& AccumulatorWitness::operator +=(
const PublicCoin& rhs) {
this->AddElement(rhs);
return *this;
}
AccumulatorWitness& AccumulatorWitness::operator =(AccumulatorWitness rhs) {
// Not pretty, but seems to work (SPOCK)
if (&witness != &rhs.witness) this->witness = rhs.witness;
if (&element != &rhs.element) std::swap(element, rhs.element);
return *this;
}
} /* namespace libzerocoin */
/**
* @file Accumulator.h
*
* @brief Accumulator and AccumulatorWitness classes for the Zerocoin library.
*
* @author Ian Miers, Christina Garman and Matthew Green
* @date June 2013
*
* @copyright Copyright 2013 Ian Miers, Christina Garman and Matthew Green
* @license This project is released under the MIT license.
**/
// Copyright (c) 2017 The PIVX developers
// Copyright (c) 2018 -2019 MERGE Developers
#ifndef ACCUMULATOR_H_
#define ACCUMULATOR_H_
#include "Coin.h"
namespace libzerocoin {
/**
* \brief Implementation of the RSA-based accumulator.
**/
class Accumulator {
public:
/**
* @brief Construct an Accumulator from a stream.
* @param p An AccumulatorAndProofParams object containing global parameters
* @param d the denomination of coins we are accumulating
* @throw Zerocoin exception in case of invalid parameters
**/
template<typename Stream>
Accumulator(const AccumulatorAndProofParams* p, Stream& strm): params(p) {
strm >> *this;
}
template<typename Stream>
Accumulator(const ZerocoinParams* p, Stream& strm) {
strm >> *this;
this->params = &(p->accumulatorParams);
}
/**
* @brief Construct an Accumulator from a Params object.
* @param p A Params object containing global parameters
* @param d the denomination of coins we are accumulating
* @throw Zerocoin exception in case of invalid parameters
**/
Accumulator(const AccumulatorAndProofParams* p, const CoinDenomination d);
Accumulator(const ZerocoinParams* p, const CoinDenomination d, Bignum bnValue = 0);
/**
* Accumulate a coin into the accumulator. Validates
* the coin prior to accumulation.
*
* @param coin A PublicCoin to accumulate.
*
* @throw Zerocoin exception if the coin is not valid.
*
**/
void accumulate(const PublicCoin &coin);
void increment(const CBigNum& bnValue);
CoinDenomination getDenomination() const;
/** Get the accumulator result
*
* @return a CBigNum containing the result.
*/
const CBigNum& getValue() const;
void setValue(CBigNum bnValue);
// /**
// * Used to set the accumulator value
// *
// * Use this to handle accumulator checkpoints
// * @param b the value to set the accumulator to.
// * @throw A ZerocoinException if the accumulator value is invalid.
// */
// void setValue(CBigNum &b); // shouldn't this be a constructor?
/** Used to accumulate a coin
*
* @param c the coin to accumulate
* @return a refrence to the updated accumulator.
*/
Accumulator& operator +=(const PublicCoin& c);
Accumulator& operator =(Accumulator rhs);
bool operator==(const Accumulator rhs) const;
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(value);
READWRITE(denomination);
}
private:
const AccumulatorAndProofParams* params;
CBigNum value;
CoinDenomination denomination;
};
/**A witness that a PublicCoin is in the accumulation of a set of coins
*
*/
class AccumulatorWitness {
public:
template<typename Stream>
AccumulatorWitness(const ZerocoinParams* p, Stream& strm) {
strm >> *this;
}
/** Construct's a witness. You must add all elements after the witness
* @param p pointer to params
* @param checkpoint the last known accumulator value before the element was added
* @param coin the coin we want a witness to
*/
AccumulatorWitness(const ZerocoinParams* p, const Accumulator& checkpoint, const PublicCoin coin);
/** Adds element to the set whose's accumulation we are proving coin is a member of
*
* @param c the coin to add
*/
void AddElement(const PublicCoin& c);