Update src/seraphis_crypto/sp_crypto_utils.cpp

Co-authored-by: Jeffro <jeffreyryan@tutanota.com>
This commit is contained in:
UkoeHB 2024-02-22 16:33:28 -06:00 committed by GitHub
parent 1d3211fca5
commit 467211a5ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 4 deletions

View File

@ -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<std::size_t> &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;
}
}
//-------------------------------------------------------------------------------------------------------------------