Solving Diffie Hellman algorithm with Modular Exponentiation

139 views Asked by At

I need to write an example of the Diffie Hellman algorithm, but because the numbers are big and overflow can happen, I need to use Modular Exponentiation in my algorithm. I tried to understand the Modular Exponentiation, but I'm not good at math. So here, I need your help to rewrite my code again in Modular Exponentiation shape.

The code and typical solution:

g = 2
p = 2410312426921032588552076022197566074856950548502459942654116941958108831682612228890093858261341614673227141477904012196503648957050582631942730706805009223062734745341073406696246014589361659774041027169249453200378729434170325843778659198143763193776859869524088940195577346119843545301547043747207749969763750084308926339295559968882457872412993810129130294592999947926365264059284647209730384947211681434464714438488520940127459844288859336526896320919633919

a = 1101001010019203192312312312435234234131235457686756554434232325365645342323243
b = 2343423432473984729384792837492837498273984739847982

A = (g ** a) % p ** 10 % 541

s = A ** b % 541

print(s)
0

There are 0 answers