Skip to content
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

clang compatibility fixes #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions src/algebra/curves/alt_bn128/alt_bn128_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ alt_bn128_G1 operator*(const bigint<m> &lhs, const alt_bn128_G1 &rhs)
return scalar_mul<alt_bn128_G1, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
alt_bn128_G1 operator*(const Fp_model<m,modulus_p> &lhs, const alt_bn128_G1 &rhs)
template<typename T>
alt_bn128_G1 operator*(const T &lhs, const alt_bn128_G1 &rhs)
{
return scalar_mul<alt_bn128_G1, m>(rhs, lhs.as_bigint());
return scalar_mul<alt_bn128_G1, T::num_limbs>(rhs, lhs.as_bigint());
}

std::ostream& operator<<(std::ostream& out, const std::vector<alt_bn128_G1> &v);
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/curves/alt_bn128/alt_bn128_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ alt_bn128_G2 operator*(const bigint<m> &lhs, const alt_bn128_G2 &rhs)
return scalar_mul<alt_bn128_G2, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
alt_bn128_G2 operator*(const Fp_model<m,modulus_p> &lhs, const alt_bn128_G2 &rhs)
template<typename T>
alt_bn128_G2 operator*(const T &lhs, const alt_bn128_G2 &rhs)
{
return scalar_mul<alt_bn128_G2, m>(rhs, lhs.as_bigint());
return scalar_mul<alt_bn128_G2, T::num_limbs>(rhs, lhs.as_bigint());
}

template<typename T>
Expand Down
8 changes: 4 additions & 4 deletions src/algebra/curves/bn128/bn128_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ bn128_G1 operator*(const bigint<m> &lhs, const bn128_G1 &rhs)
{
return scalar_mul<bn128_G1, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
bn128_G1 operator*(const Fp_model<m,modulus_p> &lhs, const bn128_G1 &rhs)
template<typename T>
bn128_G1 operator*(const T &lhs, const bn128_G1 &rhs)
{
return scalar_mul<bn128_G1, m>(rhs, lhs.as_bigint());
return scalar_mul<bn128_G1, T::num_limbs>(rhs, lhs.as_bigint());
}

std::ostream& operator<<(std::ostream& out, const std::vector<bn128_G1> &v);
Expand Down
15 changes: 13 additions & 2 deletions src/algebra/curves/bn128/bn128_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,22 @@ bn128_G2 operator*(const bigint<m> &lhs, const bn128_G2 &rhs)
return scalar_mul<bn128_G2, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
bn128_G2 operator*(const Fp_model<m, modulus_p> &lhs, const bn128_G2 &rhs)

template<typename T>
bn128_G2 operator*(const T &lhs, const bn128_G2 &rhs)
{
return scalar_mul<bn128_G2, T::num_limbs>(rhs, lhs.as_bigint());
}



/*
template<mp_size_t m>
bn128_G2 operator*(const Fp_model<m, libff::bn128_modulus_r> &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);
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/curves/edwards/edwards_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ edwards_G1 operator*(const bigint<m> &lhs, const edwards_G1 &rhs)
return scalar_mul<edwards_G1, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
edwards_G1 operator*(const Fp_model<m,modulus_p> &lhs, const edwards_G1 &rhs)
template<typename T>
edwards_G1 operator*(const T &lhs, const edwards_G1 &rhs)
{
return scalar_mul<edwards_G1, m>(rhs, lhs.as_bigint());
return scalar_mul<edwards_G1, T::num_limbs>(rhs, lhs.as_bigint());
}

std::ostream& operator<<(std::ostream& out, const std::vector<edwards_G1> &v);
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/curves/edwards/edwards_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ edwards_G2 operator*(const bigint<m> &lhs, const edwards_G2 &rhs)
return scalar_mul<edwards_G2, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
edwards_G2 operator*(const Fp_model<m, modulus_p> &lhs, const edwards_G2 &rhs)
template<typename T>
edwards_G2 operator*(const T &lhs, const edwards_G2 &rhs)
{
return scalar_mul<edwards_G2, m>(rhs, lhs.as_bigint());
return scalar_mul<edwards_G2, T::num_limbs>(rhs, lhs.as_bigint());
}

template<typename T>
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/curves/mnt/mnt4/mnt4_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ mnt4_G1 operator*(const bigint<m> &lhs, const mnt4_G1 &rhs)
return scalar_mul<mnt4_G1, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
mnt4_G1 operator*(const Fp_model<m,modulus_p> &lhs, const mnt4_G1 &rhs)
template<typename T>
mnt4_G1 operator*(const T &lhs, const mnt4_G1 &rhs)
{
return scalar_mul<mnt4_G1, m>(rhs, lhs.as_bigint());
return scalar_mul<mnt4_G1, T::num_limbs>(rhs, lhs.as_bigint());
}

std::ostream& operator<<(std::ostream& out, const std::vector<mnt4_G1> &v);
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/curves/mnt/mnt4/mnt4_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ mnt4_G2 operator*(const bigint<m> &lhs, const mnt4_G2 &rhs)
return scalar_mul<mnt4_G2, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
mnt4_G2 operator*(const Fp_model<m,modulus_p> &lhs, const mnt4_G2 &rhs)
template<typename T>
mnt4_G2 operator*(const T &lhs, const mnt4_G2 &rhs)
{
return scalar_mul<mnt4_G2, m>(rhs, lhs.as_bigint());
return scalar_mul<mnt4_G2, T::num_limbs>(rhs, lhs.as_bigint());
}

template<typename T>
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/curves/mnt/mnt6/mnt6_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ mnt6_G1 operator*(const bigint<m> &lhs, const mnt6_G1 &rhs)
return scalar_mul<mnt6_G1, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
mnt6_G1 operator*(const Fp_model<m,modulus_p> &lhs, const mnt6_G1 &rhs)
template<typename T>
mnt6_G1 operator*(const T &lhs, const mnt6_G1 &rhs)
{
return scalar_mul<mnt6_G1, m>(rhs, lhs.as_bigint());
return scalar_mul<mnt6_G1, T::num_limbs>(rhs, lhs.as_bigint());
}

std::ostream& operator<<(std::ostream& out, const std::vector<mnt6_G1> &v);
Expand Down
6 changes: 3 additions & 3 deletions src/algebra/curves/mnt/mnt6/mnt6_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ mnt6_G2 operator*(const bigint<m> &lhs, const mnt6_G2 &rhs)
return scalar_mul<mnt6_G2, m>(rhs, lhs);
}

template<mp_size_t m, const bigint<m>& modulus_p>
mnt6_G2 operator*(const Fp_model<m,modulus_p> &lhs, const mnt6_G2 &rhs)
template<typename T>
mnt6_G2 operator*(const T &lhs, const mnt6_G2 &rhs)
{
return scalar_mul<mnt6_G2, m>(rhs, lhs.as_bigint());
return scalar_mul<mnt6_G2, T::num_limbs>(rhs, lhs.as_bigint());
}

template<typename T>
Expand Down
5 changes: 3 additions & 2 deletions src/common/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,15 @@ bool is_little_endian();

std::string FORMAT(const std::string &prefix, const char* format, ...);

const std::string empty("");
/* A variadic template to suppress unused argument warnings */
template<typename ... Types>
void UNUSED(Types&&...) {}
const std::string& UNUSED(Types&&...) { return empty; }

#ifdef DEBUG
#define FMT FORMAT
#else
#define FMT(...) (UNUSED(__VA_ARGS__), "")
#define FMT(...) UNUSED(__VA_ARGS__)
#endif

void serialize_bit_vector(std::ostream &out, const bit_vector &v);
Expand Down