Bitcoin

bitcoin core – What is the endianness of the target?

Endianness is a bigger source of confusion in Bitcoin than any other software project I’ve come across.

CPU

Some historically popular processors (68K, SPARC, PowerPC) were big-endian, but that’s no longer a thing.

Currently, most personal computers larger than pocket size use little-endian processors. Most processors have instructions to exchange byte sequences efficiently. for example bswap or rev. This kind of provision usually makes endianness relatively unimportant when considering efficiency.

Current ARM processor designs are called bi-endian. Both endians can work with equal efficiency.

Internet

Internet standards stipulate that data transmitted over the Internet must transmit numbers in big-endian order. But that’s not the case with Bitcoin. This too is a cause of confusion.

software

For most software development projects I’ve worked on, including heterogeneous network applications, endianness has not been an issue. Developers don’t even need to be endian-aware. The compiler takes care of this for you. Standard software libraries handle this.

Bitcoin Core is an exception to this. There are probably many others as well. But this is the only project I’ve come across where this is a big problem that often trips people up and causes confusion too often.

human

Most numbers displayed to humans in hexadecimal notation are displayed as big-endian. This means that the most significant digits are on the left, so in a left-to-right writing system, the offset, or positional index, for the most significant digits is the smallest.


conclusion

The order in which they appear in the hexadecimal representation may be aligned for human interpretation or, for example, aligned to match the network order. The context should make this clear.

Related Articles

Back to top button