Skip to content

Multiexponentiation improvements #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ install(
TARGETS ff DESTINATION lib
)

add_executable(
multiexp_profile
EXCLUDE_FROM_ALL

algebra/scalar_multiplication/multiexp_profile.cpp
)
target_link_libraries(
multiexp_profile

ff
)

# Tests
add_executable(
algebra_bilinearity_test
Expand Down
3 changes: 1 addition & 2 deletions libff/algebra/curves/alt_bn128/alt_bn128_g1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,7 @@ std::istream& operator>>(std::istream& in, std::vector<alt_bn128_G1> &v)
return in;
}

template<>
void batch_to_special_all_non_zeros<alt_bn128_G1>(std::vector<alt_bn128_G1> &vec)
void alt_bn128_G1::batch_to_special_all_non_zeros(std::vector<alt_bn128_G1> &vec)
{
std::vector<alt_bn128_Fq> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/alt_bn128/alt_bn128_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class alt_bn128_G1 {

friend std::ostream& operator<<(std::ostream &out, const alt_bn128_G1 &g);
friend std::istream& operator>>(std::istream &in, alt_bn128_G1 &g);

static void batch_to_special_all_non_zeros(std::vector<alt_bn128_G1> &vec);
};

template<mp_size_t m>
Expand All @@ -87,10 +89,5 @@ alt_bn128_G1 operator*(const Fp_model<m,modulus_p> &lhs, const alt_bn128_G1 &rhs
std::ostream& operator<<(std::ostream& out, const std::vector<alt_bn128_G1> &v);
std::istream& operator>>(std::istream& in, std::vector<alt_bn128_G1> &v);

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<alt_bn128_G1>(std::vector<alt_bn128_G1> &vec);

} // libff
#endif // ALT_BN128_G1_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/alt_bn128/alt_bn128_g2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,7 @@ std::istream& operator>>(std::istream &in, alt_bn128_G2 &g)
return in;
}

template<>
void batch_to_special_all_non_zeros<alt_bn128_G2>(std::vector<alt_bn128_G2> &vec)
void alt_bn128_G2::batch_to_special_all_non_zeros(std::vector<alt_bn128_G2> &vec)
{
std::vector<alt_bn128_Fq2> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
6 changes: 2 additions & 4 deletions libff/algebra/curves/alt_bn128/alt_bn128_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class alt_bn128_G2 {

friend std::ostream& operator<<(std::ostream &out, const alt_bn128_G2 &g);
friend std::istream& operator>>(std::istream &in, alt_bn128_G2 &g);

static void batch_to_special_all_non_zeros(std::vector<alt_bn128_G2> &vec);
};

template<mp_size_t m>
Expand All @@ -88,10 +90,6 @@ alt_bn128_G2 operator*(const Fp_model<m,modulus_p> &lhs, const alt_bn128_G2 &rhs
return scalar_mul<alt_bn128_G2, m>(rhs, lhs.as_bigint());
}

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<alt_bn128_G2>(std::vector<alt_bn128_G2> &vec);

} // libff
#endif // ALT_BN128_G2_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/bn128/bn128_g1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ std::istream& operator>>(std::istream& in, std::vector<bn128_G1> &v)
return in;
}

template<>
void batch_to_special_all_non_zeros<bn128_G1>(std::vector<bn128_G1> &vec)
void bn128_G1::batch_to_special_all_non_zeros(std::vector<bn128_G1> &vec)
{
std::vector<bn::Fp> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
6 changes: 2 additions & 4 deletions libff/algebra/curves/bn128/bn128_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class bn128_G1 {

friend std::ostream& operator<<(std::ostream &out, const bn128_G1 &g);
friend std::istream& operator>>(std::istream &in, bn128_G1 &g);

static void batch_to_special_all_non_zeros(std::vector<bn128_G1> &vec);
};

template<mp_size_t m>
Expand All @@ -87,10 +89,6 @@ bn128_G1 operator*(const Fp_model<m,modulus_p> &lhs, const bn128_G1 &rhs)
std::ostream& operator<<(std::ostream& out, const std::vector<bn128_G1> &v);
std::istream& operator>>(std::istream& in, std::vector<bn128_G1> &v);

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<bn128_G1>(std::vector<bn128_G1> &vec);

} // libff
#endif // BN128_G1_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/bn128/bn128_g2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,7 @@ std::istream& operator>>(std::istream &in, bn128_G2 &g)
return in;
}

template<>
void batch_to_special_all_non_zeros<bn128_G2>(std::vector<bn128_G2> &vec)
void bn128_G2::batch_to_special_all_non_zeros(std::vector<bn128_G2> &vec)
{
std::vector<bn::Fp2> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/bn128/bn128_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class bn128_G2 {

friend std::ostream& operator<<(std::ostream &out, const bn128_G2 &g);
friend std::istream& operator>>(std::istream &in, bn128_G2 &g);

static void batch_to_special_all_non_zeros(std::vector<bn128_G2> &vec);
};

template<mp_size_t m>
Expand All @@ -85,10 +87,5 @@ bn128_G2 operator*(const Fp_model<m, modulus_p> &lhs, const bn128_G2 &rhs)
return scalar_mul<bn128_G2, m>(rhs, lhs.as_bigint());
}

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<bn128_G2>(std::vector<bn128_G2> &vec);

} // libff
#endif // BN128_G2_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/edwards/edwards_g1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,7 @@ std::istream& operator>>(std::istream& in, std::vector<edwards_G1> &v)
return in;
}

template<>
void batch_to_special_all_non_zeros<edwards_G1>(std::vector<edwards_G1> &vec)
void edwards_G1::batch_to_special_all_non_zeros(std::vector<edwards_G1> &vec)
{
std::vector<edwards_Fq> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/edwards/edwards_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ class edwards_G1 {

friend std::ostream& operator<<(std::ostream &out, const edwards_G1 &g);
friend std::istream& operator>>(std::istream &in, edwards_G1 &g);

static void batch_to_special_all_non_zeros(std::vector<edwards_G1> &vec);
};

template<mp_size_t m>
Expand All @@ -89,10 +91,5 @@ edwards_G1 operator*(const Fp_model<m,modulus_p> &lhs, const edwards_G1 &rhs)
std::ostream& operator<<(std::ostream& out, const std::vector<edwards_G1> &v);
std::istream& operator>>(std::istream& in, std::vector<edwards_G1> &v);

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<edwards_G1>(std::vector<edwards_G1> &vec);

} // libff
#endif // EDWARDS_G1_HPP_
5 changes: 1 addition & 4 deletions libff/algebra/curves/edwards/edwards_g2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,7 @@ std::istream& operator>>(std::istream &in, edwards_G2 &g)
return in;
}

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<edwards_G2>(std::vector<edwards_G2> &vec)
void edwards_G2::batch_to_special_all_non_zeros(std::vector<edwards_G2> &vec)
{
std::vector<edwards_Fq3> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/edwards/edwards_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class edwards_G2 {

friend std::ostream& operator<<(std::ostream &out, const edwards_G2 &g);
friend std::istream& operator>>(std::istream &in, edwards_G2 &g);

static void batch_to_special_all_non_zeros(std::vector<edwards_G2> &vec);
};

template<mp_size_t m>
Expand All @@ -92,10 +94,5 @@ edwards_G2 operator*(const Fp_model<m, modulus_p> &lhs, const edwards_G2 &rhs)
return scalar_mul<edwards_G2, m>(rhs, lhs.as_bigint());
}

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<edwards_G2>(std::vector<edwards_G2> &vec);

} // libff
#endif // EDWARDS_G2_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/mnt/mnt4/mnt4_g1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,7 @@ std::istream& operator>>(std::istream& in, std::vector<mnt4_G1> &v)
return in;
}

template<>
void batch_to_special_all_non_zeros<mnt4_G1>(std::vector<mnt4_G1> &vec)
void mnt4_G1::batch_to_special_all_non_zeros(std::vector<mnt4_G1> &vec)
{
std::vector<mnt4_Fq> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/mnt/mnt4/mnt4_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class mnt4_G1 {

friend std::ostream& operator<<(std::ostream &out, const mnt4_G1 &g);
friend std::istream& operator>>(std::istream &in, mnt4_G1 &g);

static void batch_to_special_all_non_zeros(std::vector<mnt4_G1> &vec);
};

template<mp_size_t m>
Expand All @@ -99,11 +101,6 @@ mnt4_G1 operator*(const Fp_model<m,modulus_p> &lhs, const mnt4_G1 &rhs)
std::ostream& operator<<(std::ostream& out, const std::vector<mnt4_G1> &v);
std::istream& operator>>(std::istream& in, std::vector<mnt4_G1> &v);

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<mnt4_G1>(std::vector<mnt4_G1> &vec);

} // libff

#endif // MNT4_G1_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/mnt/mnt4/mnt4_g2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,7 @@ std::istream& operator>>(std::istream &in, mnt4_G2 &g)
return in;
}

template<>
void batch_to_special_all_non_zeros<mnt4_G2>(std::vector<mnt4_G2> &vec)
void mnt4_G2::batch_to_special_all_non_zeros(std::vector<mnt4_G2> &vec)
{
std::vector<mnt4_Fq2> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/mnt/mnt4/mnt4_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class mnt4_G2 {

friend std::ostream& operator<<(std::ostream &out, const mnt4_G2 &g);
friend std::istream& operator>>(std::istream &in, mnt4_G2 &g);

static void batch_to_special_all_non_zeros(std::vector<mnt4_G2> &vec);
};

template<mp_size_t m>
Expand All @@ -101,11 +103,6 @@ mnt4_G2 operator*(const Fp_model<m,modulus_p> &lhs, const mnt4_G2 &rhs)
return scalar_mul<mnt4_G2, m>(rhs, lhs.as_bigint());
}

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<mnt4_G2>(std::vector<mnt4_G2> &vec);

} // libff

#endif // MNT4_G2_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/mnt/mnt6/mnt6_g1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,7 @@ std::istream& operator>>(std::istream& in, std::vector<mnt6_G1> &v)
return in;
}

template<>
void batch_to_special_all_non_zeros<mnt6_G1>(std::vector<mnt6_G1> &vec)
void mnt6_G1::batch_to_special_all_non_zeros(std::vector<mnt6_G1> &vec)
{
std::vector<mnt6_Fq> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/mnt/mnt6/mnt6_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class mnt6_G1 {

friend std::ostream& operator<<(std::ostream &out, const mnt6_G1 &g);
friend std::istream& operator>>(std::istream &in, mnt6_G1 &g);

static void batch_to_special_all_non_zeros(std::vector<mnt6_G1> &vec);
};

template<mp_size_t m>
Expand All @@ -99,11 +101,6 @@ mnt6_G1 operator*(const Fp_model<m,modulus_p> &lhs, const mnt6_G1 &rhs)
std::ostream& operator<<(std::ostream& out, const std::vector<mnt6_G1> &v);
std::istream& operator>>(std::istream& in, std::vector<mnt6_G1> &v);

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<mnt6_G1>(std::vector<mnt6_G1> &vec);

} // libff

#endif // MNT6_G1_HPP_
3 changes: 1 addition & 2 deletions libff/algebra/curves/mnt/mnt6/mnt6_g2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,7 @@ std::istream& operator>>(std::istream &in, mnt6_G2 &g)
return in;
}

template<>
void batch_to_special_all_non_zeros<mnt6_G2>(std::vector<mnt6_G2> &vec)
void mnt6_G2::batch_to_special_all_non_zeros(std::vector<mnt6_G2> &vec)
{
std::vector<mnt6_Fq3> Z_vec;
Z_vec.reserve(vec.size());
Expand Down
7 changes: 2 additions & 5 deletions libff/algebra/curves/mnt/mnt6/mnt6_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class mnt6_G2 {

friend std::ostream& operator<<(std::ostream &out, const mnt6_G2 &g);
friend std::istream& operator>>(std::istream &in, mnt6_G2 &g);

static void batch_to_special_all_non_zeros(std::vector<mnt6_G2> &vec);
};

template<mp_size_t m>
Expand All @@ -101,11 +103,6 @@ mnt6_G2 operator*(const Fp_model<m,modulus_p> &lhs, const mnt6_G2 &rhs)
return scalar_mul<mnt6_G2, m>(rhs, lhs.as_bigint());
}

template<typename T>
void batch_to_special_all_non_zeros(std::vector<T> &vec);
template<>
void batch_to_special_all_non_zeros<mnt6_G2>(std::vector<mnt6_G2> &vec);

} // libff

#endif // MNT6_G2_HPP_
Loading