-rw-r--r-- 691 cryptattacktester-20231020/parity_cost.cpp raw
#include "bit_vector_cost.h"
#include "ram_cost.h"
#include "parity_cost.h"
bigint parity_known_cost(bigint N,bigint K)
{
--K;
bigint R = N-K;
bigint result = 0;
result += R-1; // s.at(0) ^= s.at(j);
result += (K+1)*(R-1); // H.at(i).at(0) ^= H.at(i).at(j);
result += bit_vector_first_one_cost(K); // bit_vector_first_one(row);
result += ram_read_write_cost(K,nbits(K-1),N-K); // ram_read_write(H, 0, K, idx, H.at(K));
result += ram_read_write_cost(K,nbits(K-1),nbits(N-1)); // ram_read_write(map, 0, K, idx, map.at(K));
result += (R-1)*2; // s.at(j) ^= s.at(0) & H.at(K).at(j);
result += K*(R-1)*2; // H.at(i).at(j) ^= H.at(i).at(0) & H.at(K).at(j);
return result;
}