From 30aa085b2b8a169c157d3dfcba2caf604e8d3e54 Mon Sep 17 00:00:00 2001 From: pasta Date: Wed, 4 Dec 2024 10:02:57 -0600 Subject: [PATCH] fixup: apply code review comments --- src/elements.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/elements.cpp b/src/elements.cpp index 25c110f1d..b0c747af8 100644 --- a/src/elements.cpp +++ b/src/elements.cpp @@ -171,16 +171,16 @@ uint32_t G1Element::GetFingerprint(const bool fLegacy) const } std::vector G1Element::Serialize(const bool fLegacy) const { - const auto arr = G1Element::SerializeToArray(fLegacy); - return std::vector{arr.begin(), arr.end()}; + const auto arr = G1Element::SerializeToArray(fLegacy); + return std::vector{arr.begin(), arr.end()}; } std::array G1Element::SerializeToArray(const bool fLegacy) const { uint8_t buffer[G1Element::SIZE + 1]; g1_write_bin(buffer, G1Element::SIZE + 1, p, 1); + std::array result{}; if (buffer[0] == 0x00) { // infinity - std::array result{}; result[0] = 0xc0; return result; } @@ -193,7 +193,6 @@ std::array G1Element::SerializeToArray(const bool fLeg buffer[1] |= 0x80; // indicate compression } - std::array result{}; std::copy_n(buffer + 1, G1Element::SIZE, result.begin()); return result; } @@ -394,8 +393,8 @@ G2Element G2Element::Negate() const GTElement G2Element::Pair(const G1Element& a) const { return a & (*this); } std::vector G2Element::Serialize(const bool fLegacy) const { - const auto arr = G2Element::SerializeToArray(fLegacy); - return std::vector{arr.begin(), arr.end()}; + const auto arr = G2Element::SerializeToArray(fLegacy); + return std::vector{arr.begin(), arr.end()}; } std::array G2Element::SerializeToArray(const bool fLegacy) const {