algorithm/verify_share.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2020-2021 Mikhail Komarov <nemo@nil.foundation>
3 // Copyright (c) 2020-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_VERIFY_SHARE_HPP
27 #define CRYPTO3_PUBKEY_VERIFY_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_verification_policy<Scheme>>::type;
45  } // namespace pubkey
46 
65  template<typename Scheme, typename InputIterator, typename OutputIterator,
67  OutputIterator verify_share(InputIterator first, InputIterator last, const pubkey::public_share_sss<Scheme> &s,
68  OutputIterator out) {
69 
70  typedef typename pubkey::share_verification_accumulator_set<ProcessingMode> VerificationAccumulator;
71 
74 
75  return SchemeImpl(first, last, std::move(out), VerificationAccumulator(s));
76  }
77 
95  template<typename Scheme, typename SinglePassRange, typename OutputIterator,
96  typename ProcessingMode = pubkey::share_verification_processing_mode_default<Scheme>>
97  OutputIterator verify_share(const SinglePassRange &range, const pubkey::public_share_sss<Scheme> &s,
98  OutputIterator out) {
99 
100  typedef typename pubkey::share_verification_accumulator_set<ProcessingMode> VerificationAccumulator;
101 
104 
105  return SchemeImpl(range, std::move(out), VerificationAccumulator(s));
106  }
107 
127  template<typename Scheme, typename InputIterator,
128  typename ProcessingMode = pubkey::share_verification_processing_mode_default<Scheme>,
129  typename OutputAccumulator = typename pubkey::share_verification_accumulator_set<ProcessingMode>>
130  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
131  OutputAccumulator>::type &
132  verify_share(InputIterator first, InputIterator last, OutputAccumulator &acc) {
133 
136 
137  return SchemeImpl(first, last, std::forward<OutputAccumulator>(acc));
138  }
139 
158  template<typename Scheme, typename SinglePassRange,
159  typename ProcessingMode = pubkey::share_verification_processing_mode_default<Scheme>,
160  typename OutputAccumulator = typename pubkey::share_verification_accumulator_set<ProcessingMode>>
161  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
162  OutputAccumulator>::type &
163  verify_share(const SinglePassRange &range, OutputAccumulator &acc) {
164 
167 
168  return SchemeImpl(range, std::forward<OutputAccumulator>(acc));
169  }
170 
192  template<typename Scheme, typename InputIterator,
193  typename ProcessingMode = pubkey::share_verification_processing_mode_default<Scheme>,
194  typename VerificationAccumulator = typename pubkey::share_verification_accumulator_set<ProcessingMode>,
195  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<VerificationAccumulator>,
196  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
197  SchemeImpl verify_share(InputIterator first, InputIterator last, const pubkey::public_share_sss<Scheme> &s) {
198 
199  return SchemeImpl(first, last, VerificationAccumulator(s));
200  }
201 
222  template<typename Scheme, typename SinglePassRange,
223  typename ProcessingMode = pubkey::share_verification_processing_mode_default<Scheme>,
224  typename VerificationAccumulator = typename pubkey::share_verification_accumulator_set<ProcessingMode>,
225  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<VerificationAccumulator>,
226  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
227  SchemeImpl verify_share(const SinglePassRange &range, const pubkey::public_share_sss<Scheme> &s) {
228 
229  return SchemeImpl(range, VerificationAccumulator(s));
230  }
231  } // namespace crypto3
232 } // namespace nil
233 
234 #endif // include guard
OutputIterator verify_share(InputIterator first, InputIterator last, const pubkey::public_share_sss< Scheme > &s, OutputIterator out)
Verification of the share on the input public representatives of polynomial coefficients.
Definition: algorithm/verify_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
boost::accumulators::accumulator_set< typename ProcessingMode::result_type, boost::accumulators::features< accumulators::tag::verify_share< ProcessingMode > >> share_verification_accumulator_set
Definition: secret_sharing_state.hpp:51
typename modes::isomorphic< Scheme >::template bind< share_verification_policy< Scheme > >::type share_verification_processing_mode_default
Definition: algorithm/verify_share.hpp:44
typename pubkey::modes::isomorphic< Scheme >::share_verification_policy share_verification_policy
Definition: algorithm/verify_share.hpp:40
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: isomorphic.hpp:219
Definition: public_share_sss.hpp:33