from gmpy2 import *
from binascii import *
def chinese_remainder_theorem(items):
M = 1
for a, m in items:
M *= m
result = 0
for a, m in items:
Mi = M/m
Mi_d=invert(Mi, m);
result += a*Mi*Mi_d
return result % M, M
def solve():
m1 = 0xC1594232E0C82877C7FBCF8FA1FEC2FAE9EF9FF8A60C057B891EB3B27AC60F7CB12144FA5C08C8AC64867DE4CB94CEA44E20002F488E4BA9B328BAE420D7F861
a1 = 0x8EB59040D88360FEBCF0F2808E5C1DD3A6A5D7AEAE2C780E5662319DD807692A106AD93142A9C98FDEE52EE5A3F70273B642BD8DA0FCFBD50C54E0CA666D6F42
m2 = 0x8BE1C51518A608CD1A41D77418B3DF047017C9AEF2AF153AFC8112C68DD3F9924E6849B6FB38B887699F6687B166281D3B7C5F9E5A82582847558D11B07237A9
a2 = 0x17E5A0D31A661441265B4A2CACC205539646DF5EC9558B5D8A74A1B42B8647E7F9058228A37B19B01C5CBB513DD5C64B3EB90006308DC764A8B3404C7FA02E9A
m3 = 0xDF343E4F83D0AE62E73BA0B6BC3342038E07961DFCA37906D89DE5E5B8BADCC84CAA438DD3FAE609A0E4F3931271E240CBEC62CCA95296776FEB0E92FEF7D671
a3 = 0x9AE829A0A5BA0E89F2626C5D3D2343F9F7DAAAEACB2487E19DAF81FE0C0B40C9F5AAD47C55257F671990D2B91D19EF3204C4EF973378550C5BB1C4CEDCE11E39
data = []
data.append([a1, m1])
data.append([a2, m2])
data.append([a3, m3])
x, n = chinese_remainder_theorem(data)
print a2b_hex(hex(iroot(x, 3)[0])[2:])
return
solve()
Crt get m = 681DEE98E3541ECAF1233A49B10A5766FF1CFE5F292DD2D4172871EF0E921AC89ECB67882EF70F49 D86D6EF8700AC724EE058AA775376B7D31F1E1A9CDD52A04A5D80E82C5AB7F9677F65
x = 4B45597B7767517A5773736473506452564F6F3265366A367D