Text this: Mathematical Foundations for Side-Channel Analysis of Cryptographic Systems