verify_decryption.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_DECRYPTION_HPP
27 #define CRYPTO3_PUBKEY_VERIFY_DECRYPTION_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::decryption_verification_policy, typename InputIterator1,
47  typename InputIterator2, typename OutputIterator>
48  OutputIterator verify_decryption(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
49  InputIterator2 last2,
51  OutputIterator out) {
52 
53  typedef typename pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
54 
57 
58  return SchemeImpl(first1, last1, first2, last2, std::move(out), PubkeyAccumulator(init_params));
59  }
60 
61  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
62  typename ProcessingMode = typename Mode::decryption_verification_policy, typename SinglePassRange1,
63  typename SinglePassRange2, typename OutputIterator>
64  OutputIterator verify_decryption(const SinglePassRange1 &range1, const SinglePassRange2 &range2,
66  OutputIterator out) {
67 
68  typedef typename pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
69 
72 
73  return SchemeImpl(std::cbegin(range1), std::cend(range1), std::cbegin(range2), std::cend(range2),
74  std::move(out), PubkeyAccumulator(init_params));
75  }
76 
77  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
78  typename ProcessingMode = typename Mode::decryption_verification_policy, typename InputIterator1,
79  typename InputIterator2,
80  typename OutputAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>>
81  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
82  OutputAccumulator>::type &
83  verify_decryption(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
84  OutputAccumulator &acc) {
85 
88 
89  return SchemeImpl(first1, last1, first2, last2, std::forward<OutputAccumulator>(acc));
90  }
91 
92  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
93  typename ProcessingMode = typename Mode::decryption_verification_policy, typename SinglePassRange1,
94  typename SinglePassRange2,
95  typename OutputAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>>
96  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
97  OutputAccumulator>::type &
98  verify_decryption(const SinglePassRange1 &range1, const SinglePassRange2 &range2, OutputAccumulator &acc) {
99 
102 
103  return SchemeImpl(std::cbegin(range1), std::cend(range1), std::cbegin(range2), std::cend(range2),
104  std::forward<OutputAccumulator>(acc));
105  }
106 
107  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
108  typename ProcessingMode = typename Mode::decryption_verification_policy, typename InputIterator1,
109  typename InputIterator2,
110  typename PubkeyAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>,
111  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
112  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
113  SchemeImpl verify_decryption(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2,
114  InputIterator2 last2,
116 
117  return SchemeImpl(first1, last1, first2, last2, PubkeyAccumulator(init_params));
118  }
119 
120  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
121  typename ProcessingMode = typename Mode::decryption_verification_policy, typename SinglePassRange1,
122  typename SinglePassRange2,
123  typename PubkeyAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>,
124  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
125  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
126  SchemeImpl verify_decryption(const SinglePassRange1 &range1, const SinglePassRange2 &range2,
128 
129  return SchemeImpl(std::cbegin(range1), std::cend(range1), std::cbegin(range2), std::cend(range2),
130  PubkeyAccumulator(init_params));
131  }
132  } // namespace crypto3
133 } // namespace nil
134 
135 #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
typename verify_decryption_op< Scheme >::init_params_type decryption_verification_init_params_type
Definition: verify_decryption.hpp:42
boost::accumulators::accumulator_set< typename ProcessingMode::result_type, boost::accumulators::features< accumulators::tag::pubkey< ProcessingMode > >> pubkey_accumulator_set
Definition: pubkey_state.hpp:45
OutputIterator verify_decryption(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, const pubkey::decryption_verification_init_params_type< Scheme > &init_params, OutputIterator out)
Definition: verify_decryption.hpp:48
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: verify_decryption_op.hpp:33