Crypto - Easy Calc
😆 - Laika
Challenge
def f(s, p):
u = 0
for i in range(p):
u += p - i
u *= s
u %= p
return u
p = getPrime(1024)
s = random.randint(1, p - 1)
A = f(s, p)
Given the value of p and A, we have to find the value of s, which is used in encrypting the flag
f(s,p) generates a polynomial of the form
Since it is under modulo p, therefore we can write the polynomial as
On expanding, we get
This form of series is known as an AGP series or arithmetico-geometric progression. While there is a direct formula to calculate the sum of the series, in this case, it is easier to use the method which is used to derive the formula to solve rather then substituting into the formula itself.
On subtracting the two equations, we get
We now use the series formula for geometric progressions to simplify
From Fermat's theorem, we get
Substituting into the equation, we get
Finally, we get
Therefore, we can simply attain the value of s by a single line of code, after which we get the flag
s= inverse(-A-1,p)+1
#FLAG{Do_the_math396691ba7d7270a}Last updated