Seol mar théacs é seo: Mathematical Foundations for Side-Channel Analysis of Cryptographic Systems