public function serializeString(string $str = null)
    {
        if (null === $str) {
            $uint8 = $this->serializeInt(null);
        }
        else {
            // prepend size on 4 bytes
            $count = strlen($str);
            $uint8 = $this->serializeInt($count);

            // UTF-8 to binary
            for ($i = 0; $i < $count; $i++) {
                $dec = Ed25519::chrToInt(substr($str, $i, 1));
                array_push($uint8, $dec);
            }
        }

        return $uint8;
    }