/** * Add a checksum to the tree hash directly * * @param string $checksum The checksum to add * @param bool $inBinaryForm Whether or not the checksum is already in binary form * * @return self * @throws LogicException if the root tree hash is already calculated */ public function addChecksum($checksum, $inBinaryForm = false) { // Error if hash is already calculated if ($this->hash) { throw new LogicException('You may not add more checksums to a finalized tree hash.'); } // Convert the checksum to binary form if necessary $this->checksums[] = $inBinaryForm ? $checksum : HashUtils::hexToBin($checksum); return $this; }