public function setHashSize(int $size): self
    {
        if ($size < \SODIUM_CRYPTO_GENERICHASH_BYTES_MIN) {
            throw new InvalidDigestLength(
                \sprintf(
                    'Merkle roots must be at least %d long.',
                    \SODIUM_CRYPTO_GENERICHASH_BYTES_MIN
                )
            );
        }
        if ($size > \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX) {
            throw new InvalidDigestLength(
                \sprintf(
                    'Merkle roots must be at most %d long.',
                    \SODIUM_CRYPTO_GENERICHASH_BYTES_MAX
                )
            );
        }
        if ($this->outputSize !== $size) {
            $this->rootCalculated = false;
        }
        $this->outputSize = $size;
        return $this;
    }