rerandomize.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_RERANDOMIZE_HPP
27 #define CRYPTO3_PUBKEY_RERANDOMIZE_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::rerandomization_policy, typename InputIterator,
47  typename OutputIterator>
48  OutputIterator rerandomize(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::rerandomization_policy, typename SinglePassRange,
62  typename OutputIterator>
63  OutputIterator rerandomize(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::rerandomization_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  rerandomize(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::rerandomization_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  rerandomize(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::rerandomization_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 rerandomize(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::rerandomization_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 rerandomize(const SinglePassRange &range,
119 
120  return SchemeImpl(range, PubkeyAccumulator(init_params));
121  }
122 
123  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
124  typename ProcessingMode = typename Mode::rerandomization_policy, typename InputIterator1,
125  typename InputIterator2, typename OutputIterator>
126  OutputIterator
127  rerandomize(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
128  const pubkey::rerandomization_init_params_type<Scheme> &init_params, OutputIterator out) {
129 
130  typedef typename pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
131 
134 
135  return SchemeImpl(first1, last1, first2, last2, std::move(out), PubkeyAccumulator(init_params));
136  }
137 
138  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
139  typename ProcessingMode = typename Mode::rerandomization_policy, typename SinglePassRange1,
140  typename SinglePassRange2, typename OutputIterator>
141  OutputIterator rerandomize(const SinglePassRange1 &range1, const SinglePassRange2 &range2,
143  OutputIterator out) {
144 
145  typedef typename pubkey::pubkey_accumulator_set<ProcessingMode> PubkeyAccumulator;
146 
149 
150  return SchemeImpl(std::cbegin(range1), std::cend(range1), std::cbegin(range2), std::cend(range2),
151  std::move(out), PubkeyAccumulator(init_params));
152  }
153 
154  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
155  typename ProcessingMode = typename Mode::rerandomization_policy, typename InputIterator1,
156  typename InputIterator2,
157  typename OutputAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>>
158  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
159  OutputAccumulator>::type &
160  rerandomize(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
161  OutputAccumulator &acc) {
162 
165 
166  return SchemeImpl(first1, last1, first2, last2, std::forward<OutputAccumulator>(acc));
167  }
168 
169  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
170  typename ProcessingMode = typename Mode::rerandomization_policy, typename SinglePassRange1,
171  typename SinglePassRange2,
172  typename OutputAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>>
173  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
174  OutputAccumulator>::type &
175  rerandomize(const SinglePassRange1 &range1, const SinglePassRange2 &range2, OutputAccumulator &acc) {
176 
179 
180  return SchemeImpl(std::cbegin(range1), std::cend(range1), std::cbegin(range2), std::cend(range2),
181  std::forward<OutputAccumulator>(acc));
182  }
183 
184  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
185  typename ProcessingMode = typename Mode::rerandomization_policy, typename InputIterator1,
186  typename InputIterator2,
187  typename PubkeyAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>,
188  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
189  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
190  SchemeImpl rerandomize(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
192 
193  return SchemeImpl(first1, last1, first2, last2, PubkeyAccumulator(init_params));
194  }
195 
196  template<typename Scheme, typename Mode = pubkey::modes::verifiable_encryption<Scheme>,
197  typename ProcessingMode = typename Mode::rerandomization_policy, typename SinglePassRange1,
198  typename SinglePassRange2,
199  typename PubkeyAccumulator = typename pubkey::pubkey_accumulator_set<ProcessingMode>,
200  typename StreamSchemeImpl = pubkey::detail::value_pubkey_impl<PubkeyAccumulator>,
201  typename SchemeImpl = pubkey::detail::range_pubkey_impl<StreamSchemeImpl>>
202  SchemeImpl rerandomize(const SinglePassRange1 &range1, const SinglePassRange2 &range2,
204 
205  return SchemeImpl(std::cbegin(range1), std::cend(range1), std::cbegin(range2), std::cend(range2),
206  PubkeyAccumulator(init_params));
207  }
208  } // namespace crypto3
209 } // namespace nil
210 
211 #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 rerandomize_op< Scheme >::init_params_type rerandomization_init_params_type
Definition: rerandomize.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 rerandomize(InputIterator first, InputIterator last, const pubkey::rerandomization_init_params_type< Scheme > &init_params, OutputIterator out)
Definition: rerandomize.hpp:48
Definition: pair.hpp:31
Definition: pubkey_value.hpp:167
Definition: pubkey_value.hpp:49
Definition: rerandomize_op.hpp:33