Zeth - Zerocash on Ethereum  0.8
Reference implementation of the Zeth protocol by Clearmatics
multi_exp.tcc
Go to the documentation of this file.
1 // Copyright (c) 2015-2022 Clearmatics Technologies Ltd
2 //
3 // SPDX-License-Identifier: LGPL-3.0+
4 
5 #ifndef __ZETH_CORE_MULTI_EXP_TCC__
6 #define __ZETH_CORE_MULTI_EXP_TCC__
7 
8 #include "libzeth/core/multi_exp.hpp"
9 
10 namespace libzeth
11 {
12 
13 template<typename FieldT, typename GroupT>
14 GroupT multi_exp(
15  typename std::vector<GroupT>::const_iterator gs_start,
16  typename std::vector<GroupT>::const_iterator gs_end,
17  typename std::vector<FieldT>::const_iterator fs_start,
18  typename std::vector<FieldT>::const_iterator fs_end)
19 {
20  const libff::multi_exp_method Method = libff::multi_exp_method_BDLO12;
21  return libff::multi_exp_filter_one_zero<GroupT, FieldT, Method>(
22  gs_start, gs_end, fs_start, fs_end, 1);
23 }
24 
25 template<typename ppT, typename GroupT>
26 GroupT multi_exp(const std::vector<GroupT> &gs, const libff::Fr_vector<ppT> &fs)
27 {
28  assert(gs.size() >= fs.size());
29  assert(gs.size() > 0);
30 
31  using Fr = libff::Fr<ppT>;
32  const libff::multi_exp_method Method = libff::multi_exp_method_BDLO12;
33  return libff::multi_exp_filter_one_zero<GroupT, Fr, Method>(
34  gs.begin(), gs.begin() + fs.size(), fs.begin(), fs.end(), 1);
35 }
36 
37 } // namespace libzeth
38 
39 #endif // __ZETH_CORE_MULTI_EXP_TCC__