17

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

1
  • 1
    Also check this answer.
    – karask
    Commented Mar 4, 2016 at 21:09

2 Answers 2

26

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 };
3
  • 1
    Actually, also see this answer.
    – karask
    Commented Mar 4, 2016 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
    Commented Mar 5, 2016 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
    Commented Dec 12, 2017 at 5:46
1

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.

Update: It is also a sum of squares.

4
  • 2
    How do you know that it was chosen for that reason?
    – Nick ODell
    Commented Mar 30, 2017 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
    Commented May 8, 2018 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. :) Commented May 15, 2018 at 1:05
  • @DenisM Why not both? Or all three? Bitcoin/Botcoin =::= Ying/Yang Commented Apr 26, 2021 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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