CRYPTO NEWS

Crypto++ Multiplicative inverses do not reciprocate in ModularArithmetic group

My mathematical assumption is $(g^rx’)^x = g^r$ where $x’$ is the multiplicative inverse of $x$ and $g$ is the generator of the group. I am calculating $(g^rx’)^x$ in ModularArithmetic group G using Crypto++.

CryptoPP::Integer a, b, c, r(rng, 1, p);
a = G.Exponentiate(g, r);
b = G.Exponentiate(G.Exponentiate(g, G.MultiplicativeInverse(x)), r);
c = G.Exponentiate(b, x);
std::cout << "c = " << a  << std::endl;
std::cout << "b = " << b << std::endl;
std::cout << "c = " << c << std::endl;

I am expecting a == c But I see a and c are completely different.

a = 1930186808310718502797115181829348128116...
b = 2074612869164222925611442905270407839427...
c = 6800929086281603423987465129823606881371...

I tried $ (g^{x’})^{x} $ expecting that to be $g$, but that also is different from $g$. But $xx’ = 1$

G.Multiply(x, G.MultiplicativeInverse(x)) // But this is 1
G.Exponentiate(G.Exponentiate(g, G.MultiplicativeInverse(x)), x) // NOT g

I am generating Private key using CryptoPP::DSA::PrivateKey and using the PrivateExponent as x.

CryptoPP::DSA::PrivateKey sk;
sk.GenerateRandomWithKeySize(rng, key_size);
CryptoPP::DSA::PublicKey pk;
pk.AssignFrom(sk);
CryptoPP::Integer g, p, q, x, gx;
pk.GetValue("SubgroupGenerator", g);
pk.GetValue("SubgroupOrder", q);
pk.GetValue("Modulus", p);
pk.GetValue("PublicElement", gx);
sk.GetValue("PrivateExponent", x);

Then I am creating a group

CryptoPP::ModularArithmetic G(p);

Is my mathematical assumption wrong ? or there is a problem in the code ?

Crypto++ Multiplicative inverses do not reciprocate in ModularArithmetic group

Shopping cart
There are no products in the cart!
Continue shopping
0