algorithm/aggregate_verify.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_VERIFY_HPP
27 #define CRYPTO3_PUBKEY_AGGREGATE_VERIFY_HPP
28 
30 
33 
35 
36 namespace nil {
37  namespace crypto3 {
38  namespace pubkey {
39  template<typename Scheme>
42 
43  template<typename Scheme>
45  typename modes::isomorphic<Scheme>::template bind<aggregate_verification_policy<Scheme>>::type;
46  } // namespace pubkey
47 
71  template<
72  typename Scheme, typename InputIterator,
74  typename AggregateVerificationAccumulator = pubkey::aggregate_verification_accumulator_set<ProcessingMode>,
77  SchemeImpl aggregate_verify(InputIterator first, InputIterator last,
78  const typename pubkey::public_key<Scheme>::signature_type &signature,
79  const pubkey::public_key<Scheme> &key) {
80  return SchemeImpl(first, last, AggregateVerificationAccumulator(signature), key);
81  }
82 
105  template<
106  typename Scheme, typename SinglePassRange,
107  typename ProcessingMode = pubkey::aggregate_verification_processing_mode_default<Scheme>,
108  typename AggregateVerificationAccumulator = pubkey::aggregate_verification_accumulator_set<ProcessingMode>,
109  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<AggregateVerificationAccumulator>,
110  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
111  SchemeImpl aggregate_verify(const SinglePassRange &range,
112  const typename pubkey::public_key<Scheme>::signature_type &signature,
113  const pubkey::public_key<Scheme> &key) {
114  return SchemeImpl(range, AggregateVerificationAccumulator(signature), key);
115  }
116 
138  template<typename Scheme, typename InputIterator,
139  typename ProcessingMode = pubkey::aggregate_verification_processing_mode_default<Scheme>,
140  typename OutputAccumulator = pubkey::aggregate_verification_accumulator_set<ProcessingMode>>
141  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
142  OutputAccumulator>::type &
143  aggregate_verify(InputIterator first, InputIterator last, const pubkey::public_key<Scheme> &key,
144  OutputAccumulator &acc) {
147 
148  return SchemeImpl(first, last, std::forward<OutputAccumulator>(acc), key);
149  }
150 
171  template<typename Scheme, typename SinglePassRange,
172  typename ProcessingMode = pubkey::aggregate_verification_processing_mode_default<Scheme>,
173  typename OutputAccumulator = pubkey::aggregate_verification_accumulator_set<ProcessingMode>>
174  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
175  OutputAccumulator>::type &
176  aggregate_verify(const SinglePassRange &range, const pubkey::public_key<Scheme> &key,
177  OutputAccumulator &acc) {
180 
181  return SchemeImpl(range, std::forward<OutputAccumulator>(acc), key);
182  }
183 
202  // TODO: fix
203  template<typename Scheme,
204  typename ProcessingMode = pubkey::aggregate_verification_processing_mode_default<Scheme>,
205  typename OutputAccumulator = pubkey::aggregate_verification_accumulator_set<ProcessingMode>>
206  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
207  OutputAccumulator>::type &
208  aggregate_verify(const typename pubkey::public_key<Scheme>::signature_type &aggregated_signature,
209  OutputAccumulator &acc) {
212 
213  return SchemeImpl(std::forward<OutputAccumulator>(acc), aggregated_signature);
214  }
215 
235  // TODO: check
236  template<typename Scheme, typename OutputIterator,
237  typename ProcessingMode = pubkey::aggregate_verification_processing_mode_default<Scheme>,
238  typename OutputAccumulator = pubkey::aggregate_verification_accumulator_set<ProcessingMode>>
239  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
240  OutputIterator>::type
241  aggregate_verify(OutputAccumulator &acc, OutputIterator out) {
244 
245  return SchemeImpl(std::move(out), std::forward<OutputAccumulator>(acc));
246  }
247  } // namespace crypto3
248 } // namespace nil
249 
250 #endif // include guard
SchemeImpl aggregate_verify(InputIterator first, InputIterator last, const typename pubkey::public_key< Scheme >::signature_type &signature, const pubkey::public_key< Scheme > &key)
Aggregate verification of the input aggregated signature that aggregates signature created for the in...
Definition: algorithm/aggregate_verify.hpp:77
boost::accumulators::accumulator_set< typename ProcessingMode::result_type, boost::accumulators::features< accumulators::tag::aggregate_verify< ProcessingMode > >> aggregate_verification_accumulator_set
Accumulator set with pre-defined aggregate verification accumulator params.
Definition: pubkey_state.hpp:101
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 >::aggregate_verification_policy aggregate_verification_policy
Definition: algorithm/aggregate_verify.hpp:41
typename modes::isomorphic< Scheme >::template bind< aggregate_verification_policy< Scheme > >::type aggregate_verification_processing_mode_default
Definition: algorithm/aggregate_verify.hpp:45
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: isomorphic.hpp:219
Public key - a key that can be published and used to verify the authenticity of the signed document,...
Definition: public_key.hpp:43