浏览代码

fixing a small bug in how scalars were transmitted over the wire

tristangurtler 3 年之前
父节点
当前提交
61c645e63f
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      bgn2/src/Scalar.cpp

+ 10 - 0
bgn2/src/Scalar.cpp

@@ -359,7 +359,17 @@ std::string bytesToHex(const std::vector<char>& bytes)
 
 std::ostream& operator<<(std::ostream& os, const Scalar& output)
 {
+    if (os.flags() & std::ios::hex)
+    {
+        os << output.toInt();
+        return os;
+    }
+
     std::string outString = output.element.get_str(16);
+    
+    if (outString.size() % 2 == 1)
+        outString = "0" + outString;
+
     std::vector<char> bytes = hexToBytes(outString);
 
     BinarySizeT sizeOfVector(bytes.size());