Browse Source

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

tristangurtler 3 years ago
parent
commit
61c645e63f
1 changed files with 10 additions and 0 deletions
  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)
 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);
     std::string outString = output.element.get_str(16);
+    
+    if (outString.size() % 2 == 1)
+        outString = "0" + outString;
+
     std::vector<char> bytes = hexToBytes(outString);
     std::vector<char> bytes = hexToBytes(outString);
 
 
     BinarySizeT sizeOfVector(bytes.size());
     BinarySizeT sizeOfVector(bytes.size());