mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
AK: Add constant time equality and zero check to UFixedBigInt
This commit is contained in:
parent
590dcb0581
commit
3d561abe15
1 changed files with 26 additions and 0 deletions
|
@ -764,6 +764,32 @@ public:
|
||||||
return log2() / base.log2();
|
return log2() / base.log2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr u64 fold_or() const requires(IsSame<T, u64>)
|
||||||
|
{
|
||||||
|
return m_low | m_high;
|
||||||
|
}
|
||||||
|
constexpr u64 fold_or() const requires(!IsSame<T, u64>)
|
||||||
|
{
|
||||||
|
return m_low.fold_or() | m_high.fold_or();
|
||||||
|
}
|
||||||
|
constexpr bool is_zero_constant_time() const
|
||||||
|
{
|
||||||
|
return fold_or() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr u64 fold_xor_pair(R& other) const requires(IsSame<T, u64>)
|
||||||
|
{
|
||||||
|
return (m_low ^ other.low()) | (m_high ^ other.high());
|
||||||
|
}
|
||||||
|
constexpr u64 fold_xor_pair(R& other) const requires(!IsSame<T, u64>)
|
||||||
|
{
|
||||||
|
return (m_low.fold_xor_pair(other.low())) | (m_high.fold_xor_pair(other.high()));
|
||||||
|
}
|
||||||
|
constexpr bool is_equal_to_constant_time(R& other)
|
||||||
|
{
|
||||||
|
return fold_xor_pair(other) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_low;
|
T m_low;
|
||||||
T m_high;
|
T m_high;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue