pkpad/include/nil/crypto3/pkpad/algorithms/encode.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_PK_PAD_ENCODE_HPP
27 #define CRYPTO3_PK_PAD_ENCODE_HPP
28 
31 
32 namespace nil {
33  namespace crypto3 {
34  namespace pubkey {
35  namespace padding {
36  template<typename Padding>
38  }
39 
53  template<typename Padding, typename InputIterator,
54  typename PaddingAccumulator = padding::encoding_accumulator_set<Padding>,
57  PaddingImpl encode(InputIterator first, InputIterator last) {
58  return PaddingImpl(first, last, PaddingAccumulator());
59  }
60 
73  template<typename Padding, typename SinglePassRange,
74  typename PaddingAccumulator = padding::encoding_accumulator_set<Padding>,
75  typename StreamPaddingImpl = padding::detail::value_padding_impl<PaddingAccumulator>,
76  typename PaddingImpl = padding::detail::range_padding_impl<StreamPaddingImpl>>
77  PaddingImpl encode(const SinglePassRange &rng) {
78  return PaddingImpl(rng, PaddingAccumulator());
79  }
80 
97  template<typename Padding, typename InputIterator,
98  typename OutputAccumulator = padding::encoding_accumulator_set<Padding>>
99  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
100  OutputAccumulator>::type &
101  encode(InputIterator first, InputIterator last, OutputAccumulator &acc) {
104 
105  return PaddingImpl(first, last, std::forward<OutputAccumulator>(acc));
106  }
107 
123  template<typename Padding, typename SinglePassRange,
124  typename OutputAccumulator = padding::encoding_accumulator_set<Padding>>
125  typename std::enable_if<boost::accumulators::detail::is_accumulator_set<OutputAccumulator>::value,
126  OutputAccumulator>::type &
127  encode(const SinglePassRange &r, OutputAccumulator &acc) {
130 
131  return PaddingImpl(r, std::forward<OutputAccumulator>(acc));
132  }
133 
149  template<typename Padding, typename InputIterator, typename OutputIterator>
150  typename std::enable_if<!boost::accumulators::detail::is_accumulator_set<OutputIterator>::value,
151  OutputIterator>::type
152  encode(InputIterator first, InputIterator last, OutputIterator out) {
153  typedef padding::encoding_accumulator_set<Padding> PaddingAccumulator;
154 
157 
158  return PaddingImpl(first, last, std::move(out), PaddingAccumulator());
159  }
160 
175  template<typename Padding, typename SinglePassRange, typename OutputIterator>
176  typename std::enable_if<!boost::accumulators::detail::is_accumulator_set<OutputIterator>::value,
177  OutputIterator>::type
178  encode(const SinglePassRange &rng, OutputIterator out) {
179  typedef padding::encoding_accumulator_set<Padding> PaddingAccumulator;
180 
183 
184  return PaddingImpl(rng, std::move(out), PaddingAccumulator());
185  }
186  } // namespace pubkey
187  } // namespace crypto3
188 } // namespace nil
189 
190 #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 Padding::encoding_policy encoding_policy
Definition: pkpad/include/nil/crypto3/pkpad/algorithms/encode.hpp:37
boost::accumulators::accumulator_set< typename Padding::encoding_policy::result_type, boost::accumulators::features< accumulators::tag::encode< typename Padding::encoding_policy > >> encoding_accumulator_set
Accumulator set with pre-defined signing accumulator params.
Definition: padding_state.hpp:51
PaddingImpl encode(InputIterator first, InputIterator last)
Definition: pkpad/include/nil/crypto3/pkpad/algorithms/encode.hpp:57
Definition: pair.hpp:31