Simplest Baby-Step-Giant-Step algorithm implementation with libgmp. This is a c++ port with libgmp of: dlp.
Programs solving the discrete logarithm problem.
Problem statement: find value a
such that g^a mod p = q
a
is 31 bit unsigned integer; g
, p
and q
are specified in hex format like this:
g = A4D1CBD5C3FD34126765A442EFB99905F8104DD258AC507FD6406CFF14266D31266FEA1E5C41564B777E690F5504F213160217B4B01B886A5E91547F9E2749F4D7FBD7D3B9A92EE1909D0D2263F80A76A6A24C087A091F531DBF0A0169B6A28AD662A4D18E73AFA32D779D5918D08BC8858F4DCEF97C2A24855E6EEB22B3B2E5
p = B10B8F96A080E01DDE92DE5EAE5D54EC52C99FBCFB06A3C69A6A9DCA52D23B616073E28675A23D189838EF1E2EE652C013ECB4AEA906112324975C3CD49B83BFACCBDD7D90C4BD7098488E9C219A73724EFFD6FAE5644738FAA31A4FF55BCCC0A151AF5F0DC8B4BD45BF37DF365C1A65E68CFDA76D4DA708DF1FB2BC2E4A4371
q = 4FB7FC5543219711B7144FDA72E4A25DDCBC79DB02D51C742602FB3D0D40E04C46CD22EC33B43DBEB5C05217A9135904DD8B7915335C9337D6CF07464E6E4D762B2C8B3A2F84313D0014C74D4EFE1FB00147B3D8498A755D6E2E6729A13B0F086BFEAB83E37B6401FEA9884AC1E493D7F91A065CD25E22EE5A66433F8C308DED
libgmp-6.2.1
I have built this with MinGW-64 on Windows10.
Change libgmp path in makefile before building.
bsgs-gmp.exe
Solving g^a mod p = q using Baby-step Giant-step algorithm
Solution found, a = 1988873156
bsgs-gmp is licensed under GPLv3.