Pārlūkot izejas kodu

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

tristangurtler 3 gadi atpakaļ
vecāks
revīzija
61c645e63f
1 mainītis faili ar 10 papildinājumiem un 0 dzēšanām
  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());