Verify that we can derive external branch 0 index address to check if seed is usable.

@param string            $seed
@param NetworkInterface  $network

@return ExtendedKey|bool Master key or false
487905
public static function verifySeed($seed, $network)
    {
        try {
            $master = static::newMaster($seed, $network);
            $coinType = $master->deriveCoinTypeKey();
            $account0 = $coinType->deriveAccountKey();
            $account0->neuter();
            $account0->deriveInternalBranch();
            $externalBranch = $account0->deriveExternalBranch();
            $externalBranch0 = $externalBranch->privateChildKey(0);
            $externalBranch0->getAddress();
            return $master;
        // @codeCoverageIgnoreStart
        } catch (\Exception $e) {
            return false;
        }
        // @codeCoverageIgnoreEnd
    }
136614
protected function isFulltextRoot(NodeInterface $node): bool
    {
        if ($node->getNodeType()->hasConfiguration('search')) {
            $elasticSearchSettingsForNode = $node->getNodeType()->getConfiguration('search');
            if (isset($elasticSearchSettingsForNode['fulltext']['isRoot']) && $elasticSearchSettingsForNode['fulltext']['isRoot'] === true) {
                return true;
            }
        }

        return false;
    }
749616
protected function createSeedRunner(
        IoInterface $inOut,
        string $seedsPath,
        callable $seedInit = null,
        string $seedsTable = BaseMigrationRunner::SEEDS_TABLE
    ): FileSeedRunner {
        return new FileSeedRunner($inOut, $seedsPath, $seedInit, $seedsTable);
    }
1301051
protected function parseMultilineValue($seed = '')
    {
        $closed = false;
        $lines = empty($seed) ? []: [$seed];

        while ($line = fgets($this->handle)) {
            $line = trim($line);
            $this->linenumber++;

            if ($this->closesQuote($line)) {
                $closed = true;
                $lines[] = rtrim($line, static::QUOTE_CHARS);
                break;
            } else {
                $lines[] = "$line\n";
            }

            unset($trimmed);
        }

        return ($closed) ? join("\n", $lines) : false;
    }
831004
public function createChildNodes(NodeInterface $node)
    {
        $nodeType = $node->getNodeType();
        foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeType) {
            try {
                $node->createNode($childNodeName, $childNodeType);
            } catch (NodeExistsException $exception) {
                // If you have a node that has been marked as removed, but is needed again
                // the old node is recovered
                $childNodePath = NodePaths::addNodePathSegment($node->getPath(), $childNodeName);
                $contextProperties = $node->getContext()->getProperties();
                $contextProperties['removedContentShown'] = true;
                $context = $this->contextFactory->create($contextProperties);
                $childNode = $context->getNode($childNodePath);
                if ($childNode->isRemoved()) {
                    $childNode->setRemoved(false);
                }
            }
        }
    }
429179
protected function interruptNode(NodeInterface $node)
    {
        // if we have an interruptNodeId, bubble up until we match a node
        // else stop propagation
        return $this->interruptNodeId ? $this->interruptNodeId !== $node->getId() : false;
    }
89302
protected function runSeed(String $className)
	{
		if (!class_exists($className)) {
			throw new SeederNotFoundException(
				sprintf(
					'[%s] seeder class not found.',
					$className
				)
			);
		}

		$seeder = new $className();
		return $seeder->run();
	}
559533
protected function executeSeedInit(ContainerInterface $container, string $seedClass): void
    {
        if ($this->seedInit !== null) {
            call_user_func($this->seedInit, $container, $seedClass);
        }
    }
621471
public function verify ($token, $seed = null) {
		return Hash::ValidRandomHash($token, is_callable($this->seedFilter) ? $this->seedFilter()($seed ?? $this->seed) : $seed ?? $this->seed, $this->salt, $this->hmacKey, $this->secretKeyLength, $this->algo);
	}
1025382
public static function generateKeys($seed = null, $hashKey = '')
    {
        # The keys are being generated from a seed.
        if ($seed !== null) {
            # Generate some repeatable hashes to create keys against for recovery
            $encrHash = Hash::hash($seed, $hashKey, Constants::BOX_SEEDBYTES);
            $signHash = Hash::hash($seed, $hashKey, Constants::SIGN_SEEDBYTES);

            # Build recoverable pre-seeded key pairs.
            $seeds = [
                'encr' => \Sodium\crypto_box_keypair($encrHash),
                'sign' => \Sodium\crypto_sign_keypair($signHash),
            ];
        } else {
            # Build un-recoverable key pairs.
            $seeds = [
                'encr' => \Sodium\crypto_box_keypair(),
                'sign' => \Sodium\crypto_sign_keypair(),
            ];
        }

        # Return the two generated key pairs to the client.
        return [
            'encr' => [
                'pri' => Helpers::bin2hex(\Sodium\crypto_box_secretkey($seeds['encr'])),
                'pub' => Helpers::bin2hex(\Sodium\crypto_box_publickey($seeds['encr'])),
            ],
            'sign' => [
                'pri' => Helpers::bin2hex(\Sodium\crypto_sign_secretkey($seeds['sign'])),
                'pub' => Helpers::bin2hex(\Sodium\crypto_sign_publickey($seeds['sign'])),
            ],
        ];
    }
1335498
public static function isExitNode($ip) {
        self::init();
        if (!is_string($ip)) throw new IllegalTypeException('Illegal type of parameter $ip: '.gettype($ip));

        // TODO: mit Filter-Extension lokale Netze abfangen
        if ($ip == '127.0.0.1')
            return false;

        $nodes = self::getExitNodes();
        return isset($nodes[$ip]);
    }
140405
public function getRandomColor($seed = null)
    {
        $seed = (int) $seed;
        $keys = array_keys($this->colors);

        return $keys[$seed];
    }
379961
@Override
    public void setSeed(long seed) {
        if (initialized) {
            throw new UnsupportedOperationException();
        }
        initialized = true;
        rnd = (seed ^ multiplier) & mask;
    }
1075436
protected function isGrantedNode(ReadNodeInterface $node)
    {
        return empty($node->getFrontRoles()) ||
               (null !== $this->tokenStorage->getToken() && $this->authorizationChecker->isGranted(ContributionActionInterface::READ, $node));
    }
483901
public static function fromPassphrase(string $passphrase, AbstractNetwork $network = null): string
    {
        return PrivateKey::fromPassphrase($passphrase)->toWif($network);
    }
913922
static public function getFromId($networkId, $field = "name")
    {
        foreach (self::$networkInfos as $name => $spec) {
            if ($spec["id"] !== (int) $networkId) continue;

            if ($field === "name")
               return $name;
            elseif (in_array($field, array_keys($spec)))
                return $spec[$field];
            else
                // Field not recognized
                return null;
        }

        // Network ID not recognized
        return null;
    }
474269
public function get(string $key): IndexNodeInterface
    {
        if (!isset($this->index[$key])) {
            throw new IndexException('Node key not found in index: '.$key);
        }

        return $this->index[$key];
    }