message: [Test] wrapped serials: use multiple random values for K
diff: Covers the 'Wrapped Serials Attack' scenario
  '''
  +import random
  from time import sleep
  from test_framework.authproxy import JSONRPCException
  @@ -25,6 +26,8 @@ class zPIVwrappedSerialsTest(PIVX_FakeStakeTest):
  INITAL_MINED_BLOCKS = 351 # Blocks mined before minting
  MORE_MINED_BLOCKS = 31 # Blocks mined after minting (before spending)
  DENOM_TO_USE = 1000 # zc denomination used for double spending attack
  + K_BITSIZE = 128 # bitsize of the range for random K
  + NUM_OF_K = 5 # number of wrapping serials to try
  # 1) Start mining blocks
  self.log.info("Mining %d first blocks..." % INITAL_MINED_BLOCKS)
  @@ -71,12 +74,17 @@ class zPIVwrappedSerialsTest(PIVX_FakeStakeTest):
  self.node.generate(2)
  sleep(2)
  - # 6) create the new serial
  - serial = hex(int(zc[0]["s"], 16) + q*pow2)[2:]
  + # 6) create the new serials
  + new_serials = []
  + for i in range(NUM_OF_K):
  + K = random.getrandbits(K_BITSIZE)
  + new_serials.append(hex(int(zc[0]["s"], 16) + K*q*pow2)[2:])
  +
  randomness = zc[0]["r"]
  privkey = zc[0]["k"]
  - # 7) Spend the new zerocoin
  + # 7) Spend the new zerocoins
  + for serial in new_serials:
  self.log.info("Spending the wrapping serial %s" % serial)
  tx = None
  try:
  @@ -88,7 +96,6 @@ class zPIVwrappedSerialsTest(PIVX_FakeStakeTest):
  else:
  raise e
  - # 8) Check
  if tx is not None:
  self.log.warning("Tx is: %s" % tx)
  raise AssertionError("TEST FAILED")
  