/**
   * * generate password scheme either a) during initialization or b) after successful login
   *
   * @param hpwd
   * @param positions
   * @param password
   */
  private static void generateScheme(BigInteger hpwd, Position[] positions, String password) {
    /* generate new random polynomial */
    Polynomial newPoly = Polynomial.getRandomPolynomial(Constants.M - 1, hpwd);

    /* generate new R value and persist */
    Generator.R = Generator.getRandomInteger(Generator.BIT_LENGTH);
    LoginHandler.getPreferences().put(Constants.PREF_R, Generator.R.toString());

    /* reinitialize P and G functions with new R value */
    initFunctions(password);

    /* generate new Instruction Table and write to file */
    InstructionTable iTable = InstructionTable.generateInstructionTable(positions, newPoly);
    iTable.writeToFile(Constants.INSTRUCTION_TABLE_FILE_PATH);
  }