public function buildKey($path) {
        $path = BIP32Path::path($path);
        $originalPath = (string)$path;

        if (!isset($this->derivations[$originalPath])) {
            $key = $this->key;

            $toPublic = $path[0] === "M" && $this->path[0] === "m";
            if ($toPublic) {
                $path = $path->privatePath();
            }

            assert(strpos(strtolower((string)$path), strtolower((string)$this->path)) === 0);

            $path = substr((string)$path, strlen((string)$this->path));

            if (substr($path, 0, 1) == "/") {
                $path = substr($path, 1);
            }

            if (strlen($path)) {
                $key = $key->derivePath($path);
            }

            if ($toPublic) {
                $key = $key->toPublic();
            }

            $this->derivations[$originalPath] = BIP32Key::create($key, $originalPath);
        }

        return $this->derivations[$originalPath];
    }
public function buildKey($path) {
        $path = BIP32Path::path($path);
        $originalPath = (string)$path;

        if (!isset($this->derivations[$originalPath])) {
            $key = $this->key;

            $toPublic = $path[0] === "M" && $this->path[0] === "m";
            if ($toPublic) {
                $path = $path->privatePath();
            }

            assert(strpos(strtolower((string)$path), strtolower((string)$this->path)) === 0);

            $path = substr((string)$path, strlen((string)$this->path));

            if (substr($path, 0, 1) == "/") {
                $path = substr($path, 1);
            }

            if (strlen($path)) {
                $key = $key->derivePath($path);
            }

            if ($toPublic) {
                $key = $key->toPublic();
            }

            $this->derivations[$originalPath] = BIP32Key::create($key, $originalPath);
        }

        return $this->derivations[$originalPath];
    }
public function buildKey ( $ path ) { $ path = BIP32Path :: path ( $ path ) ; $ originalPath = ( string ) $ path ; if ( ! isset ( $ this -> derivations [ $ originalPath ] ) ) { $ key = $ this -> key ; $ toPublic = $ path [ 0 ] === "M" && $ this -> path [ 0 ] === "m" ; if ( $ toPublic ) { $ path = $ path -> privatePath ( ) ; } assert ( strpos ( strtolower ( ( string ) $ path ) , strtolower ( ( string ) $ this -> path ) ) === 0 ) ; $ path = substr ( ( string ) $ path , strlen ( ( string ) $ this -> path ) ) ; if ( substr ( $ path , 0 , 1 ) == "/" ) { $ path = substr ( $ path , 1 ) ; } if ( strlen ( $ path ) ) { $ key = $ key -> derivePath ( $ path ) ; } if ( $ toPublic ) { $ key = $ key -> toPublic ( ) ; } $ this -> derivations [ $ originalPath ] = BIP32Key :: create ( $ key , $ originalPath ) ; } return $ this -> derivations [ $ originalPath ] ; }
build child key

@param string|BIP32Path  $path
@return BIP32Key
@throws \Exception
build child key