Their documentation at http://www.lilypond.org/doc/v2.18/Documentation/learning/accidentals-and-key-signatures (in the section Warning: key signatures and pitches) states
key signature only affects the printed accidentals, not the note’s pitch!
It seems that Lilypond equates a note name with a particular pitch - you have to add the relevant suffix ('es' or 'is') to lower or raise the pitch, regardless of key signature.
So the two files above would be expected to generate the same midi file,files with the same midi note numbers.