/**
	* Validate the h value received from the receiver in the pre process phase.
	* @param trap the trapdoor outputed from the receiver's commit phase.
	* @return true, if valid; false, otherwise.
	*/
	bool validate(const shared_ptr<CmtRCommitPhaseOutput> & trap) {
		auto trapdoor = dynamic_pointer_cast<CmtRTrapdoorCommitPhaseOutput>(trap);
		if (!trapdoor)
			throw invalid_argument("the given trapdor should be an instance of CmtRTrapdoorCommitPhaseOutput");
		// check that g^trapdoor equals to h.
		auto gToTrap = dlog->exponentiate(dlog->getGenerator().get(), trapdoor->getTrap());
		return (*gToTrap == *h);
	}
Example #2
0
bool BaseAI::startTurn()
{
  static bool initialized = false;
  int count = 0;
  count = getPlayerCount(c);
  players.clear();
  players.resize(count);
  for(int i = 0; i < count; i++)
  {
    players[i] = Player(getPlayer(c, i));
  }

  count = getMappableCount(c);
  mappables.clear();
  mappables.resize(count);
  for(int i = 0; i < count; i++)
  {
    mappables[i] = Mappable(getMappable(c, i));
  }

  count = getTileCount(c);
  tiles.clear();
  tiles.resize(count);
  for(int i = 0; i < count; i++)
  {
    tiles[i] = Tile(getTile(c, i));
  }

  count = getTrapCount(c);
  traps.clear();
  traps.resize(count);
  for(int i = 0; i < count; i++)
  {
    traps[i] = Trap(getTrap(c, i));
  }

  count = getThiefCount(c);
  thiefs.clear();
  thiefs.resize(count);
  for(int i = 0; i < count; i++)
  {
    thiefs[i] = Thief(getThief(c, i));
  }

  count = getThiefTypeCount(c);
  thiefTypes.clear();
  thiefTypes.resize(count);
  for(int i = 0; i < count; i++)
  {
    thiefTypes[i] = ThiefType(getThiefType(c, i));
  }

  count = getTrapTypeCount(c);
  trapTypes.clear();
  trapTypes.resize(count);
  for(int i = 0; i < count; i++)
  {
    trapTypes[i] = TrapType(getTrapType(c, i));
  }

  if(!initialized)
  {
    initialized = true;
    init();
  }
  return run();
}