2-3.兩個訊息有仿射關係
設明文\(M\)乘\(10^5\)倍,各加上隨機補綴值\(T_1\)和\(T_2\)(假設\(0\le T_1,T_2<10^5,T_1<T_2\))後\(e=3\)次方同餘\(N\)得到密文\(c_1,c_2\)。
\(c1=1881676371789154860897069000\)
\(c2=1881678004162711039676405223\)
\(N=54957464841358314276864542898551\)
若2個補綴值\(T_1\)和\(T_2\)很接近,設\(t\)為兩個補綴值的差,\(t\)未知但足夠小(\(t<N^{\frac{1}{9}}\))。
將密文\(c_1,c_2\),公鑰\(N\)代入9次同餘方程式
\(t^9+(3c_1-3c_2)t^6+(3c_1^2+21c_1c_2+3c_2^2)t^3+(c_1-c_2)^3\equiv 0\pmod{N}\)
雖然論文說能找到比\(N^{\frac{1}{9}}=3362\)還小的解,但以Coppersmith_Howgrave()副程式精算的上界\(X\)卻小很多。
\(\displaystyle X=ceiling(\frac{1}{\sqrt{2}}(hk)^{-1/(hk-1)}N^{(h-1)/(hk-1)})\)
設\(h=3\),9次方程式\(k=9\),計算出\(X=172\)
而且會產生\(27 \times 27\)的超大矩陣,導致LLL化簡的時間大幅增加還無法求得較小的解。
換另一個作法,令\(t^3=x\),先解3次同餘方程式,不僅Coppersmith_Howgrave()副程式精算的上界\(X\)提高很多。
\(x^3+(3c_1-3c_2)x^2+(3c_1^2+21c_1c_2+3c_2^2)x+(c_1-c_2)^3\equiv 0\pmod{N}\)
設\(h=3\),3次方程式\(k=3\),計算出\(X=46260610\)
而且產生\(9\times 9\)較小的矩陣,LLL化簡的時間變得更短了
所得到的較小\(x\)的解,再解一次3次同餘方程式,得到兩個補綴值的差\(t\)。
\(t^3-x\equiv 0\pmod{N}\)
再將密文\(c_1,c_2\),補綴值的差\(t\),公鑰\(N\)代入以下公式得到有補綴值的\(m_1\),再將後5位補綴值刪除得到明文\(M\)。
\(\displaystyle m_1\equiv \frac{t(c_2+2c_1-t^3)}{c_2-c_1+2t^3}\pmod{N}\)
請下載LLL.zip,解壓縮後將LLL.mac放到C:\maxima-5.46.0\share\maxima\5.46.0\share目錄下
要先載入LLL.mac才能使用Coppersmith_Howgrave指令
(%i1) load("LLL.mac");
(%o1) C:/maxima-5.46.0/share/maxima/5.46.0/share/LLL.mac
已知密文\(c_1,c_2\),公鑰\(N\)
(%i4)
c1:1881676371789154860897069000;
c2:1881678004162711039676405223;
N:54957464841358314276864542898551;
(c1) 1881676371789154860897069000
(c2) 1881678004162711039676405223
(N) 54957464841358314276864542898551
9次同餘方程式
(%i5) fx:x^9+(3*c1-3*c2)*x^6+(3*c1^2+21*c1*c2+3*c2^2)*x^3+(c1-c2)^3;
(fx) \(x^9-4897120668536338008669x^6+95599144073213399280057649148373498671072396308207166187x^3\)
\(-4349693466736349905369332025355097289037604766707550608234921567\)
同餘方程式係數同餘N,讓係數變小
(%i6) fx:polymod(fx,N);
(fx) \(x^9-4897120668536338008669x^6-1516451737447758219766669752498x^3-21000738238808374545647388458802\)
參數h
(%i7) h:3;
(h) 3
利用Coppersmith_Howgrave方法解9次同餘方程式,執行時間需2262秒(37分鐘)
但執行結果無法求得較小的整數解,故省略執行過程
(%i10)
showtime:true$
Coppersmith_Howgrave(fx,N,h);
showtime:false$
...
整數解為[]
Evaluation took 2262.6870 seconds (2264.0150 elapsed) using 420496.373 MB.
(%o9) []
令t^3=x,化簡成3次同餘方程式
(%i11) fx:x^3+(3*c1-3*c2)*x^2+(3*c1^2+21*c1*c2+3*c2^2)*x+(c1-c2)^3;
(fx) \(x^3-4897120668536338008669x^2+95599144073213399280057649148373498671072396308207166187x\)
\(-4349693466736349905369332025355097289037604766707550608234921567\)
同餘方程式係數同餘N,讓係數變小
(%i12) fx:polymod(fx,N);
(fx) \(x^3-4897120668536338008669x^2-1516451737447758219766669752498x-21000738238808374545647388458802\)
利用Coppersmith_Howgrave方法解3次同餘方程式,執行時間需43秒
(%i15)
showtime:true$
X:Coppersmith_Howgrave(fx,N,h);
showtime:false$
Evaluation took 0.0000 seconds (0.0000 elapsed) using 0 bytes.
參數\(h=3\)
\(p(x)\)最高次方\(k=3\)
\(\displaystyle X=ceiling(\frac{1}{\sqrt{2}}(hk)^{-1/(hk-1)}N^{(h-1)/(hk-1)})=ceiling(\frac{1}{\sqrt{2}}9^{-1/8}54957464841358314276864542898551^{1/4})=46260610\)
\(q_uv=N^{h-1-v} x^u p(x)^v =\) \([3020322941789135243826751301254310584993059920451586964677899601,\)
\(3020322941789135243826751301254310584993059920451586964677899601x,\)
\(3020322941789135243826751301254310584993059920451586964677899601x^2,\)
\(54957464841358314276864542898551(x^3-4897120668536338008669x^2-1516451737447758219766669752498x-21000738238808374545647388458802),\)
\(54957464841358314276864542898551x(x^3-4897120668536338008669x^2-1516451737447758219766669752498x-21000738238808374545647388458802),\)
\(54957464841358314276864542898551x^2(x^3-4897120668536338008669x^2-1516451737447758219766669752498x-21000738238808374545647388458802),\)
\((x^3-4897120668536338008669x^2-1516451737447758219766669752498x-21000738238808374545647388458802)^2,\)
\(x(x^3-4897120668536338008669x^2-1516451737447758219766669752498x-21000738238808374545647388458802)^2,\)
\(x^2(x^3-4897120668536338008669x^2-1516451737447758219766669752498x-21000738238808374545647388458802)^2]\)
用\(46260610x\)取代\(x\),得到\(q_{uv}=\) \([3020322941789135243826751301254310584993059920451586964677899601,\)
\(139721981684159887751924249514318172791235797686641888454048089061016610x,\)
\(6463624103118063744935544456324562407407970654820642611436221569296955598732100x^2,\)
\(54957464841358314276864542898551(98999742604948264981000x^3-10480053887972286407738186731512534900x^2-70151982409893138378920200419106503780x-21000738238808374545647388458802),\)
\(2542365847614788847019462641858137376110x(98999742604948264981000x^3-10480053887972286407738186731512534900x^2-70151982409893138378920200419106503780x-21000738238808374545647388458802),\)
\(117611394953827177084317023684568968482648027100x^2(98999742604948264981000x^3-10480053887972286407738186731512534900x^2-70151982409893138378920200419106503780x-21000738238808374545647388458802),\)
\((98999742604948264981000x^3-10480053887972286407738186731512534900x^2-70151982409893138378920200419106503780x-21000738238808374545647388458802)^(2),\)
\(46260610x(98999742604948264981000x^3-10480053887972286407738186731512534900x^2-70151982409893138378920200419106503780x-21000738238808374545647388458802)^(2),\)
\(2140044037572100x^2(98999742604948264981000x^3-10480053887972286407738186731512534900x^2-70151982409893138378920200419106503780x-21000738238808374545647388458802)^(2)]\)
產生矩陣\(M=\left[ \matrix{
3020322941789135243826751301254310584993059920451586964677899601&0&0&0&0&0&0&0&0\cr
0&139721981684159887751924249514318172791235797686641888454048089061016610&0&0&0&0&0&0&0\cr
0&0&6463624103118063744935544456324562407407970654820642611436221569296955598732100&0&0&0&0&0&0\cr
-1154147333401880370164435877744830779893335235336308145728995902&-3855375106843289059874469643405077531431008453876682145059536838022780&-575957193083777435966023818707724430220694882620408968134835546929900&5440774873514967046498526949032608069078072148942531000&0&0&0&0&0\cr
0&-53391559673044361070832604010361296224641422921151169969392245114020220&-178352004221385726316119489130401363701292623991492180806562660444404996695800&-26644131085943325292024201127948743853911779893898517315388054650660801239000&251693564521475219700920220763687359166473755234092339003910000&0&0&0&0\cr
0&0&-2469926119326432700196969469407759883742609255600435024997766588244094929534200&-8250672510003878744676740400060736629653654574347063094341880675381046234195692438000&-1232573756955700653437467678941596939415709824077480689105413794852905568404895790000&11643497827837801763248586973862843084330167466119804398647668985100000&0&0&0\cr
441031006574948269107459443949256719868815747806770028851275204&2946486839047310595109751478204161934049771268347937188112057574543120&4921301076215693158799367543245210199690179969531456795727185981205628668000&1470393112007528062187159841915196407503917007629683675986668119372838320000&109831529494789146606929429768530109268611975609482301299443587987461650000&-2075045274790487347904810593080778841186998131216420673800000&9800949035846008678895673107522190930361000000&0&0\cr
0&20402363393071117647355229427353424907730536471147343664377590214914440&136306278531300406989240120330126235607922189234249266563748531753485202503200&227662389779394457098885610164724803415889536400306605558985017074020917615167480000&68021282301266572748895948454500554080939778162323820958185619069740318114575200000&5080873551661937743415985648044361658132643844999773042316053040888648280606500000&-95992860189425566911358759970378608468403657618931662386599018000000&453397880977148227551007964314572140974967380210000000&0\cr
0&0&943825776005139675748417799999320121820808332782523517793742593671973092208400&6305611591687860920570511402945041036226201306511803963291610965520595093771558952000&10531801025252553016013278646442369888149133646495387760188037870704622801637392876962800000&3146706012238795427973303402033752877122263511053778975056451231393819657574298642872000000&235044309832747753792446979829777477365827565182434950799096426463863811536307859965000000&-4440688268007542274915272165073296358699518927682926250318126398080980000000&20974462546710273066928434544050339130507985738616528100000000}\right]\)
LLL化簡\(B=\left[ \matrix{
53771676921999198037128719975410481845009948321580737058118762&50209380384868519769271355772363021078882998018525986723096380&107113429339000465042631199484653568414097906566121374434204800&2566158289017059510580947933126354061025546078929008772549000&-39201258910319328503256252507864134476510009966583646884840000&-82244768124108488515911014612606850013994967332618611133000000&-103326720791445976823937028600478023227439055205294880233000000&37553747697339884108136344819118362708215810289041024760000000&-41948925093420546133856869088100678261015971477233056200000000\cr
145771311156080366680612542702670552709050420859148668552121201&-102701813735090026820390486307494510321459974199722868939788630&55690597658188982675500688460805070018767816245101070397610800&-3690675191418901829302352712732398605405813417421315444807000&-34161730786036250811133667107244245173497899683329768637600000&105158149470961723712865498187081390865505368625840232003900000&-83943991120073620894214705274131521444270306664078709465000000&-94290002110963796909267598874077903051034921264274818610000000&0\cr
22520257569452314079351935267514264370266330796992552972684997&-98310513164562058062910678303618723610419189844159039543246600&-59216755675973590492737933555662165421890387526607433485560200&210122354709341487106669358644005820317705567891681532969573000&-13547462576968605065539206672838828517502007656710102017580000&23570869821207231876579884845247791136173699754579501358900000&-40641684543556222622266012007342445503983888770262907798000000&-86958932882212997194203757223689795368058144049335172070000000&41948925093420546133856869088100678261015971477233056200000000\cr
169015127177354263666121860022442922657381338158956682760146316&-44086339219025359808922118654836582121338928607019431900103130&-55743427083965516899322695992901696889154913782390199199450100&-99213756448548832412671199081590293096668700399267187647555000&-13681783036472695133702522618982681148717527439219162384970000&-15336537742431604945023054843850719026627918786732999429600000&64672345006900325309865538762091565046333246270689577751000000&-71951332896677550420724086465591699219582263948746051800000000&62923387640130819200785303632151017391523957215849584300000000\cr
-111109391058117478677425543043666767886469428988351808979162264&68706199548070844584789292006960471026818898889658819004932390&114242801459017508543027293838247104016630443508968997031447000&-70229925147280191228538106815486527561582710206602914483698000&-108177296750967223863314840883237590333571940265343423758290000&21114534120011920453814163485385935919207972703328940545600000&-34780235497393011659779194620008032778904564753918395174000000&44536869417475438776116536835516252809621296087125152680000000&83897850186841092267713738176201356522031942954466112400000000\cr
32124330345979841767629832716536687416322338071176926036776624&27164161165425888332075134727974947827481095848187898522695730&-79639511287230298148663766719580830450559479484044659434682900&-51041393060884297450399678845972688262211525661235763838740000&-120857089745132822141399493042839109949450984516626943707450000&220466029767922832433728342036436413650585457627045150329700000&-42081776027182400361358030886271577560506458471894525675000000&58148929768074224345419762221788597120206147540057861770000000&-41948925093420546133856869088100678261015971477233056200000000\cr
-118279971490860306266688062364858934470851326591670377750842105&186394623214470748860705331927751369982342478110034345905919190&-5844542338433954468770696410970613047578620794759879329291700&-31690810413815853326709322936928777204830797244545090618294000&36631940618043663684819094023611438217838817287345595588310000&14670122074875238001436616319545787277339265229080644956400000&-87941416624880050595555558070529584290459598827529416836000000&-58985200396438287348022673963584538334771708074420956690000000&62923387640130819200785303632151017391523957215849584300000000\cr
-67402575181872320450341662740231249645051561595949203267092646&81687875727598274014317606405009186128237310267665643776123970&-60606071715445114152730683837370692931748434259046928181917500&118448345919188327186093480437680808892299725583302023014092000&5659950991122719764062671142382391292964286805841933824120000&61863373560034972019278274616457949997753618484681115789000000&87493980444210846078712251695585839215963143393159467086000000&-110345238655812995600366365368792036283900354142468092020000000&-125846775280261638401570607264302034783047914431699168600000000\cr
391536656683468813127560730295755766606487863741754115343991921&447549940911495565399271813369673072505177321547345359598698170&345431307115038022995995779076001023195500573892855741305309800&330776015310331719481270882134135987680304349298242517737362000&334129783160230133456909028931418304394164386380225530980110000&298169048606388347296126093056185837124427112397441890970200000&317606145581069503748397520803157118676806368270962392206000000&313838224166290677083070069124989059103490292778965585030000000&440463713480915734405497125425057121740667700510947090100000000}\right]\)
產生不需要同餘\(N^2\)的方程式
\(r(x)=53771676921999198037128719975410481845009948321580737058118762 \)
\(\displaystyle +50209380384868519769271355772363021078882998018525986723096380 ( \frac{x}{46260610} ) \)
\(\displaystyle +107113429339000465042631199484653568414097906566121374434204800 ( \frac{x}{46260610} )^2 \)
\(\displaystyle +2566158289017059510580947933126354061025546078929008772549000 (\frac{x}{46260610})^3 \)
\(\displaystyle -39201258910319328503256252507864134476510009966583646884840000 (\frac{x}{46260610})^4 \)
\(\displaystyle -82244768124108488515911014612606850013994967332618611133000000 (\frac{x}{46260610})^5 \)
\(\displaystyle -103326720791445976823937028600478023227439055205294880233000000 (\frac{x}{46260610})^6 \)
\(\displaystyle +37553747697339884108136344819118362708215810289041024760000000 (\frac{x}{46260610})^7 \)
\(\displaystyle -41948925093420546133856869088100678261015971477233056200000000 (\frac{x}{46260610})^8 \)
\(r(x)= -2x^8+82827356x^7-10542521995935153x^6-388196401064276818832330x^5-8559622143684325599618510860324x^4\)
\(+25920858191087824461843813370140390129x^3+50051974379238314010577044980314319102425126688x^2+1085359237261863165428889843267588150672526756965072158x+53771676921999198037128719975410481845009948321580737058118762\)
\( = -(x-45499293)(2x^7+8171230x^6+10914307183875543x^5+884789661515435025323429x^4+48816926196345927839271626696021x^3\)
\(+2195214770175831075654032836258741023024x^2+49828745646919485619110961668243162515263595344x+1181813460749801058164326201187576295856068539825019634) \)
整數解為\([x=45499293]\)
Evaluation took 43.1100 seconds (43.1220 elapsed) using 5541.766 MB.
(X) \([x=45499293]\)
再解一次3次同餘方程式
(%i16) fx:x^3-rhs(X[1]);
(fx) \(x^3-45499293\)
利用Coppersmith_Howgrave方法解3次同餘方程式,執行時間需0.328秒
(%i19)
showtime:true$
X:Coppersmith_Howgrave(fx,N,h);
showtime:false$
Evaluation took 0.0000 seconds (0.0000 elapsed) using 0 bytes.
參數\(h=3\)
p(x)最高次方\(k=3\)
\(\displaystyle X=ceiling(\frac{1}{\sqrt{2}}(hk)^{-1/(hk-1)}N^{(h-1)/(hk-1)})=ceiling(\frac{1}{\sqrt{2}}9^{-1/8}54957464841358314276864542898551^{1/4})=46260610\)
\(q_{uv}=N^{h-1-v} x^u p(x)^v =\)
\([3020322941789135243826751301254310584993059920451586964677899601,\)
\(3020322941789135243826751301254310584993059920451586964677899601x,\)
\(3020322941789135243826751301254310584993059920451586964677899601x^2,\)
\(54957464841358314276864542898551(x^3-45499293),\)
\(54957464841358314276864542898551x(x^3-45499293),\)
\(54957464841358314276864542898551x^2(x^3-45499293),\)
\((x^3-45499293)^2,\)
\(x(x^3-45499293)^2,\)
\(x^2(x^3-45499293)^2]\)
用\(46260610x\)取代\(x\),得到\(q_uv=\)
\([3020322941789135243826751301254310584993059920451586964677899601,\)
\(139721981684159887751924249514318172791235797686641888454048089061016610x,\)
\(6463624103118063744935544456324562407407970654820642611436221569296955598732100x^2,\)
\(54957464841358314276864542898551(98999742604948264981000x^3-45499293),\)
\(2542365847614788847019462641858137376110x(98999742604948264981000x^3-45499293),\)
\(117611394953827177084317023684568968482648027100x^2(98999742604948264981000x^3-45499293),\)
\((98999742604948264981000x^3-45499293)^2,\)
\(46260610x(98999742604948264981000x^3-45499293)^2,\)
\(2140044037572100x^2(98999742604948264981000x^3-45499293)^2] \)
產生矩陣\(M=\left[ \matrix{
3020322941789135243826751301254310584993059920451586964677899601&0&0&0&0&0&0&0&0\cr
0&139721981684159887751924249514318172791235797686641888454048089061016610&0&0&0&0&0&0&0\cr
0&0&6463624103118063744935544456324562407407970654820642611436221569296955598732100&0&0&0&0&0&0\cr
-2500525795354160459269142958652241224443&0&0&5440774873514967046498526949032608069078072148942531000&0&0&0&0&0\cr
0&-115675848613818628883670707444457456909880090230&0&0&251693564521475219700920220763687359166473755234092339003910000&0&0&0&0\cr
0&0&-5351235319142904201522225965512143075699768000894840300&0&0&11643497827837801763248586973862843084330167466119804398647668985100000&0&0&0\cr
2070185663499849&0&0&-9008836591414248716424316866000&0&0&9800949035846008678895673107522190930361000000&0&0\cr
0&95768051606757749647890&0&0&-416754276109143908313505917054448260000&0&0&453397880977148227551007964314572140974967380210000000&0\cr
0&0&4430288485840093620938676612900&0&0&-19279307032917423776366854961548179721038600000&0&0&20974462546710273066928434544050339130507985738616528100000000}\right]\)
LLL化簡\(B=\left[ \matrix{
2070185663499849&0&0&-9008836591414248716424316866000&0&0&9800949035846008678895673107522190930361000000&0&0\cr
0&95768051606757749647890&0&0&-416754276109143908313505917054448260000&0&0&453397880977148227551007964314572140974967380210000000&0\cr
-2500525795354160459269142958652241224443&0&0&5440774873514967046498526949032608069078072148942531000&0&0&0&0&0\cr
0&0&4430288485840093620938676612900&0&0&-19279307032917423776366854961548179721038600000&0&0&20974462546710273066928434544050339130507985738616528100000000\cr
0&-115675848613818628883670707444457456909880090230&0&0&251693564521475219700920220763687359166473755234092339003910000&0&0&0&0\cr
3020322941789135243826751301254310584993059920451586964677899601&0&0&0&0&0&0&0&0\cr
0&0&-5351235319142904201522225965512143075699768000894840300&0&0&11643497827837801763248586973862843084330167466119804398647668985100000&0&0&0\cr
0&139721981684159887751924249514318172791235797686641888454048089061016610&0&0&0&0&0&0&0\cr
0&0&6463624103118063744935544456324562407407970654820642611436221569296955598732100&0&0&0&0&0&0}\right]\)
產生不需要同餘\(N^2\)的方程式
\(\displaystyle r(x)= 2070185663499849 + 0 ( \frac{x}{46260610} ) + 0 (\frac{x}{46260610})^2 \)
\(\displaystyle -9008836591414248716424316866000 (\frac{x}{46260610})^3 + 0 (\frac{x}{46260610})^4 + 0 (\frac{x}{46260610})^5\)
\(\displaystyle +9800949035846008678895673107522190930361000000 (\frac{x}{46260610})^6 + 0 (\frac{x}{46260610})^7 + 0 (\frac{x}{46260610})^8 \)
\(r(x)=x^6-90998586x^3+2070185663499849=(x-357)^2(x^2+357x+127449)^2 \)
整數解為\( [x=357] \)
Evaluation took 0.3280 seconds (0.3280 elapsed) using 88.429 MB.
(X) \([x=357]\)
從密文\(c_1,c_2\),兩個補綴值的差\(t=T_2-T_1\)求得加上補綴值得明文\(m_1\)
(%i20) m1:t*(c2+2*c1-t^3)/(c2-c1+2*t^3);
(m1) \(\displaystyle \frac{t(5645030747741020761470543223-t^3)}{2t^3+1632373556178779336223}\)
將\(t\)值帶入\(m_1\)公式
(%i21) ev(m1,t=rhs(X[1]));
(%o21) \(1234567890\)
將後5位補綴值刪除,得到明文M
(%i22) M:floor(%/10^5);
(M) \(12345\)