I think we should all learn elliptic curves and fatima is a good start, enjoy!
c2p(): Flag's each byte is mutiplied to pointGon elliptic curve, and generate new pointC. Point's x,y coordinates are bit encoded and concatenated, producing bin string having length of 16. All generated bin strings are concatenated to make single bin string.enmat(): Bin string is divided everyl=3bits, and decoded to make a matrix.dict_traversal: random permutation(shuffle(range(1, 6)))) is generated.1: spiral,2: revspiral,3: sinwaveform,4: helical,5: revhelicalis applied to the matrix following permutation order.CAL: Matrix is multiplied toCALmatrix, which is some circulant matrix.- We get the final matrix.
I must write inverse function of encryption logic.
p2c(): Inverse ofc2p(). Brute to solve DLP since there are only 256 candidates.decmat(): Inverse ofdecmat()dict_traversal: I wrote corresponding inverse functions:1: spiral_rev,2: revspiral_rev,3: sinwaveform_rev,4: helical_rev,5: revhelical_rev. The number of permutation is5! = 120, so feasible to brute.CAL: Circulant matrixCis generated based on row(([0 for i in range(len(B)-1)] + [1]). After that, it is somewhat multipled few times by itself. There are only100 = len(B)candidates forCALwhich are cyclic permutations because of the property of circulant matrix.
Writing the inverse functions were tedious. Total Complexity: O(100 * 5! * 256 * len(flag)) = O(2 ** 28) so feasible.
I get flag:
CCTF{Elliptic_Curv3_1s_fun_&_simpLE_Circulaitng_it_make_it_funnier!!}