pubkey/include/nil/crypto3/pubkey/algorithm/decrypt.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_DECRYPT_HPP
27 #define CRYPTO3_PUBKEY_DECRYPT_HPP
28 
30 
33 
35 
37 
38 namespace nil {
39  namespace crypto3 {
40  namespace pubkey {
41  template<typename Scheme>
43  }
44  template<typename Scheme, typename Mode = pubkey::modes::isomorphic<Scheme>,
45  typename ProcessingMode = typename Mode::decryption_policy, typename InputIterator,
46  typename PubkeyAccumulator = pubkey::pubkey_accumulator_set<ProcessingMode>,
47  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
48  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
49  SchemeImpl decrypt(InputIterator first, InputIterator last,
51  return SchemeImpl(first, last, PubkeyAccumulator(init_params));
52  }
53 
54  template<typename Scheme, typename Mode = pubkey::modes::isomorphic<Scheme>,
55  typename ProcessingMode = typename Mode::decryption_policy, typename SinglePassRange,
56  typename PubkeyAccumulator = pubkey::pubkey_accumulator_set<ProcessingMode>,
57  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
58  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
59  SchemeImpl decrypt(const SinglePassRange &range,
61  return SchemeImpl(range, PubkeyAccumulator(init_params));
62  }
63 
64  template<typename Scheme, typename Mode = pubkey::modes::isomorphic<Scheme>,
65  typename ProcessingMode = typename Mode::decryption_policy, typename InputIterator,
66  typename OutputAccumulator = pubkey::pubkey_accumulator_set<ProcessingMode>>
67  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
68  OutputAccumulator>::type &
69  decrypt(InputIterator first, InputIterator last, OutputAccumulator &acc) {
72 
73  return SchemeImpl(first, last, std::forward<OutputAccumulator>(acc));
74  }
75 
76  template<typename Scheme, typename Mode = pubkey::modes::isomorphic<Scheme>,
77  typename ProcessingMode = typename Mode::decryption_policy, typename SinglePassRange,
78  typename OutputAccumulator = pubkey::pubkey_accumulator_set<ProcessingMode>>
79  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
80  OutputAccumulator>::type &
81  decrypt(const SinglePassRange &range, OutputAccumulator &acc) {
84 
85  return SchemeImpl(range, std::forward<OutputAccumulator>(acc));
86  }
87 
88  template<typename Scheme, typename Mode = pubkey::modes::isomorphic<Scheme>,
89  typename ProcessingMode = typename Mode::decryption_policy, typename InputIterator,
90  typename OutputIterator>
91  OutputIterator decrypt(InputIterator first, InputIterator last,
92  const pubkey::decryption_init_params_type<Scheme> &init_params, OutputIterator out) {
93  typedef pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
94 
97 
98  return SchemeImpl(first, last, std::move(out), PubkeyAccumulator(init_params));
99  }
100 
101  template<typename Scheme, typename Mode = pubkey::modes::isomorphic<Scheme>,
102  typename ProcessingMode = typename Mode::decryption_policy, typename SinglePassRange,
103  typename OutputIterator>
104  OutputIterator decrypt(const SinglePassRange &range,
105  const pubkey::decryption_init_params_type<Scheme> &init_params, OutputIterator out) {
106  typedef pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
107 
110 
111  return SchemeImpl(range, std::move(out), PubkeyAccumulator(init_params));
112  }
113  } // namespace crypto3
114 } // namespace nil
115 
116 #endif // CRYPTO3_PUBKEY_DECRYPT_HPP
OutputIterator decrypt(InputIterator first, InputIterator last, KeyInputIterator key_first, KeyInputIterator key_last, OutputIterator out)
Definition: block/include/nil/crypto3/block/algorithm/decrypt.hpp:66
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 decrypt_op< Scheme >::init_params_type decryption_init_params_type
Definition: pubkey/include/nil/crypto3/pubkey/algorithm/decrypt.hpp:42
Definition: pair.hpp:31
Definition: decrypt_op.hpp:33
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49