$ ctf42

rotRSA

Crypto weight 22.56 No technique tags yet.
Difficulty Not rated yet

Flag format: H7CTF{...}

from sage.all import * from Crypto.Util.number import bytes_to_long from secret import left_prime, right_prime, x1, y1, x2, y2, hmw_k, flag

N = left_prime * right_prime M = (bytes_to_long(flag) + (x1 + y1 + x2 + y2)) % N C = pow(M, hmw_k, N) F = RealField(0x539) vx = vector(F, [x1, x2]) vy = vector(F, [y1, y2]) theta = F.random_element(min=-pi, max=pi) a = cos(theta) b = sin(theta) R = matrix(F, [[a - b, - (a + b)], [a + b, a - b]]) vx = R * vx vy = R * vy print(f"{N = }") print(f"{C = }") print(f"{vx = }") print(f"{vy = }") Output:

N = 1530918275727496052481927587506888898872661445804756668629182383177346963599178015486695788633985780304714769225260768793356151775431694243153154092613171994163101477784959518527624051431503966682506003306338841585805933821090952704904794043685132185633473727662564524685849627861735647321384257981521319290384051325921075709107288722172551168574333932808647352556653727672507067461436051513622801222997572272837527623900099986188803852650263136203314276420537883 C = 123895869377619089912431685904855683126415142906991962660654260994534288016801828574499115733405393845885262726286698514944614035229844690990959704512058774531260403938896134159824217177696911984011302991430767888379536342399760796718451958758409998207776108862992101897415487597187195878139067979782883804527830446586848672439515096056971858376075229159161804445359851730319418322212504473347589037260737916127207871046401338299433288435959795553512910745583115 vx = (1.12603559298910225367640247646958327289092603513514718149779150002117748770365932622949071091176431236004406836279786624558705339662570606116598069434254633474645823544074902492829639685270334209112664649029115267403186633725630947538323945055434999305613323248043865164370933900945232960498851571901851275761713645464974760408361283859697494129119141487116856155913454672269617263008516732874605635768e231, -1.28766340181013023465986349989612889038499256685280509247284934815033653165730262203898320773773163410966202028325463687820114081985664629615417483574756232792333933089287671003568396899622655080244676311880213337602625718021444512273874912546781230142242000191486124037686069696943515352509733658000047410584333886070818183794492395500942828786920790675953732140615495409334877428242372632565911380181e231) vy = (5.12151948564515173293138493656615709636405192953701804883255863184119285842103886383555091587961783651924874946365310272112986172395538692591654901671139562390735168633138563441671477286260959722195466105582824563784739404599235046709667089345602765294069619444436396946057767259160500024604508880559375315088275891953961140625471569561649564252059705370323869521051742806379528651340176678883547128189e192, 2.60654560848266973586043154271123952796543080056029907932250747987400383003574859705612124798203730324612739143581048542302422659880882955013906864292791310189448469050389026516705725432271074395761042626058949398210057352946878880077746871208477880587177095706348866743746566632027185134534440404213509402624663186743388030389121160726509287742674791260487524963748179432048200481445465137394280258172e192)

Writeups

Official

No official writeup linked.

Community

No community writeups yet. Solved it? Share how.

Log in to add a community writeup.