Skip to content

Commit

Permalink
libzeth: consistent type and file names
Browse files Browse the repository at this point in the history
  • Loading branch information
dtebbs committed Apr 30, 2020
1 parent db1a6a9 commit cfe6813
Show file tree
Hide file tree
Showing 27 changed files with 183 additions and 181 deletions.
2 changes: 1 addition & 1 deletion libzeth/circuits/blake2s/g_primitive.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ template<typename FieldT> void g_primitive<FieldT>::generate_r1cs_witness()

} // namespace libzeth

#endif // __ZETH_CIRCUITS_G_PRIMITIVE_TCC__
#endif // __ZETH_CIRCUITS_G_PRIMITIVE_TCC__
2 changes: 1 addition & 1 deletion libzeth/circuits/merkle_tree/merkle_path_authenticator.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ bool merkle_path_authenticator<FieldT, HashTreeT>::is_valid()

} // namespace libzeth

#endif // __ZETH_CIRCUITS_MERKLE_PATH_AUTHENTICATOR_TCC__
#endif // __ZETH_CIRCUITS_MERKLE_PATH_AUTHENTICATOR_TCC__
2 changes: 1 addition & 1 deletion libzeth/circuits/merkle_tree/merkle_path_compute.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ const libsnark::pb_variable<FieldT> merkle_path_compute<FieldT, HashTreeT>::

} // namespace libzeth

#endif // __ZETH_CIRCUITS_MERKLE_PATH_COMPUTE_TCC__
#endif // __ZETH_CIRCUITS_MERKLE_PATH_COMPUTE_TCC__
2 changes: 1 addition & 1 deletion libzeth/circuits/merkle_tree/merkle_path_selector.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ const libsnark::pb_variable<FieldT> &merkle_path_selector<FieldT>::get_right()

} // namespace libzeth

#endif // __ZETH_CIRCUITS_MERKLE_PATH_SELECTOR_TCC__
#endif // __ZETH_CIRCUITS_MERKLE_PATH_SELECTOR_TCC__
2 changes: 1 addition & 1 deletion libzeth/circuits/mimc/mimc.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,4 @@ void MiMCe7_permutation_gadget<FieldT>::setup_sha3_constants()

} // namespace libzeth

#endif // __ZETH_CIRCUITS_MIMC_TCC__
#endif // __ZETH_CIRCUITS_MIMC_TCC__
2 changes: 1 addition & 1 deletion libzeth/circuits/mimc/mimc_mp.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ FieldT MiMC_mp_gadget<FieldT>::get_hash(const FieldT x, FieldT y)

} // namespace libzeth

#endif // __ZETH_CIRCUITS_MIMC_MP_TCC__
#endif // __ZETH_CIRCUITS_MIMC_MP_TCC__
2 changes: 1 addition & 1 deletion libzeth/circuits/mimc/mimc_round.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ const libsnark::pb_variable<FieldT> &MiMCe7_round_gadget<FieldT>::result() const

} // namespace libzeth

#endif // __ZETH_CIRCUITS_MIMC_ROUND_TCC__
#endif // __ZETH_CIRCUITS_MIMC_ROUND_TCC__
2 changes: 1 addition & 1 deletion libzeth/mpc/groth16/mpc_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef __ZETH_MPC_GROTH16_MPC_UTILS_HPP__
#define __ZETH_MPC_GROTH16_MPC_UTILS_HPP__

#include "libzeth/snarks/groth16/groth16_core.hpp"
#include "libzeth/snarks/groth16/groth16_snark.hpp"

#include <vector>

Expand Down
2 changes: 1 addition & 1 deletion libzeth/mpc/groth16/phase2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define __ZETH_MPC_GROTH16_PHASE2_HPP__

#include "libzeth/mpc/groth16/hash_utils.hpp"
#include "libzeth/snarks/groth16/groth16_core.hpp"
#include "libzeth/snarks/groth16/groth16_snark.hpp"

/// Structures and operations related to the "Phase 2" MPC described in
/// [BoweGM17]. Parts of the implementation use techniques from the
Expand Down
2 changes: 1 addition & 1 deletion libzeth/mpc/groth16/powersoftau_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef __ZETH_MPC_GROTH16_POWERSOFTAU_UTILS_HPP__
#define __ZETH_MPC_GROTH16_POWERSOFTAU_UTILS_HPP__

#include "libzeth/snarks/groth16/groth16_core.hpp"
#include "libzeth/snarks/groth16/groth16_snark.hpp"

#include <istream>
#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libzeth/serialization/filesystem_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ boost::filesystem::path get_path_to_debug_directory()
return boost::filesystem::path(path);
}

} // namespace libzeth
} // namespace libzeth
28 changes: 0 additions & 28 deletions libzeth/snarks/default/default_api.hpp

This file was deleted.

30 changes: 30 additions & 0 deletions libzeth/snarks/default/default_api_handler.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2015-2020 Clearmatics Technologies Ltd
//
// SPDX-License-Identifier: LGPL-3.0+

#ifndef __ZETH_SNARKS_DEFAULT_DEFAULT_API_HANDLER_HPP__
#define __ZETH_SNARKS_DEFAULT_DEFAULT_API_HANDLER_HPP__

#include "libzeth/snarks/default/default_snark.hpp"

#if defined(ZKSNARK_PGHR13)
#include "libzeth/snarks/pghr13/pghr13_api_handler.hpp"
namespace libzeth
{
template<typename ppT>
using default_api_handler = pghr13_api_handler_handler<ppT>;
} // namespace libzeth

#elif defined(ZKSNARK_GROTH16)
#include "libzeth/snarks/groth16/groth16_api_handler.hpp"
namespace libzeth
{
template<typename ppT>
using default_api_handler = groth16_api_handler_handler<ppT>;
} // namespace libzeth

#else
#error No recognized SNARK_* macro defined (see CMakelists.txt).
#endif

#endif // __ZETH_SNARKS_DEFAULT_DEFAULT_API_HANDLER_HPP__
27 changes: 0 additions & 27 deletions libzeth/snarks/default/default_core.hpp

This file was deleted.

26 changes: 26 additions & 0 deletions libzeth/snarks/default/default_snark.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2015-2020 Clearmatics Technologies Ltd
//
// SPDX-License-Identifier: LGPL-3.0+

#ifndef __ZETH_SNARKS_DEFAULT_DEFAULT_SNARK_HPP__
#define __ZETH_SNARKS_DEFAULT_DEFAULT_SNARK_HPP__

#if defined(ZKSNARK_PGHR13)
#include "libzeth/snarks/pghr13/pghr13_snark.hpp"
namespace libzeth
{
template<typename ppT> using default_snark = pghr13_snark<ppT>;
} // namespace libzeth

#elif defined(ZKSNARK_GROTH16)
#include "libzeth/snarks/groth16/groth16_snark.hpp"
namespace libzeth
{
template<typename ppT> using default_snark = groth16_snark<ppT>;
} // namespace libzeth

#else
#error No recognized SNARK_* macro defined (see CMakelists.txt).
#endif

#endif // __ZETH_SNARKS_DEFAULT_DEFAULT_SNARK_HPP__
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
//
// SPDX-License-Identifier: LGPL-3.0+

#ifndef __ZETH_SNARKS_GROTH16_GROTH16_API_HPP__
#define __ZETH_SNARKS_GROTH16_GROTH16_API_HPP__
#ifndef __ZETH_SNARKS_GROTH16_GROTH16_API_HANDLER_HPP__
#define __ZETH_SNARKS_GROTH16_GROTH16_API_HANDLER_HPP__

#include "libzeth/core/extended_proof.hpp"
#include "libzeth/snarks/groth16/groth16_core.hpp"
#include "libzeth/snarks/groth16/groth16_snark.hpp"

#include <api/snark_messages.grpc.pb.h>

namespace libzeth
{

/// Implemetation of API-related functions for the Groth16 snark.
template<typename ppT> class groth16api
template<typename ppT> class groth16_api_handler_handler
{
public:
using snarkT = groth16snark<ppT>;
using snarkT = groth16_snark<ppT>;

static void format_extended_proof(
const extended_proof<ppT, snarkT> &ext_proof,
Expand All @@ -44,6 +44,6 @@ template<typename ppT> class groth16api

} // namespace libzeth

#include "libzeth/snarks/groth16/groth16_api.tcc"
#include "libzeth/snarks/groth16/groth16_api_handler.tcc"

#endif // __ZETH_SNARKS_GROTH16_GROTH16_API_HPP__
#endif // __ZETH_SNARKS_GROTH16_GROTH16_API_HANDLER_HPP__
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
//
// SPDX-License-Identifier: LGPL-3.0+

#ifndef __ZETH_SNARKS_GROTH16_GROTH16_API_TCC__
#define __ZETH_SNARKS_GROTH16_GROTH16_API_TCC__
#ifndef __ZETH_SNARKS_GROTH16_GROTH16_API_HANDLER_TCC__
#define __ZETH_SNARKS_GROTH16_GROTH16_API_HANDLER_TCC__

#include "libzeth/core/ff_utils.hpp"
#include "libzeth/serialization/api/api_io.hpp"
#include "libzeth/snarks/groth16/groth16_api.hpp"
#include "libzeth/snarks/groth16/groth16_api_handler.hpp"

namespace libzeth
{

template<typename ppT>
void groth16api<ppT>::format_extended_proof(
const extended_proof<ppT, groth16api<ppT>::snarkT> &ext_proof,
void groth16_api_handler_handler<ppT>::format_extended_proof(
const extended_proof<ppT, groth16_api_handler_handler<ppT>::snarkT>
&ext_proof,
zeth_proto::ExtendedProof *message)
{
libsnark::r1cs_gg_ppzksnark_proof<ppT> proof_obj = ext_proof.get_proof();
Expand Down Expand Up @@ -48,8 +49,8 @@ void groth16api<ppT>::format_extended_proof(
}

template<typename ppT>
void groth16api<ppT>::format_verification_key(
const typename groth16api<ppT>::snarkT::VerifKeyT &vk,
void groth16_api_handler_handler<ppT>::format_verification_key(
const typename groth16_api_handler_handler<ppT>::snarkT::VerifKeyT &vk,
zeth_proto::VerificationKey *message)
{
zeth_proto::HexPointBaseGroup1Affine *a =
Expand Down Expand Up @@ -88,7 +89,7 @@ void groth16api<ppT>::format_verification_key(
}

template<typename ppT>
libzeth::extended_proof<ppT, groth16snark<ppT>> groth16api<
libzeth::extended_proof<ppT, groth16_snark<ppT>> groth16_api_handler_handler<
ppT>::parse_extended_proof(const zeth_proto::ExtendedProof &ext_proof)
{
const zeth_proto::ExtendedProofGROTH16 &e_proof =
Expand All @@ -106,14 +107,14 @@ libzeth::extended_proof<ppT, groth16snark<ppT>> groth16api<

libsnark::r1cs_gg_ppzksnark_proof<ppT> proof(
std::move(a), std::move(b), std::move(c));
libzeth::extended_proof<ppT, groth16snark<ppT>> res(proof, inputs);
libzeth::extended_proof<ppT, groth16_snark<ppT>> res(proof, inputs);

return res;
}

template<typename ppT>
typename groth16snark<ppT>::VerifKeyT groth16api<ppT>::parse_verification_key(
const zeth_proto::VerificationKey &verification_key)
typename groth16_snark<ppT>::VerifKeyT groth16_api_handler_handler<ppT>::
parse_verification_key(const zeth_proto::VerificationKey &verification_key)
{
const zeth_proto::VerificationKeyGROTH16 &verif_key =
verification_key.groth16_verification_key();
Expand All @@ -137,7 +138,7 @@ typename groth16snark<ppT>::VerifKeyT groth16api<ppT>::parse_verification_key(
}

template<typename ppT>
void groth16api<ppT>::prepare_proof_response(
void groth16_api_handler_handler<ppT>::prepare_proof_response(
const extended_proof<ppT, snarkT> &ext_proof,
zeth_proto::ExtendedProof *message)
{
Expand Down Expand Up @@ -173,7 +174,7 @@ void groth16api<ppT>::prepare_proof_response(
}

template<typename ppT>
void groth16api<ppT>::prepare_verification_key_response(
void groth16_api_handler_handler<ppT>::prepare_verification_key_response(
const typename snarkT::VerifKeyT &vk, zeth_proto::VerificationKey *message)
{
zeth_proto::HexPointBaseGroup1Affine *a =
Expand Down Expand Up @@ -213,4 +214,4 @@ void groth16api<ppT>::prepare_verification_key_response(

} // namespace libzeth

#endif // __ZETH_SNARKS_GROTH16_GROTH16_API_TCC__
#endif // __ZETH_SNARKS_GROTH16_GROTH16_API_HANDLER_TCC__
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: LGPL-3.0+

#ifndef __ZETH_SNARKS_GROTH16_GROTH16_CORE_HPP__
#define __ZETH_SNARKS_GROTH16_GROTH16_CORE_HPP__
#ifndef __ZETH_SNARKS_GROTH16_GROTH16_SNARK_HPP__
#define __ZETH_SNARKS_GROTH16_GROTH16_SNARK_HPP__

#include <boost/filesystem.hpp>
#include <libsnark/gadgetlib1/protoboard.hpp>
Expand All @@ -13,7 +13,7 @@ namespace libzeth
{

/// Core types and operations for the GROTH16 snark
template<typename ppT> class groth16snark
template<typename ppT> class groth16_snark
{
public:
typedef libsnark::r1cs_gg_ppzksnark_proving_key<ppT> ProvingKeyT;
Expand Down Expand Up @@ -63,14 +63,14 @@ template<typename ppT> class groth16snark

/// Check well-formedness of a proving key
template<typename ppT>
static bool is_well_formed(const typename groth16snark<ppT>::ProvingKeyT &pk);
static bool is_well_formed(const typename groth16_snark<ppT>::ProvingKeyT &pk);

/// Check well-formedness of a verification key
template<typename ppT>
static bool is_well_formed(const typename groth16snark<ppT>::VerifKeyT &vk);
static bool is_well_formed(const typename groth16_snark<ppT>::VerifKeyT &vk);

} // namespace libzeth

#include "libzeth/snarks/groth16/groth16_core.tcc"
#include "libzeth/snarks/groth16/groth16_snark.tcc"

#endif // __ZETH_SNARKS_GROTH16_GROTH16_CORE_HPP__
#endif // __ZETH_SNARKS_GROTH16_GROTH16_SNARK_HPP__
Loading

0 comments on commit cfe6813

Please sign in to comment.