Messages on the Bitcoin network are identified by the magic value 0xD9B4BEF9, and on the testnet by 0xDAB5BFFA. Why were these values chosen?

  • 1
    Also check this answer. – karask Mar 4 '16 at 21:09
up vote 21 down vote accepted

main.cpp carries this comment:

// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ascii, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };
  • 1
    Actually, also see this answer. – karask Mar 4 '16 at 21:06
  • I find the rational of the code comment interesting. I believe that unless you stream the blocks the probability of these bytes occurring in normal data is irrelevant. Since bitcoin communicates with TCP it doesn't make sense. Can anyone shed more light to this? – karask Mar 5 '16 at 9:46
  • @karask It could mean that Bitcoin itself was designed by a large corporation or government (someone with the means to watch packets going over the network in bulk.) That's the only context it likely gets streamed anyway. – CoryG Dec 12 '17 at 5:46

It was chosen because it is a prime number, and also because 4190024921 is the hypotenuse of a primitive Pythagorean triple: 4190024921^2 = 2924728880^2 + 3000378279^2

Edit: Note that you must consider byte order. The TCP protocol requires the number to be encoded in big-endian. 0xf9beb4d9 (little) = 0xd9b4bef9 (big)

See https://stackoverflow.com/a/13514942 for more info about that.

  • 2
    How do you know that it was chosen for that reason? – Nick ODell Mar 30 '17 at 22:37
  • 1
    @NickODell He knows because he is either Satoshi, or a savant. Otherwise he simply pasted the number into WA wolframalpha.com/input/?i=4190024921 I'll let you decide the likeliest scenario. – DenisM May 8 at 19:11
  • 1
    @DenisM ;) Satoshi was into numbers, so I was pretty sure it had some interesting property to it, and indeed, WA to the rescue. :) – Richard Hein May 15 at 1:05

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.