From 28d56bde357febd5a25668fea47a4bc2a16b45e0 Mon Sep 17 00:00:00 2001 From: Alexander Lvov Date: Mon, 16 Sep 2024 18:19:05 +0300 Subject: [PATCH] Updated sanitizing for unsigned integers. --- sanitize/primes.bin | Bin 13086 -> 4524 bytes sanitize/unsigned/main.cpp | 40 ++++++++++++++++++++----------------- 2 files changed, 22 insertions(+), 18 deletions(-) mode change 100755 => 100644 sanitize/primes.bin diff --git a/sanitize/primes.bin b/sanitize/primes.bin old mode 100755 new mode 100644 index 68dff6854358402a600b528a73a1562e9a195878..4069aec425524e44c6f7e44368e87b76fdabe355 GIT binary patch delta 7 OcmbQ2wnllw8bJUK9s@xD delta 8637 zcmV~$0ZdYh0szqOoO8}O=bUrSIp>^n&N=6tbIv*EoO8_?ArcZ25h9Wjkr5FOuS!H@ zL`XzNL`GzUMnptJXhcLrM5IJUMnpFolQGIJ0Uw! zJ8?UyJDEEtcJg)#c8YdR?^Nzo@6_xx?zHc8?sV@A?u_qD2W5Z?KxLpRP%~%;2m``_ z2p}?u1{wn~K`amtBm>DoN{|+$2RT5?AP*=3N`g{%749n9Rk5pXSM#p6UG2LdyGXkz zyBNFpyClG_>0R1g)?Kb${$1f+>$~E+(!rVFEN~7uA6yD91J{Au!8^btFcr)ObHPIJ zG*}9r0qejni9f>?-am?`rL8>+0x2cM-aVyT-csUBWJL zm#jdxuT?Jnr9>#px^>~87a(GBT_cB8t{-GkkPZc;b5o7XMw zmUpYW&E3v!Z+Eae)E(=G`5;J9i^@qjnGOChaEgX6$C~=IrL~ z7VVzft=jF{9oW6OJGnarmIh0QWx{e{#jsLXJFF9if}vpq7zIX$v0>9NIZO%Dz|1fw zY!S8!1J+@wJy|{3J$XIlJ(WFGJrr zdt5!*#43318;WRiKJ_VP+Rd6-j0C&PYa6dc<55qU% zQFs!bvL|a#&Ys*o`Fo1@RP3qV(+KS8+=JMI+e6s{>|yQ^>=Eyo-Xq;3-=p8NxMy|G z`kwfn#GVvHHlhGgj3`4?BAO685FH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Ld=jj zqzI`(+K@5i3VB1}P$HE1z3_X<_lobG-@)IJ-|^px-)Z0HzU#g(d^df!es_F#e_#0? z_#XVe`91nQJ)9FR4p)ck!%g9qFf&MfPP?p;C>AMp#2#8A^oBFVfnR)g8$}z%8u23 z^(*&R$*;0smA~44b^L<^`cC0E^6KjouV&E7whKb>0!!c@XEXIoQV&a%2 zCX1$%D1Yv>bBaq;9Hn2>=tp0v_;vXZH;Ylwj^8A zTZ%39mUhd!W!rLYxwlrf0>IY#*7jC%D`&fCyKK8=yMDWIyJZ`+joLmTqR#2>;R+8^PcsXyXBia+{4hCj=Hynh0J z!hf>k`SHSdRlGXh9B+?z#>sJdoEzuIRdH?H6gS8H@nC#24y638_*?(C&|mmp z^k3{>!r$S))W3qi!oQ-wGk-OI&42BGLx1Ccvl7{ff<$GaCIL=B6SxE+K}^sR%!Dv8 zm5?Ol32nlfSWScyn~BtaY5y|*75yv!SN*T$U&p`Bf3Sb3f0%#xf8>9(f82lke}aFa zf0BRde}=k$?tj65oByK!(vw-qqGV;VI=Lg+nM5S9Nm3F>GLsWYZc?0_Ny?L! loadPrimes(const std::filesystem::path& fromLocation) { if(input.fail()) throw std::runtime_error("Failed to open prime table"); - const std::size_t primesAmount = 2000; //std::filesystem::file_size(fromLocation) / sizeof(primeType); + const std::size_t primesAmount = std::filesystem::file_size(fromLocation) / sizeof(primeType); std::vector primes (primesAmount); for (auto& prime: primes) input.read(reinterpret_cast(&prime), sizeof(primeType)); @@ -27,29 +27,33 @@ std::vector loadPrimes(const std::filesystem::path& fromLocation) { } int main() { - const Aeu<512> n = "0x4c6f0a38f6c296d07052b794a02317ce9758855"; - std::cout << "N = " << std::showbase << std::hex << n << std::endl; - const std::filesystem::path primesLocation = "../../primes.bin"; const auto primes = loadPrimes(primesLocation); - Aeu<512> base = 2u; - Aeu<2048> power = 1u; + std::array numbers = { Aeu<512>("0x4c6f0a38f6c296d07052b794a02317ce9758855"), // 0xa9ab4314cf -> 2 × 3^2 × 7 × 1181 × 2083 × 2351 + Aeu<512>("0x14cd01a38ac5c55992acb21ff9665294b30f9ee578393dad147") }; // 0x2fdd8d6ba69 -> 2^3 × 3 × 5 × 647 × 2203 × 19231 + + for(auto& number: numbers) { + std::cout << "N = " << std::showbase << std::hex << number << std::endl; + + Aeu<512> base = 2u; + Aeu<4096> power = 1u; - for(unsigned short prime : primes) { - const auto primeF = static_cast(prime), - boarder = static_cast(std::numeric_limits::max()); - const auto primePower = static_cast(static_cast(std::log(boarder) / std::log(primeF)) - 1); + for(unsigned short prime : primes) { + const auto primeF = static_cast(prime), + boarder = static_cast(std::numeric_limits::max()); + const auto primePower = static_cast(static_cast(std::log(boarder) / std::log(primeF)) - 1); - power *= static_cast(std::pow(primeF, primePower)); - if(power.bitCount() > 1536) { - base = Aeu<512>::powm<2048>(base, power, n); - power = 1u; + power *= static_cast(std::pow(primeF, primePower)); + if(power.bitCount() > 3072) { + base = Aeu<512>::powm<4096>(base, power, number); + power = 1u; - const auto candidate = Aeu<512>::gcd(base - 1u, n); - if(candidate > 1u) { - std::cout << "Completed: " << std::showbase << std::hex << candidate << std::endl; - return 0; + const auto candidate = Aeu<512>::gcd(base - 1u, number); + if(candidate > 1u) { + std::cout << "Completed: " << std::showbase << std::hex << candidate << std::endl; + break; + } } } }