public boolean equalsKeyset(KeysetHandle other) {
    if (size() != other.size()) {
      return false;
    }
    boolean primaryFound = false;
    for (int i = 0; i < size(); ++i) {
      Entry thisEntry = entries.get(i);
      Entry otherEntry = other.entries.get(i);
      if (thisEntry == null) {
        // Can only happen for invalid keyset
        return false;
      }
      if (otherEntry == null) {
        // Can only happen for invalid keyset
        return false;
      }
      if (!thisEntry.equalsEntry(otherEntry)) {
        return false;
      }
      primaryFound |= thisEntry.isPrimary;
    }
    if (!primaryFound) {
      return false;
    }
    return true;
  }
Returns true if this keyset is equal to {@code other}, ignoring monitoring annotations.

<p>Note: this may return false even if the keysets represent the same set of functions. For
example, this can happen if the keys store zero-byte padding of a {@link java.math.BigInteger},
which are irrelevant to the function computed. Currently, keysets can also be invalid in which
case this will return false.
java_src/src/main/java/com/google/crypto/tink/KeysetHandle.java