| 32 | |
| 33 | template<template<class U> class T> |
| 34 | void preprocessing(vector<EcTuple<T>>& tuples, int buffer_size, |
| 35 | T<P256Element::Scalar>& sk, |
| 36 | SubProcessor<T<P256Element::Scalar>>& proc, |
| 37 | EcdsaOptions opts) |
| 38 | { |
| 39 | bool prep_mul = opts.prep_mul; |
| 40 | if (prep_mul) |
| 41 | proc.protocol.init_mul(); |
| 42 | |
| 43 | Timer timer; |
| 44 | timer.start(); |
| 45 | Player& P = proc.P; |
| 46 | auto& prep = proc.DataF; |
| 47 | size_t start = P.total_comm().sent; |
| 48 | auto stats = P.total_comm(); |
| 49 | auto& extra_player = P; |
| 50 | |
| 51 | auto& protocol = proc.protocol; |
| 52 | auto& MCp = proc.MC; |
| 53 | typedef T<typename P256Element::Scalar> pShare; |
| 54 | typedef T<P256Element> cShare; |
| 55 | vector<pShare> inv_ks; |
| 56 | vector<cShare> secret_Rs; |
| 57 | prep.buffer_triples(); |
| 58 | vector<pShare> bs, cs; |
| 59 | for (int i = 0; i < buffer_size; i++) |
| 60 | { |
| 61 | pShare a, b, c; |
| 62 | prep.get_three(DATA_TRIPLE, a, b, c); |
| 63 | inv_ks.push_back(a); |
| 64 | bs.push_back(b); |
| 65 | cs.push_back(c); |
| 66 | } |
| 67 | vector<P256Element::Scalar> cs_opened; |
| 68 | MCp.POpen_Begin(cs_opened, cs, extra_player); |
| 69 | if (opts.fewer_rounds) |
| 70 | secret_Rs.insert(secret_Rs.begin(), bs.begin(), bs.end()); |
| 71 | else |
| 72 | { |
| 73 | MCp.POpen_End(cs_opened, cs, extra_player); |
| 74 | for (int i = 0; i < buffer_size; i++) |
| 75 | secret_Rs.push_back(bs[i] / cs_opened[i]); |
| 76 | } |
| 77 | vector<P256Element> opened_Rs(buffer_size); |
| 78 | typename cShare::Direct_MC MCc(MCp.get_alphai()); |
| 79 | if (not opts.R_after_msg) |
| 80 | MCc.POpen_Begin(opened_Rs, secret_Rs, extra_player); |
| 81 | if (prep_mul) |
| 82 | { |
| 83 | for (int i = 0; i < buffer_size; i++) |
| 84 | protocol.prepare_mul(inv_ks[i], sk); |
| 85 | protocol.start_exchange(); |
| 86 | } |
| 87 | if (opts.fewer_rounds) |
| 88 | MCp.POpen_End(cs_opened, cs, extra_player); |
| 89 | if (not opts.R_after_msg) |
| 90 | { |
| 91 | MCc.POpen_End(opened_Rs, secret_Rs, extra_player); |
no test coverage detected