26 throw std::runtime_error(
"Params are not initialized");
33 params(p), value(coin), denomination(d) {
35 throw std::runtime_error(
"Params are not initialized");
38 throw std::runtime_error(
"Denomination does not exist");
45 return error(
"%s: ERROR: PublicCoin::validate value is too low: %s", __func__,
value.
GetDec());
49 return error(
"%s: ERROR: PublicCoin::validate value is too high, max: %s, received: %s",
54 return error(
"%s: ERROR: PublicCoin::validate value is not prime. Value: %s, Iterations: %d",
67 return PUBKEY_VERSION;
68 }
catch (
const std::range_error& e) {
83 return bnSerialAdjusted;
98 return bnSerial.
bitSize() <= 256;
PublicCoin class for the Zerocoin library.
Commitment and CommitmentProof classes for the Zerocoin library.
arith_uint256 UintToArith256(const uint256 &a)
uint256 ArithToUint256(const arith_uint256 &a)
const arith_uint256 ARITH_UINT256_ZERO
const CBigNum BN_ZERO
constant bignum instances
bool isPrime(const int checks=15) const
Miller-Rabin primality test on this element.
arith_uint256 getuint256() const
std::string GetDec() const
int bitSize() const
Returns the size in bits of the underlying bignum.
void setuint256(uint256 n)
An encapsulated public key.
const unsigned char * end() const
const unsigned char * begin() const
256-bit unsigned big integer.
CBigNum maxCoinValue
Upper bound on the value for a committed coin.
CBigNum minCoinValue
Lower bound on the value for committed coin.
CBigNum groupOrder
The order of the group.
CBigNum modulus
The modulus for the group.
const ZerocoinParams * params
bool validate() const
Checks that coin is prime and in the appropriate range given the parameters.
PublicCoin(const ZerocoinParams *p, Stream &strm)
CoinDenomination denomination
IntegerGroupParams coinCommitmentGroup
The Quadratic Residue group from which we form a coin as a commitment to a serial number.
AccumulatorAndProofParams accumulatorParams
IntegerGroupParams serialNumberSoKCommitmentGroup
One of two groups used to form a commitment to a coin (which it self is a commitment to a serial numb...
uint32_t zkp_iterations
The number of iterations to use in the serial number proof.
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
bool IsValidSerial(const ZerocoinParams *params, const CBigNum &bnSerial)
bool IsValidCommitmentToCoinRange(const ZerocoinParams *params, const CBigNum &bnCommitment)
CBigNum GetAdjustedSerial(const CBigNum &bnSerial)
int ExtractVersionFromSerial(const CBigNum &bnSerial)
CBigNum ExtractSerialFromPubKey(const CPubKey pubkey)
bool error(const char *fmt, const Args &... args)