/* * ReplicatedInput.h * */ #ifndef PROTOCOLS_REPLICATEDINPUT_H_ #define PROTOCOLS_REPLICATEDINPUT_H_ #include "Processor/Input.h" #include "Processor/Processor.h" #include "Replicated.h" template class Beaver; template class AstraOnlineBase; template class AstraPrepProtocol; /** * Base class for input protocols without preprocessing */ template class PrepLessInput : public InputBase { protected: IteratorVector shares; public: PrepLessInput(SubProcessor* proc) : InputBase(proc ? proc->Proc : 0) {} virtual ~PrepLessInput() {} virtual void reset(int player) = 0; virtual void add_mine(const typename T::open_type& input, int n_bits = -1) = 0; virtual void add_other(int player, int n_bits = - 1) = 0; virtual void finalize_other(int player, T& target, octetStream& o, int n_bits = -1) = 0; T finalize_mine() final; }; /** * Replicated three-party input protocol */ template class ReplicatedInput : public PrepLessInput { SubProcessor* proc; Player& P; vector os; SeededPRNG secure_prng; ReplicatedBase protocol; vector expect; octetStream dest; octetStream* to_send; public: ReplicatedInput(SubProcessor& proc) : ReplicatedInput(&proc, proc.P) { } ReplicatedInput(SubProcessor& proc, ReplicatedMC& MC) : ReplicatedInput(proc) { (void) MC; } ReplicatedInput(typename T::MAC_Check& MC, Preprocessing& prep, Player& P, typename T::Protocol* = 0) : ReplicatedInput(P) { (void) MC, (void) prep; } ReplicatedInput(Player& P) : ReplicatedInput(0, P) { } ReplicatedInput(SubProcessor* proc, const ReplicatedBase& protocol) : PrepLessInput(proc), proc(proc), P(protocol.P), protocol(protocol.branch()), to_send(0) { assert(T::vector_length == 2); expect.resize(P.num_players()); this->reset_all(P); } template ReplicatedInput(SubProcessor*, const Beaver& protocol) : ReplicatedInput(protocol.P) { throw runtime_error("should not be called"); } template ReplicatedInput(SubProcessor*, const AstraOnlineBase& protocol) : ReplicatedInput(protocol.P) { throw runtime_error("should not be called"); } template ReplicatedInput(SubProcessor* proc, const AstraPrepProtocol& protocol); void reset(int player); void prepare(size_t n_inputs); void add_mine(const typename T::open_type& input, int n_bits = -1) final; void add_mine_prepared(T& share, const typename T::open_type& input); void add_other(int player, int n_bits = -1); void send_mine(); void exchange(); void finalize_other(int player, T& target, octetStream& o, int n_bits = -1); T finalize_offset(int offset); double randomness_time() { return protocol.randomness_time(); } }; #endif /* PROTOCOLS_REPLICATEDINPUT_H_ */