52TEST_CASE(
"MP Big Encryption Test 00",
"[big_int_t][arithmetic][math]" ) {
56 BigInt pub_P(53), pub_Q(59), pub_n(pub_P*pub_Q);
59 std::cout <<
"Public Key:: P " << pub_P <<
", Q " << pub_Q <<
", n " << pub_n <<
", e " << pub_e << std::endl;
65 BigInt sec_d = ( sec_k * sec_phi + 1 ) / pub_e;
66 std::cout <<
"Private Key:: phi " << sec_phi <<
", k " << sec_k <<
", d " << sec_d << std::endl;
70 std::cout <<
"clear:: " << clear.
to_hex_string(
true) << std::endl;
73 std::cout <<
"encrypted:: " << cipher.
to_hex_string(
true) << std::endl;
76 std::cout <<
"decrypted:: " << decrypted.
to_hex_string(
true) << std::endl;
78 REQUIRE( clear == decrypted );
Arbitrary precision integer type.
std::string to_hex_string(bool add_details=false) const noexcept
BigInt mod_pow(BigInt e, BigInt m)
Returns (*this)^e % m, or pow(*this, e) % m.
std::string to_string(const alphabet &v) noexcept
constexpr T gcd(T a, T b) noexcept
Returns the greatest common divisor (GCD) of the two given integer values following Euclid's algorith...
constexpr const jau::fraction_i64 one(1l, 1lu)
one is 10^0 or 1/1
big_int_t (this file) (c) 2024 Gothel Software e.K.
constexpr const size_t mp_word_bits
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
static BigInt phi(const BigInt &P, const BigInt &Q)
TEST_CASE("MP Big Encryption Test 00", "[big_int_t][arithmetic][math]")
static BigInt eval_e(BigInt e, const BigInt &phi)
Returns e with 1 < e < Φ(n)