Clearmatics Libsnark
0.1
C++ library for zkSNARK proofs
|
Go to the documentation of this file.
47 #ifndef R1CS_PPZKSNARK_HPP_
48 #define R1CS_PPZKSNARK_HPP_
50 #include <libff/algebra/curves/public_params.hpp>
64 template<
typename ppT>
68 template<
typename ppT>
96 libff::G1_vector<ppT> &&
H_query,
97 libff::G1_vector<ppT> &&
K_query,
131 libff::print_indent();
132 printf(
"* G1 elements in PK: %zu\n", this->
G1_size());
133 libff::print_indent();
134 printf(
"* Non-zero G1 elements in PK: %zu\n", this->
G1_sparse_size());
135 libff::print_indent();
136 printf(
"* G2 elements in PK: %zu\n", this->
G2_size());
137 libff::print_indent();
138 printf(
"* Non-zero G2 elements in PK: %zu\n", this->
G2_sparse_size());
139 libff::print_indent();
140 printf(
"* PK size in bits: %zu\n", this->
size_in_bits());
144 friend std::ostream &operator<<<ppT>(
146 friend std::istream &
operator>>
154 template<
typename ppT>
158 template<
typename ppT>
204 2 * libff::G1<ppT>::size_in_bits() +
206 5 * libff::G2<ppT>::size_in_bits());
211 libff::print_indent();
212 printf(
"* G1 elements in VK: %zu\n", this->
G1_size());
213 libff::print_indent();
214 printf(
"* G2 elements in VK: %zu\n", this->
G2_size());
215 libff::print_indent();
216 printf(
"* VK size in bits: %zu\n", this->
size_in_bits());
220 friend std::ostream &operator<<<ppT>(
222 friend std::istream &
operator>>
226 const size_t input_size);
233 template<
typename ppT>
238 template<
typename ppT>
265 friend std::ostream &operator<<<ppT>(
268 friend std::istream &
operator>><ppT>(
289 :
pk(std::move(
pk)),
vk(std::move(
vk))
300 template<
typename ppT>
304 template<
typename ppT>
326 this->g_A.
g = libff::G1<ppT>::one();
327 this->g_A.
h = libff::G1<ppT>::one();
328 this->g_B.
g = libff::G2<ppT>::one();
329 this->g_B.
h = libff::G1<ppT>::one();
330 this->g_C.
g = libff::G1<ppT>::one();
331 this->g_C.
h = libff::G1<ppT>::one();
332 this->g_H = libff::G1<ppT>::one();
333 this->g_K = libff::G1<ppT>::one();
339 libff::G1<ppT> &&
g_H,
340 libff::G1<ppT> &&
g_K)
353 return G1_size() * libff::G1<ppT>::size_in_bits() +
354 G2_size() * libff::G2<ppT>::size_in_bits();
359 libff::print_indent();
360 printf(
"* G1 elements in proof: %zu\n", this->
G1_size());
361 libff::print_indent();
362 printf(
"* G2 elements in proof: %zu\n", this->
G2_size());
363 libff::print_indent();
364 printf(
"* Proof size in bits: %zu\n", this->
size_in_bits());
370 g_A.
g.is_well_formed() &&
g_A.
h.is_well_formed() &&
371 g_B.
g.is_well_formed() &&
g_B.
h.is_well_formed() &&
372 g_C.
g.is_well_formed() &&
g_C.
h.is_well_formed() &&
373 g_H.is_well_formed() &&
g_K.is_well_formed());
377 friend std::ostream &operator<<<ppT>(
379 friend std::istream &
operator>>
393 libff::multi_exp_base_form BaseForm = libff::multi_exp_base_form_normal>
395 const r1cs_ppzksnark_constraint_system<ppT> &cs);
408 libff::multi_exp_method Method = libff::multi_exp_method_bos_coster,
409 libff::multi_exp_base_form BaseForm = libff::multi_exp_base_form_normal>
411 const r1cs_ppzksnark_proving_key<ppT> &pk,
412 const r1cs_ppzksnark_primary_input<ppT> &primary_input,
413 const r1cs_ppzksnark_auxiliary_input<ppT> &auxiliary_input);
436 template<
typename ppT>
438 const r1cs_ppzksnark_verification_key<ppT> &vk,
439 const r1cs_ppzksnark_primary_input<ppT> &primary_input,
440 const r1cs_ppzksnark_proof<ppT> &proof);
447 template<
typename ppT>
449 const r1cs_ppzksnark_verification_key<ppT> &vk,
450 const r1cs_ppzksnark_primary_input<ppT> &primary_input,
451 const r1cs_ppzksnark_proof<ppT> &proof);
456 template<
typename ppT>
458 const r1cs_ppzksnark_verification_key<ppT> &vk);
465 template<
typename ppT>
467 const r1cs_ppzksnark_processed_verification_key<ppT> &pvk,
468 const r1cs_ppzksnark_primary_input<ppT> &input,
469 const r1cs_ppzksnark_proof<ppT> &proof);
476 template<
typename ppT>
478 const r1cs_ppzksnark_processed_verification_key<ppT> &pvk,
479 const r1cs_ppzksnark_primary_input<ppT> &primary_input,
480 const r1cs_ppzksnark_proof<ppT> &proof);
492 template<
typename ppT>
494 const r1cs_ppzksnark_verification_key<ppT> &vk,
495 const r1cs_ppzksnark_primary_input<ppT> &primary_input,
496 const r1cs_ppzksnark_proof<ppT> &proof);
502 #endif // R1CS_PPZKSNARK_HPP_
size_t size_in_bits() const
bool r1cs_ppzksnark_online_verifier_strong_IC(const r1cs_ppzksnark_processed_verification_key< ppT > &pvk, const r1cs_ppzksnark_primary_input< ppT > &primary_input, const r1cs_ppzksnark_proof< ppT > &proof)
bool r1cs_ppzksnark_affine_verifier_weak_IC(const r1cs_ppzksnark_verification_key< ppT > &vk, const r1cs_ppzksnark_primary_input< ppT > &primary_input, const r1cs_ppzksnark_proof< ppT > &proof)
r1cs_ppzksnark_constraint_system< ppT > constraint_system
libff::G1_vector< ppT > K_query
std::ostream & operator<<(std::ostream &out, const accumulation_vector< T > &v)
r1cs_ppzksnark_verification_key< ppT > vk
size_t G1_sparse_size() const
libff::G1_vector< ppT > H_query
static r1cs_ppzksnark_verification_key< ppT > dummy_verification_key(const size_t input_size)
libff::G2_precomp< ppT > vk_rC_Z_g2_precomp
bool operator==(const r1cs_ppzksnark_proof< ppT > &other) const
knowledge_commitment< libff::G2< ppT >, libff::G1< ppT > > g_B
accumulation_vector< libff::G1< ppT > > encoded_IC_query
knowledge_commitment_vector< libff::G1< ppT >, libff::G1< ppT > > A_query
r1cs_ppzksnark_proving_key< ppT > pk
bool r1cs_ppzksnark_online_verifier_weak_IC(const r1cs_ppzksnark_processed_verification_key< ppT > &pvk, const r1cs_ppzksnark_primary_input< ppT > &input, const r1cs_ppzksnark_proof< ppT > &proof)
accumulation_vector< libff::G1< ppT > > encoded_IC_query
libff::G1_precomp< ppT > vk_alphaB_g1_precomp
knowledge_commitment< libff::G1< ppT >, libff::G1< ppT > > g_C
bool operator==(const r1cs_ppzksnark_verification_key< ppT > &other) const
libff::G2< ppT > gamma_g2
r1cs_ppzksnark_keypair(r1cs_ppzksnark_proving_key< ppT > &&pk, r1cs_ppzksnark_verification_key< ppT > &&vk)
bool operator==(const r1cs_ppzksnark_processed_verification_key &other) const
bool operator==(const r1cs_ppzksnark_proving_key< ppT > &other) const
r1cs_ppzksnark_proving_key()
size_t size_in_bits() const
bool r1cs_ppzksnark_verifier_weak_IC(const r1cs_ppzksnark_verification_key< ppT > &vk, const r1cs_ppzksnark_primary_input< ppT > &primary_input, const r1cs_ppzksnark_proof< ppT > &proof)
libff::G2_precomp< ppT > vk_alphaC_g2_precomp
r1cs_ppzksnark_proving_key(knowledge_commitment_vector< libff::G1< ppT >, libff::G1< ppT >> &&A_query, knowledge_commitment_vector< libff::G2< ppT >, libff::G1< ppT >> &&B_query, knowledge_commitment_vector< libff::G1< ppT >, libff::G1< ppT >> &&C_query, libff::G1_vector< ppT > &&H_query, libff::G1_vector< ppT > &&K_query, r1cs_ppzksnark_constraint_system< ppT > &&constraint_system)
libff::G2< ppT > alphaC_g2
r1cs_ppzksnark_proof< ppT > r1cs_ppzksnark_prover(const r1cs_ppzksnark_proving_key< ppT > &pk, const r1cs_ppzksnark_primary_input< ppT > &primary_input, const r1cs_ppzksnark_auxiliary_input< ppT > &auxiliary_input)
r1cs_ppzksnark_verification_key()=default
knowledge_commitment_vector< libff::G2< ppT >, libff::G1< ppT > > B_query
size_t size_in_bits() const
libff::G2_precomp< ppT > vk_gamma_g2_precomp
libff::G1< ppT > alphaB_g1
libff::G1< ppT > gamma_beta_g1
r1cs_ppzksnark_keypair< ppT > r1cs_ppzksnark_generator(const r1cs_ppzksnark_constraint_system< ppT > &cs)
size_t G2_sparse_size() const
r1cs_ppzksnark_verification_key(const libff::G2< ppT > &alphaA_g2, const libff::G1< ppT > &alphaB_g1, const libff::G2< ppT > &alphaC_g2, const libff::G2< ppT > &gamma_g2, const libff::G1< ppT > &gamma_beta_g1, const libff::G2< ppT > &gamma_beta_g2, const libff::G2< ppT > &rC_Z_g2, const accumulation_vector< libff::G1< ppT >> &eIC)
libff::G2< ppT > gamma_beta_g2
knowledge_commitment_vector< libff::G1< ppT >, libff::G1< ppT > > C_query
std::istream & operator>>(std::istream &in, accumulation_vector< T > &v)
r1cs_ppzksnark_keypair()=default
bool r1cs_ppzksnark_verifier_strong_IC(const r1cs_ppzksnark_verification_key< ppT > &vk, const r1cs_ppzksnark_primary_input< ppT > &primary_input, const r1cs_ppzksnark_proof< ppT > &proof)
libff::G2_precomp< ppT > pp_G2_one_precomp
size_t size_in_bits() const
libff::G2_precomp< ppT > vk_gamma_beta_g2_precomp
libff::G2< ppT > alphaA_g2
libff::G2_precomp< ppT > vk_alphaA_g2_precomp
knowledge_commitment< libff::G1< ppT >, libff::G1< ppT > > g_A
bool is_well_formed() const
r1cs_ppzksnark_proving_key< ppT > & operator=(const r1cs_ppzksnark_proving_key< ppT > &other)=default
r1cs_ppzksnark_proof(knowledge_commitment< libff::G1< ppT >, libff::G1< ppT >> &&g_A, knowledge_commitment< libff::G2< ppT >, libff::G1< ppT >> &&g_B, knowledge_commitment< libff::G1< ppT >, libff::G1< ppT >> &&g_C, libff::G1< ppT > &&g_H, libff::G1< ppT > &&g_K)
r1cs_ppzksnark_processed_verification_key< ppT > r1cs_ppzksnark_verifier_process_vk(const r1cs_ppzksnark_verification_key< ppT > &vk)
libff::G1_precomp< ppT > vk_gamma_beta_g1_precomp