verify_encryption.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_VERIFY_ENCRYPTION_HPP
27 #define CRYPTO3_PUBKEY_VERIFY_ENCRYPTION_HPP
28 
30 
33 
35 
37 
38 namespace nil {
39  namespace crypto3 {
40  namespace pubkey {
41  template<typename Scheme>
43  }
44 
45  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
46  typename ProcessingMode = typename Mode::encryption_verification_policy, typename InputIterator,
47  typename OutputIterator>
48  OutputIterator verify_encryption(InputIterator first, InputIterator last,
50  OutputIterator out) {
51 
52  typedef typename pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
53 
56 
57  return SchemeImpl(first, last, std::move(out), PubkeyAccumulator(init_params));
58  }
59 
60  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
61  typename ProcessingMode = typename Mode::encryption_verification_policy, typename SinglePassRange,
62  typename OutputIterator>
63  OutputIterator verify_encryption(const SinglePassRange &range,
65  OutputIterator out) {
66 
67  typedef typename pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
68 
71 
72  return SchemeImpl(range, std::move(out), PubkeyAccumulator(init_params));
73  }
74 
75  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
76  typename ProcessingMode = typename Mode::encryption_verification_policy, typename InputIterator,
77  typename OutputAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>>
78  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
79  OutputAccumulator>::type &
80  verify_encryption(InputIterator first, InputIterator last, OutputAccumulator &acc) {
81 
84 
85  return SchemeImpl(first, last, std::forward<OutputAccumulator>(acc));
86  }
87 
88  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
89  typename ProcessingMode = typename Mode::encryption_verification_policy, typename SinglePassRange,
90  typename OutputAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>>
91  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
92  OutputAccumulator>::type &
93  verify_encryption(const SinglePassRange &range, OutputAccumulator &acc) {
94 
97 
98  return SchemeImpl(range, std::forward<OutputAccumulator>(acc));
99  }
100 
101  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
102  typename ProcessingMode = typename Mode::encryption_verification_policy, typename InputIterator,
103  typename PubkeyAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>,
104  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
105  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
106  SchemeImpl verify_encryption(InputIterator first, InputIterator last,
108 
109  return SchemeImpl(first, last, PubkeyAccumulator(init_params));
110  }
111 
112  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
113  typename ProcessingMode = typename Mode::encryption_verification_policy, typename SinglePassRange,
114  typename PubkeyAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>,
115  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
116  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
117  SchemeImpl verify_encryption(const SinglePassRange &range,
119 
120  return SchemeImpl(range, PubkeyAccumulator(init_params));
121  }
122  } // namespace crypto3
123 } // namespace nil
124 
125 #endif // include guard
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::pubkey< ProcessingMode > >> pubkey_accumulator_set
Definition: pubkey_state.hpp:45
typename verify_encryption_op< Scheme >::init_params_type encryption_verification_init_params_type
Definition: verify_encryption.hpp:42
OutputIterator verify_encryption(InputIterator first, InputIterator last, const pubkey::encryption_verification_init_params_type< Scheme > &init_params, OutputIterator out)
Definition: verify_encryption.hpp:48
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: verify_encryption_op.hpp:33