public static function generateSeed(NetworkInterface $network, $length = self::RECOMMENDED_SEED_BYTES)
    {
        // Per [BIP32], the seed must be in range [16, 64].
        if (($length < static::MIN_SEED_BYTES) || ($length > static::MAX_SEED_BYTES)) {
            throw new \InvalidArgumentException(
                'Invalid seed length. Length should be between 16 and 64 bytes (32 recommended).'
            );
        }

        $seed = random_bytes($length);

        while (!static::verifySeed($seed, $network)) {
            // @codeCoverageIgnoreStart
            $seed = random_bytes($length);
            // @codeCoverageIgnoreEnd
        }

        return $seed;
    }