From 467211a5ad468e84cc6e51bae36e65c82925c12b Mon Sep 17 00:00:00 2001 From: UkoeHB <37489173+UkoeHB@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:33:28 -0600 Subject: [PATCH] Update src/seraphis_crypto/sp_crypto_utils.cpp Co-authored-by: Jeffro --- src/seraphis_crypto/sp_crypto_utils.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/seraphis_crypto/sp_crypto_utils.cpp b/src/seraphis_crypto/sp_crypto_utils.cpp index 9da911a1c..ff379dbca 100644 --- a/src/seraphis_crypto/sp_crypto_utils.cpp +++ b/src/seraphis_crypto/sp_crypto_utils.cpp @@ -136,16 +136,14 @@ rct::key invert(const rct::key &x) void decompose(const std::size_t val, const std::size_t base, const std::size_t size, std::vector &r_out) { CHECK_AND_ASSERT_THROW_MES(base > 1, "Bad decomposition parameters!"); - CHECK_AND_ASSERT_THROW_MES(size > 0, "Bad decomposition parameters!"); CHECK_AND_ASSERT_THROW_MES(r_out.size() == size, "Bad decomposition result vector size!"); std::size_t temp = val; for (std::size_t i = 0; i < size; ++i) { - std::size_t slot = std::pow(base, size - i - 1); - r_out[size - i - 1] = temp/slot; - temp -= slot*r_out[size - i - 1]; + r_out[i] = temp % base; + temp /= base; } } //-------------------------------------------------------------------------------------------------------------------