reconstruct_public_secret.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2021 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_RECONSTRUCT_PUBLIC_SECRET_HPP
27 #define CRYPTO3_PUBKEY_RECONSTRUCT_PUBLIC_SECRET_HPP
28 
30 
33 
35 
36 namespace nil {
37  namespace crypto3 {
38  namespace pubkey {
39  template<typename Scheme>
42 
43  template<typename Scheme>
44  using public_secret_reconstructing_processing_mode =
45  typename modes::isomorphic<Scheme>::template bind<public_secret_reconstructing_policy<Scheme>>::type
46  } // namespace pubkey
47 
65  template<typename Scheme, typename InputIterator, typename OutputIterator,
66  typename ProcessingMode = pubkey::public_secret_reconstructing_processing_mode<Scheme>>
67  typename std::enable_if<!boost::accumulators::detail::is_accumulator_set<OutputIterator>::value,
68  OutputIterator>::type
69  reconstruct_public_secret(InputIterator first, InputIterator last, OutputIterator out) {
70 
71  typedef typename pubkey::reconstructing_accumulator_set<ProcessingMode> ReconstructionAccumulator;
72 
75 
76  return SchemeImpl(first, last, std::move(out), ReconstructionAccumulator());
77  }
78 
95  template<typename Scheme, typename SinglePassRange, typename OutputIterator,
96  typename ProcessingMode = pubkey::public_secret_reconstructing_processing_mode<Scheme>>
97  typename std::enable_if<!boost::accumulators::detail::is_accumulator_set<OutputIterator>::value,
98  OutputIterator>::type
99  reconstruct_public_secret(const SinglePassRange &range, OutputIterator out) {
100 
101  typedef typename pubkey::reconstructing_accumulator_set<ProcessingMode> ReconstructionAccumulator;
102 
105 
106  return SchemeImpl(range, std::move(out), ReconstructionAccumulator());
107  }
108 
127  template<typename Scheme, typename InputIterator,
128  typename ProcessingMode = pubkey::public_secret_reconstructing_processing_mode<Scheme>,
129  typename OutputAccumulator = typename pubkey::reconstructing_accumulator_set<ProcessingMode>>
130  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
131  OutputAccumulator>::type &
132  reconstruct_public_secret(InputIterator first, InputIterator last, OutputAccumulator &acc) {
133 
136 
137  return SchemeImpl(first, last, std::forward<OutputAccumulator>(acc));
138  }
139 
157  template<typename Scheme, typename SinglePassRange,
158  typename ProcessingMode = pubkey::public_secret_reconstructing_processing_mode<Scheme>,
159  typename OutputAccumulator = typename pubkey::reconstructing_accumulator_set<ProcessingMode>>
160  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
161  OutputAccumulator>::type &
162  reconstruct_public_secret(const SinglePassRange &range, OutputAccumulator &acc) {
163 
166 
167  return SchemeImpl(range, std::forward<OutputAccumulator>(acc));
168  }
169 
190  template<typename Scheme, typename InputIterator,
191  typename ProcessingMode = pubkey::public_secret_reconstructing_processing_mode<Scheme>,
192  typename ReconstructionAccumulator = typename pubkey::reconstructing_accumulator_set<ProcessingMode>,
193  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<ReconstructionAccumulator>,
194  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
195  SchemeImpl reconstruct_public_secret(InputIterator first, InputIterator last) {
196 
197  return SchemeImpl(first, last, ReconstructionAccumulator());
198  }
199 
219  template<typename Scheme, typename SinglePassRange,
220  typename ProcessingMode = pubkey::public_secret_reconstructing_processing_mode<Scheme>,
221  typename ReconstructionAccumulator = typename pubkey::reconstructing_accumulator_set<ProcessingMode>,
222  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<ReconstructionAccumulator>,
223  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
224  SchemeImpl reconstruct_public_secret(const SinglePassRange &range) {
225 
226  return SchemeImpl(range, ReconstructionAccumulator());
227  }
228  } // namespace crypto3
229 } // namespace nil
230 
231 #endif // include guard
std::enable_if<!boost::accumulators::detail::is_accumulator_set< OutputIterator >::value, OutputIterator >::type reconstruct_public_secret(InputIterator first, InputIterator last, OutputIterator out)
Reconstruct public representative of secret using passed public representatives of shares.
Definition: reconstruct_public_secret.hpp:69
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 >::public_secret_reconstructing_policy public_secret_reconstructing_policy
Definition: reconstruct_public_secret.hpp:41
boost::accumulators::accumulator_set< typename ProcessingMode::result_type, boost::accumulators::features< accumulators::tag::reconstruct< ProcessingMode > >> reconstructing_accumulator_set
Definition: secret_sharing_state.hpp:56
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: isomorphic.hpp:219