Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1ctaes2=====4Simple C module for constant-time AES encryption and decryption.6Features:7* Simple, pure C code without any dependencies.8* No tables or data-dependent branches whatsoever, but using bit sliced approach from https://eprint.iacr.org/2009/129.pdf.9* Very small object code: slightly over 4k of executable code when compiled with -Os.10* Slower than implementations based on precomputed tables or specialized instructions, but can do ~15 MB/s on modern CPUs.12Performance13-----------15Compiled with GCC 5.3.1 with -O3, on an Intel(R) Core(TM) i7-4800MQ CPU, numbers in CPU cycles:17| Algorithm | Key schedule | Encryption per byte | Decryption per byte |18| --------- | ------------:| -------------------:| -------------------:|19| AES-128 | 2.8k | 154 | 161 |20| AES-192 | 3.1k | 169 | 181 |21| AES-256 | 4.0k | 191 | 203 |23Build steps24-----------26Object code:28$ gcc -O3 ctaes.c -c -o ctaes.o30Tests:32$ gcc -O3 ctaes.c test.c -o test34Benchmark:36$ gcc -O3 ctaes.c bench.c -o bench38Review39------41Results of a formal review of the code can be found in http://bitcoin.sipa.be/ctaes/review.zip
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.