Optimizing Embedded Systems Logic: Speeding Up Your Code with De Morgan's Law

2025-03-11

Two hackers, Bob and Alice, encountered a bug in their resource-constrained microcontroller: OR operations were five times slower than other operations. Facing a three-day deadline, they used logical equivalences, specifically De Morgan's Law, to rewrite their code, replacing OR operations with AND and NOT operations. This bypassed the performance bottleneck. The article further explores the universality of NAND operations and their application in optimizing cryptographic computations, such as significantly improving the efficiency of homomorphic encryption in the TFHE library.