Can the chromosome names and lengths to which a bam file was aligned be determined solely from its bai file?
No. The BAI format is described in §5.2 of [SAMv1.pdf](http://samtools.github.io/hts-specs/SAMv1.pdf) and does not contain the chromosome names or lengths. Instead it merely identifies reference sequences by their index, 0 <= n < n_ref, in the corresponding BAM file's (binary) header.

The CSI format operates similarly.

The [Tabix format](https://samtools.github.io/hts-specs/tabix.pdf) OTOH does contain the names of reference sequences (but not their lengths).