base.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  1. #include <iostream>
  2. #include "base.hpp"
  3. extern const scalar_t bn_n;
  4. extern const curvepoint_fp_t bn_curvegen;
  5. /* These lines need to be here so these static variables are defined,
  6. * but in C++ putting code here doesn't actually execute
  7. * (or at least, with g++, whenever it would execute is not at a useful time)
  8. * so we have an init() function to actually put the correct values in them. */
  9. Curvepoint PrsonaBase::EL_GAMAL_GENERATOR = Curvepoint();
  10. Scalar PrsonaBase::SCALAR_N = Scalar();
  11. Scalar PrsonaBase::DEFAULT_TALLY = Scalar();
  12. Scalar PrsonaBase::DEFAULT_VOTE = Scalar();
  13. bool PrsonaBase::SERVER_IS_MALICIOUS = false;
  14. bool PrsonaBase::CLIENT_IS_MALICIOUS = false;
  15. size_t PrsonaBase::MAX_ALLOWED_VOTE = 2;
  16. // Quick and dirty function to calculate ceil(log base 2) with mpz_class
  17. mpz_class log2(mpz_class x)
  18. {
  19. mpz_class retval = 0;
  20. while (x > 0)
  21. {
  22. retval++;
  23. x = x >> 1;
  24. }
  25. return retval;
  26. }
  27. mpz_class bit(mpz_class x)
  28. {
  29. return x > 0 ? 1 : 0;
  30. }
  31. /********************
  32. * PUBLIC FUNCTIONS *
  33. ********************/
  34. /*
  35. * SETUP FUNCTIONS
  36. */
  37. // Must be called once before any usage of this class
  38. void PrsonaBase::init()
  39. {
  40. EL_GAMAL_GENERATOR = Curvepoint(bn_curvegen);
  41. SCALAR_N = Scalar(bn_n);
  42. DEFAULT_TALLY = Scalar(1);
  43. DEFAULT_VOTE = Scalar(1);
  44. }
  45. // Call this (once) if using malicious-security servers
  46. void PrsonaBase::set_server_malicious()
  47. {
  48. SERVER_IS_MALICIOUS = true;
  49. }
  50. // Call this (once) if using malicious-security clients
  51. void PrsonaBase::set_client_malicious()
  52. {
  53. CLIENT_IS_MALICIOUS = true;
  54. }
  55. /*
  56. * CONST GETTERS
  57. */
  58. size_t PrsonaBase::get_max_allowed_vote()
  59. {
  60. return MAX_ALLOWED_VOTE;
  61. }
  62. Curvepoint PrsonaBase::get_blinding_generator() const
  63. {
  64. return elGamalBlindGenerator;
  65. }
  66. Curvepoint PrsonaBase::get_blinding_generator(std::vector<Proof>& pi) const
  67. {
  68. pi = elGamalBlindGeneratorProof;
  69. return elGamalBlindGenerator;
  70. }
  71. /***********************
  72. * PROTECTED FUNCTIONS *
  73. ***********************/
  74. /*
  75. * PRIVATE ELEMENT SETTER
  76. */
  77. bool PrsonaBase::set_EG_blind_generator(
  78. const std::vector<Proof>& pi,
  79. const Curvepoint& currGenerator,
  80. size_t numServers)
  81. {
  82. if (!verify_generator_proof(pi, currGenerator, numServers))
  83. return false;
  84. elGamalBlindGeneratorProof = pi;
  85. elGamalBlindGenerator = currGenerator;
  86. return true;
  87. }
  88. /*
  89. * SCHNORR PROOFS
  90. */
  91. Proof PrsonaBase::schnorr_generation(
  92. const Curvepoint& generator,
  93. const Curvepoint& commitment,
  94. const Scalar& log) const
  95. {
  96. Proof retval;
  97. std::stringstream oracleInput;
  98. Scalar r;
  99. r.set_random();
  100. Curvepoint U = generator * r;
  101. oracleInput << generator << commitment << U;
  102. Scalar c = oracle(oracleInput.str());
  103. Scalar z = r.curveAdd(c.curveMult(log));
  104. retval.challengeParts.push_back(c);
  105. retval.responseParts.push_back(z);
  106. return retval;
  107. }
  108. bool PrsonaBase::schnorr_verification(
  109. const Curvepoint& generator,
  110. const Curvepoint& commitment,
  111. const Scalar& c,
  112. const Scalar& z) const
  113. {
  114. Curvepoint U = generator * z - commitment * c;
  115. std::stringstream oracleInput;
  116. oracleInput << generator << commitment << U;
  117. return c == oracle(oracleInput.str());
  118. }
  119. /*
  120. * OWNERSHIP PROOFS
  121. */
  122. // Prove ownership of the short term public key
  123. Proof PrsonaBase::generate_ownership_proof(
  124. const Curvepoint& generator,
  125. const Curvepoint& commitment,
  126. const Scalar& log) const
  127. {
  128. if (!CLIENT_IS_MALICIOUS)
  129. {
  130. Proof retval;
  131. retval.basic = "PROOF";
  132. return retval;
  133. }
  134. return schnorr_generation(generator, commitment, log);
  135. }
  136. bool PrsonaBase::verify_ownership_proof(
  137. const Proof& pi,
  138. const Curvepoint& generator,
  139. const Curvepoint& commitment) const
  140. {
  141. if (!CLIENT_IS_MALICIOUS)
  142. return pi.basic == "PROOF";
  143. Scalar c = pi.challengeParts[0];
  144. Scalar z = pi.responseParts[0];
  145. return schnorr_verification(generator, commitment, c, z);
  146. }
  147. /*
  148. * ITERATED SCHNORR PROOFS
  149. */
  150. Proof PrsonaBase::add_to_generator_proof(
  151. const Curvepoint& currGenerator,
  152. const Scalar& seed) const
  153. {
  154. Proof retval;
  155. if (!CLIENT_IS_MALICIOUS)
  156. {
  157. retval.basic = "PROOF";
  158. return retval;
  159. }
  160. Curvepoint nextGenerator = currGenerator * seed;
  161. retval = schnorr_generation(currGenerator, nextGenerator, seed);
  162. retval.partialUniversals.push_back(currGenerator);
  163. return retval;
  164. }
  165. bool PrsonaBase::verify_generator_proof(
  166. const std::vector<Proof>& pi,
  167. const Curvepoint& currGenerator,
  168. size_t numServers) const
  169. {
  170. if (pi.size() != numServers || numServers == 0)
  171. return false;
  172. bool retval = true;
  173. if (!SERVER_IS_MALICIOUS)
  174. {
  175. for (size_t i = 0; i < pi.size(); i++)
  176. retval = retval && pi[i].basic == "PROOF";
  177. return retval;
  178. }
  179. if (pi[0].partialUniversals[0] != EL_GAMAL_GENERATOR)
  180. return false;
  181. for (size_t i = 0; i < pi.size(); i++)
  182. {
  183. Curvepoint generator = pi[i].partialUniversals[0];
  184. Curvepoint commitment = (i == pi.size() - 1 ?
  185. currGenerator :
  186. pi[i + 1].partialUniversals[0]);
  187. Scalar c = pi[i].challengeParts[0];
  188. Scalar z = pi[i].responseParts[0];
  189. retval = retval &&
  190. schnorr_verification(generator, commitment, c, z);
  191. if (!retval)
  192. std::cerr << "Error in index " << i+1 << " of " << pi.size() << std::endl;
  193. }
  194. return retval;
  195. }
  196. /*
  197. * REPUTATION PROOFS
  198. */
  199. // A pretty straightforward range proof (generation)
  200. std::vector<Proof> PrsonaBase::generate_reputation_proof(
  201. const Proof& ownershipProof,
  202. const EGCiphertext& commitment,
  203. const Scalar& currentScore,
  204. const Scalar& threshold,
  205. const Scalar& inverseKey,
  206. size_t numClients) const
  207. {
  208. std::vector<Proof> retval;
  209. // Base case
  210. if (!CLIENT_IS_MALICIOUS)
  211. {
  212. retval.push_back(Proof("PROOF"));
  213. return retval;
  214. }
  215. // Don't even try if the user asks to make an illegitimate proof
  216. if (threshold.toInt() > (numClients * MAX_ALLOWED_VOTE))
  217. return retval;
  218. // We really have two consecutive proofs in a junction.
  219. // The first is to prove that we are the stpk we claim we are
  220. retval.push_back(ownershipProof);
  221. // The value we're actually using in our proof
  222. mpz_class proofVal = currentScore.curveSub(threshold).toInt();
  223. // Top of the range in our proof determined by what scores are even possible
  224. mpz_class proofBits =
  225. log2(numClients * MAX_ALLOWED_VOTE - threshold.toInt());
  226. // Don't risk a situation that would divulge our private key
  227. if (proofBits <= 1)
  228. proofBits = 2;
  229. // This seems weird, but remember our base is A_t^r, not g^t
  230. std::vector<Scalar> masksPerBit;
  231. masksPerBit.push_back(inverseKey);
  232. for (size_t i = 1; i < proofBits; i++)
  233. {
  234. Scalar currMask;
  235. currMask.set_random();
  236. masksPerBit.push_back(currMask);
  237. masksPerBit[0] =
  238. masksPerBit[0].curveSub(currMask.curveMult(Scalar(1 << i)));
  239. }
  240. // Taken from Fig. 1 in https://eprint.iacr.org/2014/764.pdf
  241. for (size_t i = 0; i < proofBits; i++)
  242. {
  243. Proof currProof;
  244. Curvepoint g, h, c, c_a, c_b;
  245. g = commitment.mask;
  246. h = elGamalBlindGenerator;
  247. mpz_class currBit = bit(proofVal & (1 << i));
  248. Scalar a, s, t, m, r;
  249. a.set_random();
  250. s.set_random();
  251. t.set_random();
  252. m = Scalar(currBit);
  253. r = masksPerBit[i];
  254. c = g * r + h * m;
  255. currProof.partialUniversals.push_back(c);
  256. c_a = g * s + h * a;
  257. Scalar am = a.curveMult(m);
  258. c_b = g * t + h * am;
  259. std::stringstream oracleInput;
  260. oracleInput << g << h << c << c_a << c_b;
  261. Scalar x = oracle(oracleInput.str());
  262. currProof.challengeParts.push_back(x);
  263. Scalar f, z_a, z_b;
  264. Scalar mx = m.curveMult(x);
  265. f = mx.curveAdd(a);
  266. Scalar rx = r.curveMult(x);
  267. z_a = rx.curveAdd(s);
  268. Scalar x_f = x.curveSub(f);
  269. Scalar r_x_f = r.curveMult(x_f);
  270. z_b = r_x_f.curveAdd(t);
  271. currProof.responseParts.push_back(f);
  272. currProof.responseParts.push_back(z_a);
  273. currProof.responseParts.push_back(z_b);
  274. retval.push_back(currProof);
  275. }
  276. return retval;
  277. }
  278. // A pretty straightforward range proof (verification)
  279. bool PrsonaBase::verify_reputation_proof(
  280. const std::vector<Proof>& pi,
  281. const Curvepoint& generator,
  282. const Curvepoint& owner,
  283. const EGCiphertext& commitment,
  284. const Scalar& threshold) const
  285. {
  286. // Reject outright if there's no proof to check
  287. if (pi.empty())
  288. {
  289. std::cerr << "Proof was empty, aborting." << std::endl;
  290. return false;
  291. }
  292. // If the range is so big that it wraps around mod n,
  293. // there's a chance the user actually made a proof for a very low reputation
  294. if (pi.size() > 256)
  295. {
  296. std::cerr << "Proof was too big, prover could have cheated." << std::endl;
  297. return false;
  298. }
  299. if (!CLIENT_IS_MALICIOUS)
  300. return pi[0].basic == "PROOF";
  301. Scalar c, z;
  302. c = pi[0].challengeParts[0];
  303. z = pi[0].responseParts[0];
  304. // User should be able to prove they are who they say they are
  305. if (!schnorr_verification(generator, owner, c, z))
  306. {
  307. std::cerr << "Schnorr proof failed, aborting." << std::endl;
  308. return false;
  309. }
  310. // X is the thing we're going to be checking in on throughout
  311. // to try to get our score commitment back in the end.
  312. Curvepoint X;
  313. for (size_t i = 1; i < pi.size(); i++)
  314. {
  315. Curvepoint c, g, h;
  316. c = pi[i].partialUniversals[0];
  317. g = commitment.mask;
  318. h = elGamalBlindGenerator;
  319. X = X + c * Scalar(1 << (i - 1));
  320. Scalar x, f, z_a, z_b;
  321. x = pi[i].challengeParts[0];
  322. f = pi[i].responseParts[0];
  323. z_a = pi[i].responseParts[1];
  324. z_b = pi[i].responseParts[2];
  325. // Taken from Fig. 1 in https://eprint.iacr.org/2014/764.pdf
  326. Curvepoint c_a, c_b;
  327. c_a = g * z_a + h * f - c * x;
  328. Scalar x_f = x.curveSub(f);
  329. c_b = g * z_b - c * x_f;
  330. std::stringstream oracleInput;
  331. oracleInput << g << h << c << c_a << c_b;
  332. if (oracle(oracleInput.str()) != pi[i].challengeParts[0])
  333. {
  334. std::cerr << "0 or 1 proof failed at index " << i << " of " << pi.size() - 1 << ", aborting." << std::endl;
  335. return false;
  336. }
  337. }
  338. Scalar negThreshold;
  339. negThreshold = Scalar(0).curveSub(threshold);
  340. Curvepoint scoreCommitment =
  341. commitment.encryptedMessage +
  342. elGamalBlindGenerator * negThreshold;
  343. return X == scoreCommitment;
  344. }
  345. /*
  346. * VALID VOTE PROOFS
  347. */
  348. std::vector<Proof> PrsonaBase::generate_vote_proof(
  349. const Proof& ownershipProof,
  350. const CurveBipoint& g,
  351. const CurveBipoint& h,
  352. const std::vector<bool>& replaces,
  353. const std::vector<CurveBipoint>& oldEncryptedVotes,
  354. const std::vector<CurveBipoint>& newEncryptedVotes,
  355. const std::vector<Scalar>& seeds,
  356. const std::vector<Scalar>& votes) const
  357. {
  358. std::vector<Proof> retval;
  359. // Base case
  360. if (!CLIENT_IS_MALICIOUS)
  361. {
  362. retval.push_back(Proof("PROOF"));
  363. return retval;
  364. }
  365. // The first need is to prove that we are the stpk we claim we are
  366. retval.push_back(ownershipProof);
  367. // Then, we iterate over all votes for the proofs that they are correct
  368. for (size_t i = 0; i < replaces.size(); i++)
  369. {
  370. std::stringstream oracleInput;
  371. oracleInput << g << h << oldEncryptedVotes[i] << newEncryptedVotes[i];
  372. /* This proof structure is documented in my notes.
  373. * It's inspired by the proof in Fig. 1 at
  374. * https://eprint.iacr.org/2014/764.pdf, but adapted so that you prove
  375. * m(m-1)(m-2) = 0 instead of m(m-1) = 0.
  376. *
  377. * The rerandomization part is just a slight variation on an
  378. * ordinary Schnorr proof, so that part's less scary. */
  379. if (replaces[i]) // CASE: Make new vote
  380. {
  381. Proof currProof;
  382. Scalar c_r, z_r, a, s, t_1, t_2;
  383. c_r.set_random();
  384. z_r.set_random();
  385. a.set_random();
  386. s.set_random();
  387. t_1.set_random();
  388. t_2.set_random();
  389. CurveBipoint U = h * z_r +
  390. oldEncryptedVotes[i] * c_r -
  391. newEncryptedVotes[i] * c_r;
  392. CurveBipoint C_a = g * a + h * s;
  393. Scalar power = (a.curveAdd(a)).curveMult(votes[i].curveMult(votes[i]));
  394. power =
  395. power.curveSub((a.curveAdd(a).curveAdd(a)).curveMult(votes[i]));
  396. CurveBipoint C_b = g * power + h * t_1;
  397. currProof.partialUniversals.push_back(C_b[0]);
  398. currProof.partialUniversals.push_back(C_b[1]);
  399. CurveBipoint C_c = g * a.curveMult(a.curveMult(votes[i])) +
  400. h * t_2;
  401. oracleInput << U << C_a << C_b << C_c;
  402. Scalar c = oracle(oracleInput.str());
  403. Scalar c_n = c.curveSub(c_r);
  404. currProof.challengeParts.push_back(c_r);
  405. currProof.challengeParts.push_back(c_n);
  406. Scalar f = (votes[i].curveMult(c_n)).curveAdd(a);
  407. Scalar z_na = (seeds[i].curveMult(c_n)).curveAdd(s);
  408. Scalar t_1_c_n_t_2 = (t_1.curveMult(c_n)).curveAdd(t_2);
  409. Scalar f_c_n = f.curveSub(c_n);
  410. Scalar c_n2_f = c_n.curveAdd(c_n).curveSub(f);
  411. Scalar z_nb =
  412. (seeds[i].curveMult(f_c_n).curveMult(c_n2_f)).curveAdd(
  413. t_1_c_n_t_2);
  414. currProof.responseParts.push_back(z_r);
  415. currProof.responseParts.push_back(f);
  416. currProof.responseParts.push_back(z_na);
  417. currProof.responseParts.push_back(z_nb);
  418. retval.push_back(currProof);
  419. }
  420. else // CASE: Rerandomize existing vote
  421. {
  422. Proof currProof;
  423. Scalar u, commitmentLambda_1, commitmentLambda_2,
  424. c_n, z_na, z_nb, f;
  425. u.set_random();
  426. commitmentLambda_1.set_random();
  427. commitmentLambda_2.set_random();
  428. c_n.set_random();
  429. z_na.set_random();
  430. z_nb.set_random();
  431. f.set_random();
  432. CurveBipoint U = h * u;
  433. CurveBipoint C_a = g * f +
  434. h * z_na -
  435. newEncryptedVotes[i] * c_n;
  436. CurveBipoint C_b = g * commitmentLambda_1 + h * commitmentLambda_2;
  437. currProof.partialUniversals.push_back(C_b[0]);
  438. currProof.partialUniversals.push_back(C_b[1]);
  439. Scalar f_c_n = f.curveSub(c_n);
  440. Scalar c_n2_f = c_n.curveAdd(c_n).curveSub(f);
  441. CurveBipoint C_c =
  442. h * z_nb -
  443. newEncryptedVotes[i] * f_c_n.curveMult(c_n2_f) -
  444. C_b * c_n;
  445. oracleInput << U << C_a << C_b << C_c;
  446. Scalar c = oracle(oracleInput.str());
  447. Scalar c_r = c.curveSub(c_n);
  448. currProof.challengeParts.push_back(c_r);
  449. currProof.challengeParts.push_back(c_n);
  450. Scalar z_r = u.curveAdd(c_r.curveMult(seeds[i]));
  451. currProof.responseParts.push_back(z_r);
  452. currProof.responseParts.push_back(f);
  453. currProof.responseParts.push_back(z_na);
  454. currProof.responseParts.push_back(z_nb);
  455. retval.push_back(currProof);
  456. }
  457. }
  458. return retval;
  459. }
  460. bool PrsonaBase::verify_vote_proof(
  461. const CurveBipoint& g,
  462. const CurveBipoint& h,
  463. const std::vector<Proof>& pi,
  464. const std::vector<CurveBipoint>& oldEncryptedVotes,
  465. const std::vector<CurveBipoint>& newEncryptedVotes,
  466. const Curvepoint& freshGenerator,
  467. const Curvepoint& owner) const
  468. {
  469. // Reject outright if there's no proof to check
  470. if (pi.empty())
  471. {
  472. std::cerr << "Proof was empty, aborting." << std::endl;
  473. return false;
  474. }
  475. // Base case
  476. if (!CLIENT_IS_MALICIOUS)
  477. return pi[0].basic == "PROOF";
  478. // User should be able to prove they are who they say they are
  479. if (!verify_ownership_proof(pi[0], freshGenerator, owner))
  480. {
  481. std::cerr << "Schnorr proof failed, aborting." << std::endl;
  482. return false;
  483. }
  484. /* This proof structure is documented in my notes.
  485. * It's inspired by the proof in Fig. 1 at
  486. * https://eprint.iacr.org/2014/764.pdf, but adapted so that you prove
  487. * m(m-1)(m-2) = 0 instead of m(m-1) = 0.
  488. *
  489. * The rerandomization part is just a slight variation on an
  490. * ordinary Schnorr proof, so that part's less scary. */
  491. for (size_t i = 1; i < pi.size(); i++)
  492. {
  493. size_t voteIndex = i - 1;
  494. Curvepoint C_b_0, C_b_1;
  495. C_b_0 = pi[i].partialUniversals[0];
  496. C_b_1 = pi[i].partialUniversals[1];
  497. CurveBipoint C_b(C_b_0, C_b_1);
  498. Scalar c_r, c_n, z_r, f, z_na, z_nb;
  499. c_r = pi[i].challengeParts[0];
  500. c_n = pi[i].challengeParts[1];
  501. z_r = pi[i].responseParts[0];
  502. f = pi[i].responseParts[1];
  503. z_na = pi[i].responseParts[2];
  504. z_nb = pi[i].responseParts[3];
  505. CurveBipoint U, C_a, C_c;
  506. U = h * z_r +
  507. oldEncryptedVotes[voteIndex] * c_r -
  508. newEncryptedVotes[voteIndex] * c_r;
  509. C_a = g * f + h * z_na - newEncryptedVotes[voteIndex] * c_n;
  510. Scalar f_c_n = f.curveSub(c_n);
  511. Scalar c_n2_f = c_n.curveAdd(c_n).curveSub(f);
  512. C_c = h * z_nb -
  513. newEncryptedVotes[voteIndex] * f_c_n.curveMult(c_n2_f) -
  514. C_b * c_n;
  515. std::stringstream oracleInput;
  516. oracleInput << g << h
  517. << oldEncryptedVotes[voteIndex] << newEncryptedVotes[voteIndex]
  518. << U << C_a << C_b << C_c;
  519. if (oracle(oracleInput.str()) != c_r.curveAdd(c_n))
  520. return false;
  521. }
  522. return true;
  523. }
  524. /*
  525. * EPOCH PROOFS
  526. */
  527. bool PrsonaBase::verify_update_proof(
  528. const Proof& pi) const
  529. {
  530. if (!SERVER_IS_MALICIOUS)
  531. return pi.basic == "PROOF";
  532. return pi.basic == "PROOF";
  533. }
  534. /*
  535. * SERVER AGREEMENT PROOFS
  536. */
  537. Proof PrsonaBase::generate_valid_default_tally_proof() const
  538. {
  539. Proof retval;
  540. if (!SERVER_IS_MALICIOUS)
  541. {
  542. retval.basic = "PROOF";
  543. return retval;
  544. }
  545. retval.basic = "PROOF";
  546. return retval;
  547. }
  548. Proof PrsonaBase::generate_valid_fresh_generator_proof() const
  549. {
  550. Proof retval;
  551. if (!SERVER_IS_MALICIOUS)
  552. {
  553. retval.basic = "PROOF";
  554. return retval;
  555. }
  556. retval.basic = "PROOF";
  557. return retval;
  558. }
  559. Proof PrsonaBase::generate_votes_valid_proof() const
  560. {
  561. Proof retval;
  562. if (!SERVER_IS_MALICIOUS)
  563. {
  564. retval.basic = "PROOF";
  565. return retval;
  566. }
  567. retval.basic = "PROOF";
  568. return retval;
  569. }
  570. Proof PrsonaBase::generate_proof_of_added_user() const
  571. {
  572. Proof retval;
  573. if (!SERVER_IS_MALICIOUS)
  574. {
  575. retval.basic = "PROOF";
  576. return retval;
  577. }
  578. retval.basic = "PROOF";
  579. return retval;
  580. }
  581. Proof PrsonaBase::generate_score_proof() const
  582. {
  583. Proof retval;
  584. if (!SERVER_IS_MALICIOUS)
  585. {
  586. retval.basic = "PROOF";
  587. return retval;
  588. }
  589. retval.basic = "PROOF";
  590. return retval;
  591. }
  592. Proof PrsonaBase::generate_proof_of_correct_tally() const
  593. {
  594. Proof retval;
  595. if (!SERVER_IS_MALICIOUS)
  596. {
  597. retval.basic = "PROOF";
  598. return retval;
  599. }
  600. retval.basic = "PROOF";
  601. return retval;
  602. }
  603. Proof PrsonaBase::generate_proof_of_correct_sum() const
  604. {
  605. Proof retval;
  606. if (!SERVER_IS_MALICIOUS)
  607. {
  608. retval.basic = "PROOF";
  609. return retval;
  610. }
  611. retval.basic = "PROOF";
  612. return retval;
  613. }
  614. Proof PrsonaBase::generate_proof_of_shuffle() const
  615. {
  616. Proof retval;
  617. if (!SERVER_IS_MALICIOUS)
  618. {
  619. retval.basic = "PROOF";
  620. return retval;
  621. }
  622. retval.basic = "PROOF";
  623. return retval;
  624. }
  625. Proof PrsonaBase::generate_valid_pseudonyms_proof() const
  626. {
  627. Proof retval;
  628. if (!SERVER_IS_MALICIOUS)
  629. {
  630. retval.basic = "PROOF";
  631. return retval;
  632. }
  633. retval.basic = "PROOF";
  634. return retval;
  635. }
  636. bool PrsonaBase::verify_valid_tally_proof(const Proof& pi) const
  637. {
  638. if (!SERVER_IS_MALICIOUS)
  639. return pi.basic == "PROOF";
  640. return pi.basic == "PROOF";
  641. }
  642. bool PrsonaBase::verify_score_proof(const Proof& pi) const
  643. {
  644. if (!SERVER_IS_MALICIOUS)
  645. return pi.basic == "PROOF";
  646. return pi.basic == "PROOF";
  647. }
  648. bool PrsonaBase::verify_default_tally_proof(const Proof& pi) const
  649. {
  650. if (!SERVER_IS_MALICIOUS)
  651. return pi.basic == "PROOF";
  652. return pi.basic == "PROOF";
  653. }
  654. bool PrsonaBase::verify_default_votes_proof(const Proof& pi) const
  655. {
  656. if (!SERVER_IS_MALICIOUS)
  657. return pi.basic == "PROOF";
  658. return pi.basic == "PROOF";
  659. }
  660. bool PrsonaBase::verify_valid_votes_proof(const Proof& pi) const
  661. {
  662. if (!SERVER_IS_MALICIOUS)
  663. return pi.basic == "PROOF";
  664. return pi.basic == "PROOF";
  665. }
  666. bool PrsonaBase::verify_valid_pseudonyms_proof(const Proof& pi) const
  667. {
  668. if (!SERVER_IS_MALICIOUS)
  669. return pi.basic == "PROOF";
  670. return pi.basic == "PROOF";
  671. }