forked from p4-team/ctf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
brute.cpp
127 lines (110 loc) · 30.3 KB
/
brute.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include <bits/stdc++.h>
using namespace std;
struct RNG {
random_device dev;
mt19937_64 rng;
RNG() : dev(), rng(dev()) {}
RNG(uint64_t seed) : rng(seed) {}
bool next_bit() { return rng() & 1; }
// For when we want to hide the RNG state
uint64_t next_qword_safe() {
uint64_t res = 0;
for (int i = 0; i < 64; ++i)
res |= next_bit() << i;
return res;
}
// For when we don't care about security
uint64_t next_qword_fast() {
return rng();
}
};
using Vector = valarray<uint64_t>;
struct Matrix {
vector<Vector> elements;
Matrix(int rows, int cols)
: elements(rows, Vector(cols)) {}
auto rows() const { return elements.size(); }
auto cols() const { return elements[0].size(); }
auto operator*(const Vector& v) const {
assert(v.size() == cols());
Vector res(rows());
for (size_t i = 0; i < rows(); ++i) {
Vector mul = elements[i] * v;
res[i] = accumulate(begin(mul), end(mul), uint64_t{0});
}
return res;
}
void fill(RNG* rng) {
for (auto& row : elements)
for (auto& x : row)
x = rng->next_qword_fast();
}
void fill(uint64_t* data) {
int i = 0;
for (auto& row : elements)
for (auto& x : row)
x = data[i++];
}
void print() {
for (auto& row : elements)
for (auto& x : row)
cout<<x<<" ";
}
};
constexpr int key_size = 64;
void write64(ofstream& o, uint64_t x) {
o.write(reinterpret_cast<const char*>(&x), sizeof x);
}
Vector load_result(string path){
ifstream in(path.c_str(), ios::binary);
char buffer[8];
in.read(buffer, 8);
uint64_t size = *reinterpret_cast<uint64_t*>(buffer);
Vector all(64);
for(int i=0;i<64;i++){
in.read(buffer, 8);
uint64_t element = *reinterpret_cast<uint64_t*>(buffer);
all[i] = element;
}
Vector res(size);
for(int i=0;i<size;i++){
res[i] = all[i+4];
}
return res;
}
int main(int argc, const char **argv) {
if(argc < 4){
cerr<<"./binary start end encrypted_file"<<endl;
exit(-1);
}
unsigned int start = atoi(argv[1]);
unsigned int end = atoi(argv[2]);
Vector result = load_result(string(argv[3]));
Matrix A_inv(37, 37);
uint64_t data[] = {6612423972294138831,9667107047553394101,7798071757385797805,6941139426977189477,273054658297522189,15755393383675445344,11140754237069989665,18214854682015101198,9721244169973678758,14973488192567943230,13427533897815582944,17547065919829667569,13832840271694235448,9124597867421542637,3532728663350981427,8716797083654762740,7124455318828058715,11707290104068335359,15079168564425755320,10721842958175856760,11548523907832852646,8956201799956280110,16603541463531404589,15370376713969322497,2938273974625571065,4150366928168736544,7082321225039519313,16239293224494904406,8929923184845738753,3181050637531538586,4005976294341973018,14798273496906217146,164728478575490859,7827130510475501080,18279952141378039378,10574870107178347002,12760496882070874426,6526632227631322881,7264115880476466945,12499964218477389234,5943956361972759370,15015144983285805550,3257763135385281851,2125143625997340566,12348242513623464682,11713006993011041954,7490087608239308783,5604173510915215236,8129356322158126342,8451186888636619625,16728041967385405871,8061843568993442237,5740712880627566405,1376930118141810917,407520835910076124,3965042435833382005,8215802159930766400,3809153959667375603,2512961597571494044,9262095428415590122,9442693073325801470,2492598453029206006,15048049560538549547,16106519165275492759,8994282657318487864,5852498740605015192,11878098512718316006,7678915575404362200,14437305489282184063,11742662722391965114,6728947175146210083,13891390453615209225,17066609840447266485,7212203372037986001,13221091961557085286,14316510423160489620,1407200099236811520,754440986470677653,13035819905579778694,9560225499668475829,16356515259426253877,17131040792854014275,17079232854245332931,14662644452954288327,13598599100479449472,11134576439073398017,15436867324847398665,2693670465828878586,14699297380830728980,16244388305507135735,7722116425400827987,5362189014787705909,472440966090017233,4335296421428826792,10918917937795474901,12428502925441349092,15971081530002200682,1483989849585848924,106058717599254646,13076275378056982828,10738712395942701578,14907012410669315943,8957079597076962736,15701755990324774662,2759245168297692614,14452789609132126311,11603692503993615416,10224641635441606537,719679020498041008,15522015671371219997,13679162819994434273,14132289016943852721,11596195753436110348,17856870651877043341,1295434961173763390,7332574948135345002,4072305315080248014,15425710935790537427,7430105510175553416,16133581694512451790,12875423936967858543,4980535363384797378,8975892279894599836,12397329987797648372,5105010748350808824,13342206435278145795,16769248995136379337,650476898582910052,1969377531758983643,15797641241624211725,14631548968441314361,17651073948929206223,2350755053023188218,6138028218718995668,4697011573906139403,4041062497801265229,14796883800199966092,14705445692937070292,10299263732598413096,10968160254274675094,4919794392454753876,16910357336828612012,9189719417115662663,4591192435839974484,5133308550991089062,17043618908988232270,10710315846428893491,9663670460985534706,17929569331411701691,1948309026538243540,7367789138055319885,7713575560602515323,432153071460615850,7765250548451907738,11063590336210325134,2557333216589345874,5296535947833898689,17199096846099328024,4084116802119640635,15155076274730757580,13655729231795825926,8169738793343010846,454660059485363771,532510360843522923,16966382844795542256,1901350071142573474,13453308114366092711,16076352655942857226,11694906376413826070,11447005250499358776,2472450125143069084,332723507063919941,11199257657210046156,1097828930683329818,18269713484633780654,907384689878402832,13395840203990987035,17514419888608284512,9501935956734817543,9752784249397245893,6191743536483322294,16481275278451525079,8310748886449498917,13468255046087114982,17220996258996362859,17264727027183917810,1155619426426487416,13029857229542460733,15473592616228236102,14746442213576671677,4648595914274540014,1523249110649422927,3116174756254687548,101754464845298207,14452563144323293491,7437727261672716875,10253599905088974356,275821638564263621,2653108867923005743,18092492438540898123,7709168320091937477,8977306709787877648,4554721850952060617,3853134714587872134,11947145405334322442,1455359778305409434,8748935796271851994,8196079272176974408,9406131815195479744,12172650265303368164,843688320710859352,18100575420827033569,17784601928820016083,16451056765766689040,15865088644577973713,12897923984356469176,14558974186245952507,2099425701921653916,11188923098391747624,15931894019618118044,3985972230004988646,5509877074017248417,3674591793137271016,4958564057499198707,14312687980222670291,17482922427453157595,4518045899087610290,295276654408050940,6738260541899325269,9564167523566523089,10855784344800233601,14244074057340543841,9350925553052112092,15441207403344197219,8770634874057203454,2476267943963766988,14640585690471325682,16343867635023287479,17911692387356627043,14059873597713267044,17237907219901991650,9937494066127947122,8667042292527015135,14252364741527223747,4364415917875345355,10296943315690447550,13359409617234342866,564923679647552682,8842949817992965972,14485214479383520876,1401745182454382894,9789461305804016474,2088913808440899855,7855166399148658082,14612108766845208480,7544646068435528527,4491000631242054453,12746201406235294884,3543291672416671350,14802604229641188229,5827097490569304520,13054345948889279282,11431313607007152263,17789293971324177305,15698466202434015516,9867790966050709093,14237781655535030291,8022805372193843435,273437606437275150,18444804173394738461,14049294432282678517,9952305488711462841,9820535390296440073,8087767470530774860,13793019621972087485,8755096482135173810,2137002743828051859,1449331775533931357,2394917595820135340,17624457294559341393,6274446347515901705,6627830199653767642,5248285586574167145,6669574729973567171,13941050948743685263,7762317380625131829,13190652711795304165,2367677985984013123,6173635364580561467,8900253595325458840,15785850312671457200,3702063162301414614,4371982614591617319,1326936268361997376,11421205005244481362,2734214663237108249,12489290145854841734,9944597160754754087,12614080704109742029,8466077343392424143,8401540465036479575,16909429994513654442,8412543379837908112,5412729832560393381,16359361203530989706,2754233235098358224,1323135108845735456,856230426059643883,10599829448034835321,1526407057768946248,952011660398573197,8426574101697894450,3643784466596380172,16349553663164701876,7369412193078987813,6523912594152470106,6825999916433082868,6670825127226598612,3388906014676994027,2313779100942437588,12300974626602726764,16354366884006646223,13862409734518441074,14474125807943696814,16800179357907813446,1004472273879481659,2422654152647220137,11409355097773851398,1329544289556436596,6100119815107270428,14487223923995255112,13251304691409407616,882838958774402328,5390807582050678368,11579067281491749444,3939143831628686162,1969259523209450701,15137417303408270111,8636023056047819905,11296306968942775332,3324037204485758270,1495269575654590165,12932240959799426046,12754030202501226227,9418673773510086677,8138905787724876680,678449784009738480,15487050126274590745,8512524772883726896,3603847261483989948,2120180034908247205,7181766371831887885,15104199644895072639,14220875793547193586,12651541926833673693,11761767916004479296,13459837065035485359,1011058524370699825,8158319115132750413,16676471742151391489,14764027798180483781,16512320874458647290,6947167285233232691,3178235359695804574,15502234056211810030,6883335127970775592,7382672439666401212,13187432829838396289,25562366450656229,15149310984055049889,13039984541677337819,18324789042377519168,16561178372554614893,14422789357998096632,12745369025094599564,10561261570363594607,4054694266881360804,12996722590220026010,8332568495185271712,11142156783716121039,11011327351490052763,7214639776583535776,381173450944921664,795933463535862748,9482319293524096573,16441965686635530372,13448362780448542240,10545923419465995085,2753839876699606392,16635103044573325738,5622721647778304417,10770521636293719404,8251547521141589750,14546873295889531382,11203324203664829566,4440812267641307017,6395022619691990106,537793326878307894,13221491015856126471,3330800688214260914,8027190253511103308,9342381548447641628,10347466690381721869,16062340374247071058,1930905333538708379,9487491724309046645,7007177788060778328,11683788543294452015,3362355035918069523,5031980796820159144,12129335188361385880,11731780481616322612,9781043447904050291,1173278206551485892,15949770888391231693,7937270217078010550,8967337039531722253,8381187153208648,2937503041938604180,12926249473852021091,13886311883733563104,11605757770682822539,18409205429177695634,12870046317432567039,5252992500060118279,8837439934085488745,4897829307891020061,15715915133443455440,7406911036750397509,14758724083966865676,13412529791718655340,4484212047427881167,9390951856388390720,10793164827856818356,16845465949648478561,7028429034599703446,8687531128891191226,12044259418466252344,12726587729863559326,10791673125779969319,6402989584360087738,6077796075396603441,14130174950159989559,15175766306985913294,16022241668138842285,14032158410797518673,16511191535235817956,5520427266849362550,6103614884287626758,525513607135593486,5362126629591146926,7762188540384266598,6815229438046328725,12037855307665786826,15965068274681484691,14912405572775360913,10498575262544019958,9052246544954788418,11193346991868788891,16250187730240127797,9310371568715109526,11326568679457068975,17045590958889917473,9372981660936614832,5648524973663132144,10439090534746314383,11337644425749455904,17780441489604079744,12820984406820187088,6435626539256259033,1650034866871338478,6121530257880456651,13830155369695283314,3966819573968810357,15987631959666186006,485816693958283582,83208714298125635,2834187365001028238,7107935241188357874,12009401294709992015,17676763916652758630,9706530677659338845,15892860098142660892,2706588606704670891,12365345246667451592,8809468941442547984,14393889708526336701,11075898987606180279,12250875520701910004,10826845224462040529,10039254040544536506,16660606510025172211,12374293464309331010,9540946984868218618,8645028195278739459,8442731547899570416,12500563017234924847,3620200661080673796,5140971706954348371,1374754427769330434,3140763219880752093,270076815670547193,17215679540038970770,6397021841871560447,16000650358957774453,619877068156218555,14232331775112232514,16566953586359581541,10544106843851919756,11017881662237530491,13374626207607073311,4212690782496822749,17573236423391065389,13786077131733507575,17448218625148494836,2491325002992883838,13872993629419924807,10503632698870931211,10081245866729374909,1812989821378803614,7145699627700144965,16030031837413267745,15043452692477356556,11515657196802408972,1920058829539959986,14529019443234366071,2170710684764564181,12272103829754142086,15744183971142480150,5301647146579860870,16099821550216790672,1248926405172816558,10646544527036147034,17251448435306113706,17046311178296777196,3738520791093650671,8379845322962366857,10832709089813529734,15941098911659843611,12645274410879135574,13803435926832471094,17300455401596000641,734676634755655466,4214836184238425461,4466616689775102577,3603290072889747180,3118054667379642718,324882087163308769,1525367787708030303,9460991333280113997,14050161515530651432,8703073494335599792,5740799952899470435,11923826262400455736,17241980981456130595,14194434499867668172,15858652462885709905,6315530862303460798,16393691916958998420,15276593111709298552,5515619916878854890,16168316741597258731,14868152847537545568,4857590827943429101,13763216254923401480,4097480704685069927,14919600596150401258,11222778255703188412,18440753087694475329,2676168819945062059,16897445091014747112,11693149810921009900,34802519764392339,13415106979735069244,1375734432732748898,6334000947330028165,5153645163551790900,15763966826527489370,4391518021340888002,987055332785818435,5227671214086595513,6207964174331690002,18208023782491371813,4183225206501376636,5380393099863778268,14578762398124680380,18296373918100595515,18309708638903473493,7468732041870846618,3113112159629090165,7034601090741509460,13057650150056191763,16702491129855244826,5012229644806225593,17447364744694461673,9140206976850788443,356718164538135763,5241356330810417832,4112336525306597577,8826990989685370260,14340277460428341398,17785384379108324494,14886866868251010521,7776752477584972524,1261812295507496285,18326003504453517465,8961938486922533986,15474960900190721606,15117560681829835096,9474573354497397158,397740022821028732,7847983964911549715,10424617021616841227,16691017628098099743,270152274042538736,10419381226166370586,12891751341669323951,2322144029602456101,8557269242521157533,16086912702207038202,14840138866342389566,4892279288022694122,961567238100408972,4787840237020841753,16616104889362979286,6567692961050386990,3767246818498103316,17651802508532643134,7191190767772032941,17678022016584674307,4455770550778965637,7118270335706884238,13955736496178451284,12060266549130759339,14487103223491414436,900230794950825881,15149855372068885955,3770559576614345138,16829595192169825566,1210502387535737544,881503522713486055,12849227464592727138,15118324761522973300,5353762873507914591,780431310526066882,305823101924407662,10054641015968896291,1551963781047986457,13958287797078599705,4762326759395084059,2089230894221109305,7054743419859754432,16941758333349321002,11396240027813744577,3587739211586542826,7701794335195415521,3510702225875444436,14917408451137172214,17645624667100274850,335842555442066294,18348598746010301928,12829341122326086255,3598029834343696091,6886168367265552956,5479818077387546989,11366175246399383547,2191880206754375707,9613521306034997685,4923215122305226020,13115819040276505189,16403544130004167705,9227964489259901710,3399865808557883557,9780671032359434448,12494135524503613335,10637290382497131376,3298843357227495106,11819215884752218736,4600873926156989925,3804066515572293367,13337097324408083205,2524810585688784973,5257552874274224187,8443632982528664265,9760086098758087183,12154375748361510919,7264302344759798102,7121497835380783220,15566376096887963828,5993314623621504873,15509293971616591377,7475717902587778614,11240021230902226763,15220327293088109531,16986997758236744014,13416363519190713155,781310362208931713,3000178022207206361,14844705286678594916,17542730237063320071,486888211006478788,1753541485770531675,3924018030495325395,11793269776076755175,17114361738594382732,3976571681843686726,5675325056861436750,6781915109828365878,15337222382111909418,4586643159958303551,7452559905076223577,4351786310394312152,2175359109335433539,17564664715195090358,15982197611266810499,10855146673113250881,189498437063645221,4813387558596036903,8154298987236696948,920864164014049457,11493394012134283302,14945611590874063011,11431891282948598352,15339906762541330193,18219758606198185495,14678958225708268962,8459257759571766027,2602129780611862932,11168994691861374896,16645051969564154267,9290132443475175871,12625114340416294714,10800333426834912853,12148443260235051881,4221019044156934085,2307715257077790884,4028413592777590891,3308396575063217231,14722371758597613583,14989021902085463019,3091817347556963086,10331078532830428742,17221567446147576080,17413239479625178235,9911003356231145821,9586512186467911672,12525561439266433551,6310329157129260681,4833708029144472652,2569112682019482069,3599323863173786071,6691377593512842673,4525756979647759730,5698015100348707695,3050923649841702486,10126683426679438667,15534897028937891925,4179451116504510127,12417950024456134042,1996214605752520833,149118268535403755,10974152938583135013,4136813858786116344,3263968000702595302,8595752375546596976,10267872008516209497,17311640942781080130,1729910923917908490,13390873206044995949,4299078382913397853,1616493505473057124,14233523740529793928,12348011290682583799,4061655139926813777,3054074389115406181,5537682000454156194,4516957006291891692,9916041143850074644,15196325311659295068,2180884345250822407,4256198258330505948,10495293569293943883,13893778104319955128,1534284457907883503,9087761929536954525,2498612195287640229,13749379786904391184,11026845499010815821,7734422587724187801,16850014470098073700,4628517028460144002,12744930803662656874,14761547787518954266,3291109442451490672,4401542676292769689,14506501172978498519,4027415846103721682,10299405971897933979,4899991566029449499,8054434724327933435,7745350153583566018,11093351615750095321,17074409851714150122,10080874128434717922,10210762878811622787,10276487106722976830,14857800416891301079,18296614660845576807,15000754685377331845,2794881117650533138,8382800091069486842,1475333127463673348,16975076783714074464,8262800382892397364,7941406441006587118,11501252618434544165,5377293830909117402,9403178363296577924,6127515733156440701,2229625937642952337,11140146119540318417,9928376150979694648,17256923922741326787,2909083286821850932,8252390553334933224,8576023433180482547,6223582771520161838,2199604348391066115,11527645379625878543,15493923697023154173,17073954738513019622,10251343480932097710,9956684902559016114,2355279612507709236,523877565045746028,12887383199902133104,2898985590389737922,875651550095861862,6471744930622038352,14960718382110666889,17508028385242712044,6334867904603281039,528925824903403086,6209694270027321693,6700771309966437578,1145406036237889372,9883931481173741568,17687889530518153481,9854852285036446189,13042786584721375672,16557939341682345164,18080201444278856717,5202554949089818924,18091208217172597134,12964343716063304631,7681850911093878796,15513218334436286076,6344367146165801457,8069231595844118950,2603311917583246015,17330932144810451441,2365817517477136833,17801298827042418493,877312579609767019,7945950835002072590,8999380339476219964,1702284598339827757,1392301714088252889,14733547046583485441,7217232401824995902,3988310363466438850,15986269002446767001,14141773004079962966,14323682779910160109,3452794527858560620,6312102335145457571,5120463816986123649,10824867021706007829,10259374065535497685,8430455079253725121,5511657372335722850,17154340747585780151,3077053976488362503,13430579705507622690,5933525281243970179,1295791959431540382,6355007808187736560,14746903446309519637,1141082342883111802,11459237047593897198,7030492807704268304,10767429846442298355,17664505129239447040,13647339243657848790,5873172431041636992,9426477325770781048,4593058239228397993,1336817057498042030,1961370835874094297,2128633091856389354,2314463287740474724,10924699267428369216,16856046791287910092,17814597727249807743,15493775630611869368,12559209436583301225,3708299964531339634,6900102655462611453,6319339186950452491,13474789756885365954,13950525114277293371,6364893454220354928,4215263824803486743,11190460528882731531,16663943146577528192,15485159441680071169,13632909062134095325,14581589694332664660,12378758957233752093,15795756162895744461,11046525804066475578,5093803584699177296,4278641180098584843,2377083840101994232,12684958784335511566,6898908597824868414,10234995815508760900,15601993995062011814,3957001627682881801,7052955741009015787,10786790810668798379,16574365324510104151,14370503829093630041,10547510275575699393,11634739341977345922,3168020004126619122,407216754719710309,744326326445924448,9654065406921314943,12920740205344075857,13268653249366416331,16715302465454777533,10753769855254512994,2113051592150655440,17044464136114795136,7440070514753707466,16243831183524180494,7884763402771715161,13475068905671756760,11010170669119721037,6382371817003671828,1078059720271118072,4842768913766618015,15720503718519854837,14592164931114082964,7996463714287865990,8414592403852462049,14169299290784968522,4060711653373485820,4111977293811445900,5972313920249512614,14503338904686481914,18442936376755538938,853610924490134010,5995103723041214435,5244482493962307543,1835645656832363976,8915516699480127028,16079838935792009724,17464234296885755167,17954112023447812613,11969067906500175339,3179126973273099225,4851068153824553003,6280770671993490988,1142578918366373641,3130046610099306582,4101248734691052013,11986503735763886043,10759495559684135626,13933214535375396073,1550813233421627818,10801960483454286987,17367022665628661372,1738068280466190775,4950567308138571784,8999542742361547750,11375748948517250872,1382506962459336251,659045818495437661,16212925025387043982,16757137560167420704,17394556490012027670,10539369966946992287,2077848782268053954,13721442872952854556,13807208516968180383,4929533163606072472,11160912662217061000,928759259950778036,8707586165515507939,7623542887936493648,15145251366194998434,16946839221963337327,950426478290177121,16699187274465756008,11391186066649499005,16081729867205018817,1266912478173261913,18328954293543085540,15467444106962601547,173085038711193789,672953911948567940,13900136654708707624,17392028570287488858,12389329078987345836,12147336731113425686,2662939700866062749,5557321624551871470,8543039853409428736,8205725878029715447,4778907706296346357,6813768358167360658,17392931190042396407,8517323078121037612,1893624751237159657,11131835210361914070,2565575195320218403,17381366681341581496,4256270118983975759,10300190019202354155,148703056662686372,3851733962294311124,14668633931833846342,9035512193723159233,8767617612634842269,4106396825949188393,8626957507062660474,167032703880990547,16251503226530607743,15928675205463932118,4198516919799334384,11706334678765915005,15394470018489128880,16760295136005346543,18288304536906636618,13559676826159947576,6897858808629616701,6946639926600874508,3235777428244050611,7175431462473793726,1040380532713711825,15714275187832128608,11561827503790380123,16748731314095448099,2018677929418318481,14893704850223392665,6108057706881897267,6854339920521528788,14481326265439300104,17887940130022843060,15304377031217625593,14373844179418685409,16070868294804482148,15063720881414377234,1972668329099094098,6682089567065962534,3961831221701377388,1157213177097240928,983230227633311863,4050411904590708007,16673972949925277259,12438898181680104976,15937464819494484831,12781914589401373925,3445475401857816513,16164361628063122378,16468198194610278161,13631948306641664145,6394317992488837745,14521600227094496331,7595240750233461878,11734442057869796959,10065751306932957428,5328738962773704036,14962558782356437178,2278554783298031128,9967425162650253198,16154516079645666727,11078389306004946276,4196597061627881439,11480861675710778934,1838177424106232350,14735985993112356431,15513289393526497296,16951542274360225355,9815813113532855428,5208178046546546823,12000066374383483427,9038896719717611991,17868835744040593330,15585253465477116301,8000556062656671296,9922626883455474207,18041419253247757277,9345722212532309944,8140913213054830241,11995576174393087492,9283661061608526011,13935600936327571535,5350587070484495219,6352474482495382897,295437420212293496,13124692904696346698,10570099580682686854,3954365834038333079,9524673186465700277,9789171654167131586,1964957409587128224,6646039778568604340,4374679524439718596,615119991391555350,2013612983083696369,11563350218466643116,18312356166001799907,16535812971893257815,545277152036937913,6963981548244026692,869513218326402385,14236880587057840650,9927603364793970227,16006660855152350335,15517405147348907906,4729262541082890412,6579118012462874075,495055621714783895,14170107610710528624,9991973831098268220,1664419473294556118,13780861412840527415,10602120264247595353,3216668169055074878,15825207497378370871,1266952649175492251,9044770937763969488,18302554089479450684,12622041316062249148,1009393788500605287,18081054532164919341,2442127493648995728,10799031358451386914,14273577298474227892,11827798036761209277,2996524614936751543,1409395503001213478,13437469645892760633,689076809947399183,4427142600258984287,15158340584431618771,556177013713934247,16252542191456334482,1589041289998431402,12880167861201451079,12115373432079750921,9629793945755069397,5684302356805151901,5721048507750586829,8862732610079283106,1946067630276121569,16604780645927113709,10101996056420014370,15602394238827892409,7074163229003955683,12874641833681352923,18053023198913404278,11405299894553028427,3520033640114241087,242906217745981053,9187222217447196710,6422789786413388158,6072082720017414789,888714876889475158,12908625439191026817,11603044428933426839,12559548902573761135,4235074681821354824,18260888582393081811,6064188547127768216,15432497385961357235,5664817650706015690,15331213580100270902,18030879109519329667,8522957504850488099,435481000654089436,903906237697486320,13681515049195643287,4821023956909328885,14634387189033089191,13631309140930951633,11587179612325615861,7659471203085763555,6790308312750154988,3329823606766639980,12728718642757703650,11044600488212098247,18238502233633005947,330641549907270406,9819837130785555441,12428504052463973317,15075633766953829700,3204828240499265207,6439862112257729876,8403649722643762460,947347313674944273,13288358259345874165,18289706129080395251,1752762352604880316,162008436786802655,8121297550429247995,14238523131560017820,4061740822120984342,15233689080332937609,10216740687079077019,16508647401848419551,2997639361290432207,10162250676775994790,12867844427341295474,10302190304817287141,2499727571835820676,15319502690970111478,392373021640457765,9631285013979282800,15138494260977236806,4925220224581375907,14999621831496808689,10045779516110958722,13859949561174789864,9463288478965887902,13982839881715774419,2338868720979836951,11610390563315858357,18345462219308511154,4766486318090162299,9172661478160066982,12014162246991560208,16232964646137962499,10973309433347456532,14043866196203827083,3199261532234585666,9866092843106001156,6989030142969075809,12066107503157360115,8393188453490521044,15130152207113439674,12619725947547860589,18273252397046688202,9073840214643413072,14496558289898020100,14786105969165391866,16605353063326845744,9608621769189775004,5219555423149745778,487039271892417352,12605361748667984705,5244700003379545660,826580880136557484,9612175823599614489,17423109211463423328,5028695433013081097,11191170261532020816,6566751328762574619,13888921854497772791,12380619615117773695,3247238213855586696,14020807967346933296,10400891909851739763,18124726474925523849,14182727301003256028,4618713915755718310,15386577093660538711,15314696197704446800,2109275992123383456,3231823980849159358,16041857221280599868,15934655195049714086,4815647036315407238,7301444734230455584,2102378418495473058,7503702755751532910,10529867904458990514,7912460023149939615,2203201074218849869,2590833168259131747,7562930459442994679,15582022247703152480,9965746576821227173,3785313124398193378,3396858262965613098,15950409353315829979,2294610918007430244,15701401415150854332,16088906820050457705,5731578753998807143,18261126382752484055,13641220279227638982,1046267755266924222,15956610571085705400,12510952434099422153,15690169768732600145,1071342759835635407,449623970389372887,11583737067763544666,11054079799708774310,17861072205470449217,11663492391844029379,17445367962035182652,3777110137789728909,5688165136236061215,10790314018757302481,10731319711303407958,857917455032621424,7141422845359532742,7444996483944763567,6769690854826026128,4417402539939990010,2588762448170453292,1805465658541700893,9506650338893007981,7570430687964318101,9862538332657518469,10255970571088832344,14499558459738017508,16314325014660507312,18251210180943937248,9088613896890566648,3108843719887852112,13566652393669462330,2362293687119654402,5585556539268986332,17438951344171803325,7629944610328816337,8117199861601474937,932014708305135875,12832515311995143,7634489645473161641,13970161552862536141,16304015930177766120,2379648602864298044,6223951441079497394,15571945982668057720,4947489119959604719,13484112443131272554,15112157086636211503,12145081558819166873,701698393304330313,15418794494144743756,659950269966540114,17785015366816217221,5430575460140462690,6456066999293180092,8360763376053518922,3542181488247120777,4555527879113457652,5195337360153507147,18398194763368372169,15051305618430598175,15404592094900537094,17313203698078341206,11018768791963116504};
A_inv.fill(data);
// Generate random key
for(unsigned int i=start;i<end;i++){
if((i & 0xFFFFF) == 0){
cout<<i<<endl;
}
Vector key(key_size);
{
RNG rng(i);
for (auto& x : key)
x = rng.next_qword_safe();
}
Vector cut_key(37);
for(int j=0;j<37;j++){
cut_key[j] = key[j+4];
}
Vector clean = (result - cut_key);
Vector solution = A_inv * clean;
if(solution[0] == 51) {
cout<<"match at seed = "<<i<<endl;
for (int k=0;k<37;k++) {
cout << solution[k]<<" ";
}
}
}
}