-rw-r--r-- 944 cryptattacktester-20231020/predictedprob.cpp raw
#include <iostream>
#include "problem.h"
#include "attack.h"
#include "collision_prob.h"
using namespace std;
int attack_handle(const problem &E,const vector<bigint> &P,const attack &A,const vector<bigint> &Q)
{
bigfloat prob = A.prob(P,Q);
bigfloat lgprob = log2(prob);
bigfloat numinputs = E.numinputs(P);
bigfloat numoutputs = E.numoutputs(P);
bigfloat prob2 = collision_lastmatch_prob(prob*numinputs,numinputs,numoutputs);
bigfloat lgprob2 = log2(prob2);
cout << "predictedprob";
cout << " problem=" << E.name;
for (bigint j = 0;j < P.size();++j)
cout << (j ? ',' : ' ') << E.paramnames.at(j) << "=" << P.at(j);
cout << " attack=" << A.name;
for (bigint j = 0;j < Q.size();++j)
cout << (j ? ',' : ' ') << A.paramnames.at(j) << "=" << Q.at(j);
cout << " prob " << prob;
cout << " lgprob " << lgprob;
cout << " prob2 " << prob2;
cout << " lgprob2 " << lgprob2;
cout << '\n' << flush;
return 1;
}