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

Cleanups and miscellaneous fixes #354

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
96 changes: 46 additions & 50 deletions include/nil/blueprint/algorithms/generate_circuit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,66 +33,62 @@
#include <nil/blueprint/blueprint/plonk/assignment.hpp>

namespace nil {
namespace crypto3 {
namespace blueprint {
namespace components {
namespace blueprint {
namespace components {

BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(generate_circuit)
BOOST_TTI_HAS_STATIC_MEMBER_FUNCTION(generate_circuit)

template<typename ComponentType, typename ArithmetizationType>
typename std::enable_if<
(!(has_static_member_function_generate_circuit<ComponentType,
typename ComponentType::result_type,
boost::mpl::vector<blueprint<ArithmetizationType> &,
blueprint_public_assignment_table<ArithmetizationType> &,
const typename ComponentType::params_type &,
const std::size_t>>::value)),
typename ComponentType::result_type>::type
generate_circuit(
blueprint<ArithmetizationType> &bp,
blueprint_public_assignment_table<ArithmetizationType> &assignment,
const typename ComponentType::params_type & params,
const std::size_t start_row_index){
template<typename ComponentType, typename ArithmetizationType>
typename std::enable_if<(!(has_static_member_function_generate_circuit<
ComponentType,
typename ComponentType::result_type,
boost::mpl::vector<blueprint<ArithmetizationType> &,
assignment<ArithmetizationType> &,
const typename ComponentType::params_type &,
const std::size_t>>::value)),
typename ComponentType::result_type>::type
generate_circuit(blueprint<ArithmetizationType> &bp,
assignment<ArithmetizationType> &assignment,
const typename ComponentType::params_type &params,
const std::size_t start_row_index) {

auto selector_iterator = assignment.find_selector(ComponentType::selector_seed);
std::size_t first_selector_index;
auto selector_iterator = assignment.find_selector(ComponentType::selector_seed);
std::size_t first_selector_index;

if (selector_iterator == assignment.selectors_end()){
first_selector_index = assignment.allocate_selector(ComponentType::selector_seed,
ComponentType::gates_amount);
ComponentType::generate_gates(bp, assignment, params, first_selector_index);
} else {
first_selector_index = selector_iterator->second;
}
if (selector_iterator == assignment.selectors_end()) {
first_selector_index =
assignment.allocate_selector(ComponentType::selector_seed, ComponentType::gates_amount);
ComponentType::generate_gates(bp, assignment, params, first_selector_index);
} else {
first_selector_index = selector_iterator->second;
}

assignment.enable_selector(first_selector_index, start_row_index);
assignment.enable_selector(first_selector_index, start_row_index);

ComponentType::generate_copy_constraints(bp, assignment, params, start_row_index);
ComponentType::generate_copy_constraints(bp, assignment, params, start_row_index);

return typename ComponentType::result_type(params, start_row_index);
}
return typename ComponentType::result_type(params, start_row_index);
}

template<typename ComponentType, typename ArithmetizationType>
typename std::enable_if<
(has_static_member_function_generate_circuit<ComponentType,
typename ComponentType::result_type,
boost::mpl::vector<blueprint<ArithmetizationType> &,
blueprint_public_assignment_table<ArithmetizationType> &,
const typename ComponentType::params_type &,
const std::size_t>>::value),
typename ComponentType::result_type>::type
generate_circuit(
blueprint<ArithmetizationType> &bp,
blueprint_public_assignment_table<ArithmetizationType> &assignment,
const typename ComponentType::params_type & params,
const std::size_t start_row_index){
template<typename ComponentType, typename ArithmetizationType>
typename std::enable_if<(has_static_member_function_generate_circuit<
ComponentType,
typename ComponentType::result_type,
boost::mpl::vector<blueprint<ArithmetizationType> &,
assignment<ArithmetizationType> &,
const typename ComponentType::params_type &,
const std::size_t>>::value),
typename ComponentType::result_type>::type
generate_circuit(blueprint<ArithmetizationType> &bp,
assignment<ArithmetizationType> &assignment,
const typename ComponentType::params_type &params,
const std::size_t start_row_index) {

return ComponentType::generate_circuit(bp, assignment, params, start_row_index);
}
return ComponentType::generate_circuit(bp, assignment, params, start_row_index);
}

} // namespace components
} // namespace blueprint
} // namespace crypto3
} // namespace components
} // namespace blueprint
} // namespace nil

#endif // CRYPTO3_ZK_COMPONENTS_ALGORITHMS_GENERATE_CIRCUIT_HPP
Loading
Loading