> The total number of possible extended keypairs is almost 2512, but the produced keys are only 256 bits long, and offer about half of that in terms of security. > Therefore, master keys are not generated directly, but instead from a potentially short seed value.
> Generate a seed byte sequence S of a chosen length (between 128 and 512 bits; 256 bits is advised) from a (P)RNG.
> * Calculate I = HMAC-SHA512(Key = "Bitcoin seed", Data = S)
> * Split I into two 32-byte sequences, IL and IR.
> * Use parse256(IL) as master secret key, and IR as master chain code.
> In case IL is 0 or ≥n, the master key is invalid.

https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#master-key-generation