@Override
 public int numKeys() {
   // We need to return here the total number of keys including the lookahead zone, not the number
   // of keys we
   // have issued via getKey/freshReceiveKey.
   lock.lock();
   try {
     maybeLookAhead();
     return basicKeyChain.numKeys();
   } finally {
     lock.unlock();
   }
 }