/** @file ***************************************************************************** Implementation of interfaces for: - a knowledge commitment, and - a knowledge commitment vector. See knowledge_commitment.hpp . ***************************************************************************** * @author This file is part of libsnark, developed by SCIPR Lab * and contributors (see AUTHORS). * @copyright MIT license (see LICENSE file) *****************************************************************************/ #ifndef KNOWLEDGE_COMMITMENT_TCC_ #define KNOWLEDGE_COMMITMENT_TCC_ namespace libsnark { template knowledge_commitment::knowledge_commitment(const T1 &g, const T2 &h) : g(g), h(h) { } template knowledge_commitment knowledge_commitment::zero() { return knowledge_commitment(T1::zero(), T2::zero()); } template knowledge_commitment knowledge_commitment::one() { return knowledge_commitment(T1::one(), T2::one()); } template knowledge_commitment knowledge_commitment::operator+(const knowledge_commitment &other) const { return knowledge_commitment(this->g + other.g, this->h + other.h); } template bool knowledge_commitment::is_zero() const { return (g.is_zero() && h.is_zero()); } template bool knowledge_commitment::operator==(const knowledge_commitment &other) const { return (this->g == other.g && this->h == other.h); } template bool knowledge_commitment::operator!=(const knowledge_commitment &other) const { return !((*this) == other); } template knowledge_commitment operator*(const bigint &lhs, const knowledge_commitment &rhs) { return knowledge_commitment(lhs * rhs.g, lhs * rhs.h); } template &modulus_p> knowledge_commitment operator*(const Fp_model &lhs, const knowledge_commitment &rhs) { return (lhs.as_bigint()) * rhs; } template void knowledge_commitment::print() const { printf("knowledge_commitment.g:\n"); g.print(); printf("knowledge_commitment.h:\n"); h.print(); } template size_t knowledge_commitment::size_in_bits() { return T1::size_in_bits() + T2::size_in_bits(); } template std::ostream& operator<<(std::ostream& out, const knowledge_commitment &kc) { out << kc.g << OUTPUT_SEPARATOR << kc.h; return out; } template std::istream& operator>>(std::istream& in, knowledge_commitment &kc) { in >> kc.g; consume_OUTPUT_SEPARATOR(in); in >> kc.h; return in; } } // libsnark #endif // KNOWLEDGE_COMMITMENT_TCC_