0
I've seen several variations on "modular inverse" but I can't seem to identify the proper way of utilizing it for C++. I'm not sure how this python code translates into c++:
def inverse(x, p):
"""
Calculate the modular inverse of x ( mod p )
the modular inverse is a number such that:
(inverse(x, p) * x) % p == 1
you could think of this as: 1/x
"""
inv1 = 1
inv2 = 0
while p != 1 and p!=0:
inv1, inv2 = inv2, inv1 - inv2 * (x / p)
x, p = p, x % p
return inv2
My current coding is here: http://coliru.stacked-crooked.com/a/74648b16c2692525
But it only shows like the first public key properly, after that it messes up.
I downloaded that library, but I don't know what to do with your inverse. I'm only sending two variables to my inverse to be worked with. I think it works out to the number to be modding and the number being modded by. – Mine – 2014-06-24T07:29:01.090