Parcourir la source

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

tristangurtler il y a 3 ans
Parent
commit
61c645e63f
1 fichiers modifiés avec 10 ajouts et 0 suppressions
  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());