mirror of
https://github.com/monero-project/monero.git
synced 2025-01-23 03:04:57 +00:00
Update src/seraphis_crypto/sp_crypto_utils.cpp
Co-authored-by: Jeffro <jeffreyryan@tutanota.com>
This commit is contained in:
parent
1d3211fca5
commit
467211a5ad
1 changed files with 2 additions and 4 deletions
|
@ -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)
|
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(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!");
|
CHECK_AND_ASSERT_THROW_MES(r_out.size() == size, "Bad decomposition result vector size!");
|
||||||
|
|
||||||
std::size_t temp = val;
|
std::size_t temp = val;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < size; ++i)
|
for (std::size_t i = 0; i < size; ++i)
|
||||||
{
|
{
|
||||||
std::size_t slot = std::pow(base, size - i - 1);
|
r_out[i] = temp % base;
|
||||||
r_out[size - i - 1] = temp/slot;
|
temp /= base;
|
||||||
temp -= slot*r_out[size - i - 1];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//-------------------------------------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue