Skip to content

Commit 4da0612

Browse files
committed
tmp
1 parent 474c5d2 commit 4da0612

27 files changed

+533
-2247
lines changed

Libraries/LibCrypto/ASN1/DER.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ ErrorOr<void> Encoder::write_arbitrary_sized_integer(UnsignedBigInteger const& v
302302
auto kind = kind_override.value_or(Kind::Integer);
303303
TRY(write_tag(class_, type, kind));
304304

305-
auto max_byte_size = max(1ull, value.length() * UnsignedBigInteger::BITS_IN_WORD / 8); // At minimum, we need one byte to encode 0.
305+
auto max_byte_size = max(1ull, value.byte_length()); // At minimum, we need one byte to encode 0.
306306
ByteBuffer buffer;
307307
auto output = TRY(buffer.get_bytes_for_writing(max_byte_size));
308308
auto size = value.export_data(output);

Libraries/LibCrypto/BigFraction/BigFraction.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <AK/Math.h>
1111
#include <AK/StringBuilder.h>
1212
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
13-
#include <LibCrypto/NumberTheory/ModularFunctions.h>
1413

1514
namespace Crypto {
1615

@@ -36,12 +35,11 @@ ErrorOr<BigFraction> BigFraction::from_string(StringView sv)
3635

3736
auto integer_part = TRY(SignedBigInteger::from_base(10, integer_part_view));
3837
auto fractional_part = TRY(SignedBigInteger::from_base(10, fraction_part_view));
39-
auto fraction_length = UnsignedBigInteger(static_cast<u64>(fraction_part_view.length()));
4038

4139
if (!sv.is_empty() && sv[0] == '-')
4240
fractional_part.negate();
4341

44-
return BigFraction(move(integer_part)) + BigFraction(move(fractional_part), NumberTheory::Power("10"_bigint, move(fraction_length)));
42+
return BigFraction(move(integer_part)) + BigFraction(move(fractional_part), "10"_bigint.pow(fraction_part_view.length()));
4543
}
4644

4745
BigFraction BigFraction::operator+(BigFraction const& rhs) const
@@ -129,7 +127,7 @@ BigFraction::BigFraction(double d)
129127
d -= digit * AK::pow(10.0, (double)current_pow);
130128
if (current_pow < 0) {
131129
++decimal_places;
132-
m_denominator.set_to(NumberTheory::Power("10"_bigint, UnsignedBigInteger { decimal_places }));
130+
m_denominator.set_to("10"_bigint.pow(decimal_places));
133131
}
134132
current_pow -= 1;
135133
}
@@ -205,7 +203,7 @@ BigFraction BigFraction::rounded(unsigned rounding_threshold) const
205203
auto res = m_numerator.divided_by(m_denominator);
206204
BigFraction result { move(res.quotient) };
207205

208-
auto const needed_power = NumberTheory::Power("10"_bigint, UnsignedBigInteger { rounding_threshold });
206+
auto const needed_power = "10"_bigint.pow(rounding_threshold);
209207
// We get one more digit to do proper rounding
210208
auto const fractional_value = res.remainder.multiplied_by(needed_power.multiplied_by("10"_bigint)).divided_by(m_denominator).quotient;
211209

@@ -221,7 +219,7 @@ BigFraction BigFraction::rounded(unsigned rounding_threshold) const
221219

222220
void BigFraction::reduce()
223221
{
224-
auto const gcd = NumberTheory::GCD(m_numerator.unsigned_value(), m_denominator);
222+
auto const gcd = m_numerator.unsigned_value().gcd(m_denominator);
225223

226224
if (gcd == 1)
227225
return;

Libraries/LibCrypto/BigInt/Algorithms/BitwiseOperations.cpp

Lines changed: 0 additions & 313 deletions
This file was deleted.

0 commit comments

Comments
 (0)