This was an interesting challenge for me since I was dealing with Discrete Log Problem and Finite Fields for the first time. The challenge asks us to calculate discrete log for a polynomial finite field.
The algorithm I used to solve this was [Pohlig-Hellman Algorithm](https://en.wikipedia.org/wiki/Pohlig%E2%80%93Hellman_algorithm). Since this algorithm works when n is irreducible, what I did was I changed n to new_n which is irreducible polynomial and calculated the mod using that polynomial. Since (a mod b) mod c = a mod c, i calculated (g^X mod n) mod new_n and ran the algorithm for this. This gave me the flag ```inctf{bingo!}```
Note : I used one of the factors of n as new_n since those are already irreducible.
The whole solution is :```p = 35201
P = PolynomialRing(GF(p), 'x')x = P.gen()n = 1629*x^256 + 25086*x^255 + 32366*x^254 + 21665*x^253 + 24571*x^252 + 20588*x^251 + 17474*x^250 + 30654*x^249 + 31322*x^248 + 23385*x^247 + 14049*x^246 + 27853*x^245 + 18189*x^244 + 33130*x^243 + 29218*x^242 + 3412*x^241 + 28875*x^240 + 1550*x^239 + 15231*x^238 + 32794*x^237 + 8541*x^236 + 23025*x^235 + 21145*x^234 + 11858*x^233 + 34388*x^232 + 21092*x^231 + 22355*x^230 + 1768*x^229 + 5868*x^228 + 1502*x^227 + 30644*x^226 + 24646*x^225 + 32356*x^224 + 27350*x^223 + 34810*x^222 + 27676*x^221 + 24351*x^220 + 9218*x^219 + 27072*x^218 + 21176*x^217 + 2139*x^216 + 8244*x^215 + 1887*x^214 + 3854*x^213 + 24362*x^212 + 10981*x^211 + 14237*x^210 + 28663*x^209 + 32272*x^208 + 29911*x^207 + 13575*x^206 + 15955*x^205 + 5367*x^204 + 34844*x^203 + 15036*x^202 + 7662*x^201 + 16816*x^200 + 1051*x^199 + 16540*x^198 + 17738*x^197 + 10212*x^196 + 4180*x^195 + 33126*x^194 + 13014*x^193 + 16584*x^192 + 10139*x^191 + 27520*x^190 + 116*x^189 + 28199*x^188 + 31755*x^187 + 10917*x^186 + 28271*x^185 + 1152*x^184 + 6118*x^183 + 27171*x^182 + 14265*x^181 + 905*x^180 + 13776*x^179 + 854*x^178 + 5397*x^177 + 14898*x^176 + 1388*x^175 + 14058*x^174 + 6871*x^173 + 13508*x^172 + 3102*x^171 + 20438*x^170 + 29122*x^169 + 17072*x^168 + 23021*x^167 + 29879*x^166 + 28424*x^165 + 8616*x^164 + 21771*x^163 + 31878*x^162 + 33793*x^161 + 9238*x^160 + 23751*x^159 + 24157*x^158 + 17665*x^157 + 34015*x^156 + 9925*x^155 + 2981*x^154 + 24715*x^153 + 13223*x^152 + 1492*x^151 + 7548*x^150 + 13335*x^149 + 24773*x^148 + 15147*x^147 + 25234*x^146 + 24394*x^145 + 27742*x^144 + 29033*x^143 + 10247*x^142 + 22010*x^141 + 18634*x^140 + 27877*x^139 + 27754*x^138 + 13972*x^137 + 31376*x^136 + 17211*x^135 + 21233*x^134 + 5378*x^133 + 27022*x^132 + 5107*x^131 + 15833*x^130 + 27650*x^129 + 26776*x^128 + 7420*x^127 + 20235*x^126 + 2767*x^125 + 2708*x^124 + 31540*x^123 + 16736*x^122 + 30955*x^121 + 14959*x^120 + 13171*x^119 + 5450*x^118 + 20204*x^117 + 18833*x^116 + 33989*x^115 + 25970*x^114 + 767*x^113 + 16400*x^112 + 34931*x^111 + 7923*x^110 + 33965*x^109 + 12199*x^108 + 11788*x^107 + 19343*x^106 + 33039*x^105 + 13476*x^104 + 15822*x^103 + 20921*x^102 + 25100*x^101 + 9771*x^100 + 5272*x^99 + 34002*x^98 + 16026*x^97 + 23104*x^96 + 33331*x^95 + 11944*x^94 + 5428*x^93 + 11838*x^92 + 30854*x^91 + 18595*x^90 + 5226*x^89 + 23614*x^88 + 5611*x^87 + 34572*x^86 + 17035*x^85 + 16199*x^84 + 26755*x^83 + 10270*x^82 + 25206*x^81 + 30800*x^80 + 21714*x^79 + 2088*x^78 + 3785*x^77 + 9626*x^76 + 25706*x^75 + 24807*x^74 + 31605*x^73 + 5292*x^72 + 17836*x^71 + 32529*x^70 + 33088*x^69 + 16369*x^68 + 18195*x^67 + 22227*x^66 + 8839*x^65 + 27975*x^64 + 10464*x^63 + 29788*x^62 + 15770*x^61 + 31095*x^60 + 276*x^59 + 25968*x^58 + 14891*x^57 + 23490*x^56 + 34563*x^55 + 29778*x^54 + 26719*x^53 + 28613*x^52 + 1633*x^51 + 28335*x^50 + 18278*x^49 + 33901*x^48 + 13451*x^47 + 30759*x^46 + 19192*x^45 + 31002*x^44 + 11733*x^43 + 29274*x^42 + 11756*x^41 + 6880*x^40 + 11492*x^39 + 7151*x^38 + 28624*x^37 + 29566*x^36 + 33986*x^35 + 5726*x^34 + 5040*x^33 + 14730*x^32 + 7443*x^31 + 12168*x^30 + 24201*x^29 + 20390*x^28 + 15087*x^27 + 18193*x^26 + 19798*x^25 + 32514*x^24 + 25252*x^23 + 15090*x^22 + 2653*x^21 + 29310*x^20 + 4037*x^19 + 6440*x^18 + 16789*x^17 + 1891*x^16 + 20592*x^15 + 11890*x^14 + 25769*x^13 + 29259*x^12 + 23814*x^11 + 17565*x^10 + 16797*x^9 + 34151*x^8 + 20893*x^7 + 2807*x^6 + 209*x^5 + 3217*x^4 + 8801*x^3 + 21964*x^2 + 16286*x + 12050new_n = n.factor()[0][0]phi = 1for i in new_n.factor():	phi=phi*(pow(p, i[0].degree())-1)u = P.quotient(new_n, 'a')a = u.gen()g = ah = 10254*a^255 + 11436*a^254 + 9453*a^253 + 31783*a^252 + 22103*a^251 + 10097*a^250 + 28892*a^249 + 18508*a^248 + 22160*a^247 + 26375*a^246 + 3876*a^245 + 19858*a^244 + 30728*a^243 + 7847*a^242 + 16954*a^241 + 3306*a^240 + 13208*a^239 + 25886*a^238 + 33685*a^237 + 6481*a^236 + 12387*a^235 + 16989*a^234 + 32301*a^233 + 3069*a^232 + 1062*a^231 + 30500*a^230 + 7726*a^229 + 5137*a^228 + 10962*a^227 + 10406*a^226 + 22108*a^225 + 21887*a^224 + 739*a^223 + 27363*a^222 + 5715*a^221 + 8176*a^220 + 32398*a^219 + 33238*a^218 + 28151*a^217 + 18812*a^216 + 24615*a^215 + 8245*a^214 + 9730*a^213 + 8071*a^212 + 5590*a^211 + 21532*a^210 + 5962*a^209 + 17369*a^208 + 25626*a^207 + 14284*a^206 + 32492*a^205 + 3944*a^204 + 5227*a^203 + 30264*a^202 + 17098*a^201 + 28516*a^200 + 19180*a^199 + 31133*a^198 + 6217*a^197 + 29652*a^196 + 23061*a^195 + 22336*a^194 + 7848*a^193 + 15686*a^192 + 14763*a^191 + 27394*a^190 + 26349*a^189 + 3586*a^188 + 13954*a^187 + 12979*a^186 + 1909*a^185 + 506*a^184 + 18147*a^183 + 12126*a^182 + 8258*a^181 + 32944*a^180 + 11947*a^179 + 1354*a^178 + 33656*a^177 + 12395*a^176 + 14442*a^175 + 8301*a^174 + 4409*a^173 + 28252*a^172 + 29872*a^171 + 14252*a^170 + 2279*a^169 + 6317*a^168 + 31734*a^167 + 19036*a^166 + 520*a^165 + 34967*a^164 + 15096*a^163 + 20173*a^162 + 18962*a^161 + 28622*a^160 + 9961*a^159 + 18600*a^158 + 4794*a^157 + 33233*a^156 + 23874*a^155 + 26462*a^154 + 17088*a^153 + 11202*a^152 + 11392*a^151 + 16258*a^150 + 19460*a^149 + 17784*a^148 + 28458*a^147 + 817*a^146 + 25362*a^145 + 35096*a^144 + 3283*a^143 + 6551*a^142 + 30282*a^141 + 1134*a^140 + 29704*a^139 + 12388*a^138 + 20847*a^137 + 23240*a^136 + 25554*a^135 + 19687*a^134 + 22021*a^133 + 33659*a^132 + 19105*a^131 + 15422*a^130 + 32550*a^129 + 20712*a^128 + 11862*a^127 + 31185*a^126 + 9245*a^125 + 20218*a^124 + 18357*a^123 + 12809*a^122 + 20336*a^121 + 5247*a^120 + 6737*a^119 + 15970*a^118 + 14986*a^117 + 13437*a^116 + 8582*a^115 + 35005*a^114 + 14125*a^113 + 1110*a^112 + 11888*a^111 + 28756*a^110 + 11610*a^109 + 10241*a^108 + 13301*a^107 + 10052*a^106 + 3501*a^105 + 33176*a^104 + 12987*a^103 + 27504*a^102 + 21903*a^101 + 16653*a^100 + 12466*a^99 + 33281*a^98 + 360*a^97 + 26611*a^96 + 8066*a^95 + 1528*a^94 + 34974*a^93 + 16606*a^92 + 6724*a^91 + 18933*a^90 + 6703*a^89 + 6011*a^88 + 12647*a^87 + 32169*a^86 + 27545*a^85 + 18417*a^84 + 31199*a^83 + 17400*a^82 + 23798*a^81 + 16555*a^80 + 23009*a^79 + 1904*a^78 + 4962*a^77 + 1390*a^76 + 8141*a^75 + 25010*a^74 + 33199*a^73 + 19059*a^72 + 23473*a^71 + 14324*a^70 + 30136*a^69 + 15298*a^68 + 29677*a^67 + 33907*a^66 + 2250*a^65 + 34933*a^64 + 11261*a^63 + 22789*a^62 + 3652*a^61 + 15401*a^60 + 8978*a^59 + 32965*a^58 + 2505*a^57 + 17018*a^56 + 33296*a^55 + 27680*a^54 + 6679*a^53 + 24625*a^52 + 28932*a^51 + 789*a^50 + 10745*a^49 + 15681*a^48 + 14757*a^47 + 8233*a^46 + 15427*a^45 + 10112*a^44 + 30124*a^43 + 3701*a^42 + 31048*a^41 + 29692*a^40 + 2865*a^39 + 9066*a^38 + 20493*a^37 + 25607*a^36 + 115*a^35 + 9724*a^34 + 20716*a^33 + 19260*a^32 + 19536*a^31 + 6311*a^30 + 4672*a^29 + 27315*a^28 + 12186*a^27 + 17786*a^26 + 7341*a^25 + 4276*a^24 + 9217*a^23 + 6637*a^22 + 18711*a^21 + 19348*a^20 + 14022*a^19 + 30518*a^18 + 10550*a^17 + 19146*a^16 + 2430*a^15 + 25237*a^14 + 34375*a^13 + 2497*a^12 + 35085*a^11 + 8261*a^10 + 3388*a^9 + 26236*a^8 + 14902*a^7 + 14487*a^6 + 24280*a^5 + 11078*a^4 + 7380*a^3 + 24669*a^2 + 549*a + 1468factors = factor(phi)l1 = []l2 = []x1 = 1for i in factors:	a = int(phi/pow(i[0], i[1]))	b = int(pow(i[0], i[1]))	gi = g^a	hi = h^a	for j in range(b):		if(gi^j == hi):			l1.append(j)			l2.append(b)			breakprint('inctf{'+int.to_bytes(int(crt(l1, l2)), 7, 'big')[1:].decode()+'}')```