How was the magic network ID value chosen?

16

4

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

jl6

Posted 2011-12-29T13:13:26.477

Reputation: 1 219

1

Also check this answer.

karask 2016-03-04T21:09:41.103

Answers

24

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 };

jarpiain

Posted 2011-12-29T13:13:26.477

Reputation: 796

1

Actually, also see this answer.

karask 2016-03-04T21:06:53.057

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 2016-03-05T09:46:27.460

@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 2017-12-12T05:46:08.307

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.

Richard Anthony Hein

Posted 2011-12-29T13:13:26.477

Reputation: 111

2How do you know that it was chosen for that reason?Nick ODell 2017-03-30T22:37:12.320

1

@NickODell He knows because he is either Satoshi, or a savant. Otherwise he simply pasted the number into WA https://www.wolframalpha.com/input/?i=4190024921

I'll let you decide the likeliest scenario.

DenisM 2018-05-08T19:11:29.883

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 Anthony Hein 2018-05-15T01:05:59.223