code: public byte findRecoveryId(Sha256Hash hash, ECDSASignature sig) {
          byte recId = -1;
          for (byte i = 0; i < 4; i++) {
              ECKey k = ECKey.recoverFromSignature(i, sig, hash, isCompressed());
              if (k != null && k.pub.equals(pub)) {
                  recId = i;
                  break;
              }
          }
          if (recId == -1)
              throw new RuntimeException("Could not construct a recoverable key. This should never happen.");
          return recId;
      }
docs: Returns the recovery ID, a byte with value between 0 and 3, inclusive, that specifies which of 4 possible
  curve points was used to sign a message. This value is also referred to as "v".
  
  @throws RuntimeException if no recovery ID can be found.