Diffie-Hellman: shared secret
Diffie-Hellman (DH) is a protocol where two people communicate over a public channel and agree on the same shared secret without ever transmitting a private key. It was discovered in 1976 and is at the foundation of today's HTTPS connections.
The way it works is very simple. Two numbers visible to everyone are chosen: a large prime number p and a generator g. Then:
- Alice thinks of a private number
aand sendsA = g^a mod p. - Bob thinks of a private number
band sendsB = g^b mod p. - Alice calculates
s = B^a mod p. - Bob calculates
s = A^b mod p.
Both get g^(ab) mod p — that is, the same number. An eavesdropper, however, only sees p, g, A, B and cannot find a (the discrete logarithm problem).
Below, Alice's private number a has accidentally been exposed. Calculate the shared secret s:
p = 1113764753
g = 3
a = 748479285 # Alisaning maxfiy soni
A = 521666560 # Alisa jo'natgan
B = 1055302623 # Bob jo'natgan
Assemble the flag like this: BAYROQ{DH_umumiy_sir_<s>} — where <s> is the shared secret in decimal format.