/** @file ***************************************************************************** Declaration of interfaces for: - a knowledge commitment, and - a knowledge commitment vector. ***************************************************************************** * @author This file is part of libsnark, developed by SCIPR Lab * and contributors (see AUTHORS). * @copyright MIT license (see LICENSE file) *****************************************************************************/ #ifndef KNOWLEDGE_COMMITMENT_HPP_ #define KNOWLEDGE_COMMITMENT_HPP_ #include "algebra/fields/fp.hpp" #include "common/data_structures/sparse_vector.hpp" namespace libsnark { /********************** Knowledge commitment *********************************/ /** * A knowledge commitment is a pair (g,h) where g is in T1 and h in T2, * and T1 and T2 are groups (written additively). * * Such pairs form a group by defining: * - "zero" = (0,0) * - "one" = (1,1) * - a * (g,h) + b * (g',h') := ( a * g + b * g', a * h + b * h'). */ template struct knowledge_commitment { T1 g; T2 h; knowledge_commitment() = default; knowledge_commitment(const knowledge_commitment &other) = default; knowledge_commitment(knowledge_commitment &&other) = default; knowledge_commitment(const T1 &g, const T2 &h); knowledge_commitment& operator=(const knowledge_commitment &other) = default; knowledge_commitment& operator=(knowledge_commitment &&other) = default; knowledge_commitment operator+(const knowledge_commitment &other) const; bool is_zero() const; bool operator==(const knowledge_commitment &other) const; bool operator!=(const knowledge_commitment &other) const; static knowledge_commitment zero(); static knowledge_commitment one(); void print() const; static size_t size_in_bits(); }; template knowledge_commitment operator*(const bigint &lhs, const knowledge_commitment &rhs); template &modulus_p> knowledge_commitment operator*(const Fp_model &lhs, const knowledge_commitment &rhs); template std::ostream& operator<<(std::ostream& out, const knowledge_commitment &kc); template std::istream& operator>>(std::istream& in, knowledge_commitment &kc); /******************** Knowledge commitment vector ****************************/ /** * A knowledge commitment vector is a sparse vector of knowledge commitments. */ template using knowledge_commitment_vector = sparse_vector >; } // libsnark #include "algebra/knowledge_commitment/knowledge_commitment.tcc" #endif // KNOWLEDGE_COMMITMENT_HPP_