algorithm/aggregate.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_AGGREGATE_HPP
27 #define CRYPTO3_PUBKEY_AGGREGATE_HPP
28 
30 
33 
35 
37 
38 namespace nil {
39  namespace crypto3 {
40  namespace pubkey {
41  template<typename Scheme>
43 
44  template<typename Scheme>
46  typename modes::isomorphic<Scheme>::template bind<aggregation_policy<Scheme>>::type;
47  } // namespace pubkey
48 
66  template<typename Scheme, typename InputIterator, typename OutputIterator,
68  typename std::enable_if<!boost::accumulators::detail::is_accumulator_set<OutputIterator>::value,
69  OutputIterator>::type
70  aggregate(InputIterator first, InputIterator last, OutputIterator out) {
71 
72  typedef typename pubkey::aggregation_accumulator_set<ProcessingMode> AggregationAccumulator;
73 
76 
77  return SchemeImpl(first, last, std::move(out), AggregationAccumulator());
78  }
79 
96  template<typename Scheme, typename SinglePassRange, typename OutputIterator,
97  typename ProcessingMode = pubkey::aggregation_processing_mode_default<Scheme>>
98  typename std::enable_if<!boost::accumulators::detail::is_accumulator_set<OutputIterator>::value,
99  OutputIterator>::type
100  aggregate(const SinglePassRange &range, OutputIterator out) {
101 
102  typedef typename pubkey::aggregation_accumulator_set<ProcessingMode> AggregationAccumulator;
103 
106 
107  return SchemeImpl(range, std::move(out), AggregationAccumulator());
108  }
109 
128  template<typename Scheme, typename InputIterator,
129  typename ProcessingMode = pubkey::aggregation_processing_mode_default<Scheme>,
130  typename OutputAccumulator = typename pubkey::aggregation_accumulator_set<ProcessingMode>>
131  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
132  OutputAccumulator>::type &
133  aggregate(InputIterator first, InputIterator last, OutputAccumulator &acc) {
134 
137 
138  return SchemeImpl(first, last, std::forward<OutputAccumulator>(acc));
139  }
140 
158  template<typename Scheme, typename SinglePassRange,
159  typename ProcessingMode = pubkey::aggregation_processing_mode_default<Scheme>,
160  typename OutputAccumulator = typename pubkey::aggregation_accumulator_set<ProcessingMode>>
161  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
162  OutputAccumulator>::type &
163  aggregate(const SinglePassRange &range, OutputAccumulator &acc) {
164 
167 
168  return SchemeImpl(range, std::forward<OutputAccumulator>(acc));
169  }
170 
190  template<typename Scheme, typename InputIterator,
191  typename ProcessingMode = pubkey::aggregation_processing_mode_default<Scheme>,
192  typename AggregationAccumulator = typename pubkey::aggregation_accumulator_set<ProcessingMode>,
193  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<AggregationAccumulator>,
194  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
195  SchemeImpl aggregate(InputIterator first, InputIterator last) {
196  return SchemeImpl(first, last, AggregationAccumulator());
197  }
198 
217  template<typename Scheme, typename SinglePassRange,
218  typename ProcessingMode = pubkey::aggregation_processing_mode_default<Scheme>,
219  typename AggregationAccumulator = typename pubkey::aggregation_accumulator_set<ProcessingMode>,
220  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<AggregationAccumulator>,
221  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
222  SchemeImpl aggregate(const SinglePassRange &range) {
223  return SchemeImpl(range, AggregationAccumulator());
224  }
225  } // namespace crypto3
226 } // namespace nil
227 
228 #endif // CRYPTO3_PUBKEY_AGGREGATE_HPP
std::enable_if<!boost::accumulators::detail::is_accumulator_set< OutputIterator >::value, OutputIterator >::type aggregate(InputIterator first, InputIterator last, OutputIterator out)
Aggregation of the input signatures into one resulted signature and writing it in out.
Definition: algorithm/aggregate.hpp:70
boost::accumulators::accumulator_set< typename ProcessingMode::result_type, boost::accumulators::features< accumulators::tag::aggregate< ProcessingMode > >> aggregation_accumulator_set
Accumulator set with pre-defined aggregation accumulator params.
Definition: pubkey_state.hpp:87
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 >::aggregation_policy aggregation_policy
Definition: algorithm/aggregate.hpp:42
typename modes::isomorphic< Scheme >::template bind< aggregation_policy< Scheme > >::type aggregation_processing_mode_default
Definition: algorithm/aggregate.hpp:46
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: isomorphic.hpp:219