Trendy windy trigonity
Description: have you seen Tan challenge before? see maple version pi documentation!
trendy windy trigonity was a crypto CTF CyberSpace CTF 2024 added during the second wave.
from Crypto.Util.number import bytes_to_long
flag = REDACTED
print(len(flag))
R = RealField(1000)
a, b = bytes_to_long(flag[:len(flag)//2]), bytes_to_long(flag[len(flag)//2:])
x = R(0.75872961153339387563860550178464795474547887323678173252494265684893323654606628651427151866818730100357590296863274236719073684620030717141521941211167282170567424114270941542016135979438271439047194028943997508126389603529160316379547558098144713802870753946485296790294770557302303874143106908193100)
enc = a*cos(x)+b*sin(x)
# 38
# 2.78332652222000091147933689155414792020338527644698903976732528036823470890155538913578083110732846416012108159157421703264608723649277363079905992717518852564589901390988865009495918051490722972227485851595410047572144567706501150041757189923387228097603575500648300998275877439215112961273516978501e45
The challenge uses sagemath to handle high precision floating point numbers, in this case a RealField
with 1000 bits of precision.
The idea behind the challenge is very simple: find a and b to retrieve the flag.
enc
is a linear combination of cos(x)
and sin(x)
, you know what that means: lattice.
Don’t forget to scale by the precision as we are working with integers.
R = RealField(1000)
x = R(0.75872961153339387563860550178464795474547887323678173252494265684893323654606628651427151866818730100357590296863274236719073684620030717141521941211167282170567424114270941542016135979438271439047194028943997508126389603529160316379547558098144713802870753946485296790294770557302303874143106908193100)
enc = R(2.78332652222000091147933689155414792020338527644698903976732528036823470890155538913578083110732846416012108159157421703264608723649277363079905992717518852564589901390988865009495918051490722972227485851595410047572144567706501150041757189923387228097603575500648300998275877439215112961273516978501e45)
scale = 2^1000
m = matrix(ZZ, [
[1, 0, scale*cos(x)],
[0, 1, scale*sin(x)],
[0, 0, -scale*enc],
])
vec = m.LLL()[0]
a, b = vec[0], vec[1]
print(f'flag: {(a.to_bytes(19) + b.to_bytes(19)).decode()}')
$ flag: CSCTF{Trigo_453_Tr3ndy_FuN_Th35e_D4Y5}
Author: vympel