If we're using the key cache optimization, we might reuse keys: we only guarantee that keys made with distinct values for idx are different. The value of idx must be at least 0, and less than N_PREGEN_KEYS.