algorithm/deal_share.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020 Ilias Khairullin <ilias@nil.foundation>
4 //
5 // MIT License
6 //
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
13 //
14 // The above copyright notice and this permission notice shall be included in all
15 // copies or substantial portions of the Software.
16 //
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 // SOFTWARE.
24 //---------------------------------------------------------------------------//
25 
26 #ifndef CRYPTO3_PUBKEY_DEAL_SHARE_HPP
27 #define CRYPTO3_PUBKEY_DEAL_SHARE_HPP
28 
30 
33 
35 
36 namespace nil {
37  namespace crypto3 {
38  namespace pubkey {
39  template<typename Scheme>
41 
42  template<typename Scheme>
44  typename modes::isomorphic<Scheme>::template bind<share_dealing_policy<Scheme>>::type;
45  } // namespace pubkey
46 
65  template<typename Scheme, typename InputIterator, typename OutputIterator,
67  OutputIterator deal_share(std::size_t i, InputIterator first, InputIterator last, OutputIterator out) {
68 
69  typedef typename pubkey::share_dealing_accumulator_set<ProcessingMode> DealingAccumulator;
70 
73 
74  return SchemeImpl(first, last, std::move(out), DealingAccumulator(i));
75  }
76 
94  template<typename Scheme, typename SinglePassRange, typename OutputIterator,
95  typename ProcessingMode = pubkey::share_dealing_processing_mode_default<Scheme>>
96  OutputIterator deal_share(std::size_t i, const SinglePassRange &range, OutputIterator out) {
97 
98  typedef typename pubkey::share_dealing_accumulator_set<ProcessingMode> DealingAccumulator;
99 
102 
103  return SchemeImpl(range, std::move(out), DealingAccumulator(i));
104  }
105 
124  template<typename Scheme, typename InputIterator,
125  typename ProcessingMode = pubkey::share_dealing_processing_mode_default<Scheme>,
126  typename OutputAccumulator = typename pubkey::share_dealing_accumulator_set<ProcessingMode>>
127  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
128  OutputAccumulator>::type &
129  deal_share(InputIterator first, InputIterator last, OutputAccumulator &acc) {
130 
133 
134  return SchemeImpl(first, last, std::forward<OutputAccumulator>(acc));
135  }
136 
154  template<typename Scheme, typename SinglePassRange,
155  typename ProcessingMode = pubkey::share_dealing_processing_mode_default<Scheme>,
156  typename OutputAccumulator = typename pubkey::share_dealing_accumulator_set<ProcessingMode>>
157  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
158  OutputAccumulator>::type &
159  deal_share(const SinglePassRange &range, OutputAccumulator &acc) {
160 
163 
164  return SchemeImpl(range, std::forward<OutputAccumulator>(acc));
165  }
166 
186  template<typename Scheme, typename InputIterator,
187  typename ProcessingMode = pubkey::share_dealing_processing_mode_default<Scheme>,
188  typename DealingAccumulator = typename pubkey::share_dealing_accumulator_set<ProcessingMode>,
189  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<DealingAccumulator>,
190  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
191  SchemeImpl deal_share(std::size_t i, InputIterator first, InputIterator last) {
192 
193  return SchemeImpl(first, last, DealingAccumulator(i));
194  }
195 
214  template<typename Scheme, typename SinglePassRange,
215  typename ProcessingMode = pubkey::share_dealing_processing_mode_default<Scheme>,
216  typename DealingAccumulator = typename pubkey::share_dealing_accumulator_set<ProcessingMode>,
217  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<DealingAccumulator>,
218  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
219  SchemeImpl deal_share(std::size_t i, const SinglePassRange &range) {
220 
221  return SchemeImpl(range, DealingAccumulator(i));
222  }
223  } // namespace crypto3
224 } // namespace nil
225 
226 #endif // include guard
OutputIterator deal_share(std::size_t i, InputIterator first, InputIterator last, OutputIterator out)
Deal share of specified participant using passed shares, dealt by other participant for the current.
Definition: algorithm/deal_share.hpp:67
OutputIterator move(const SinglePassRange &rng, OutputIterator result)
Definition: move.hpp:45
boost::mpl::apply< AccumulatorSet, tag::pubkey< ProcessingMode > >::type::result_type pubkey(const AccumulatorSet &acc)
Definition: accumulators/pubkey.hpp:106
typename pubkey::modes::isomorphic< Scheme >::share_dealing_policy share_dealing_policy
Definition: algorithm/deal_share.hpp:40
typename modes::isomorphic< Scheme >::template bind< share_dealing_policy< Scheme > >::type share_dealing_processing_mode_default
Definition: algorithm/deal_share.hpp:44
boost::accumulators::accumulator_set< typename ProcessingMode::result_type, boost::accumulators::features< accumulators::tag::deal_share< ProcessingMode > >> share_dealing_accumulator_set
Definition: secret_sharing_state.hpp:61
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: isomorphic.hpp:219