Skip to content

Commit

Permalink
Fixed constants amount for sha256_process.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iluvmagick committed Feb 20, 2024
1 parent 3b6ebc1 commit 4455c41
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ namespace nil {
integral_type(var_value(assignment, instance_input.data[1]).data)};
std::array<std::array<std::array<integral_type, 3>, 4>, 2> range_chunks;
std::array<std::array<integral_type, 4>, 2> output_chunks;
std::size_t shift = 0;

for (std::size_t data_idx = 0; data_idx < 2; data_idx++) {
for (std::size_t chunk_idx = 0; chunk_idx < 4; chunk_idx++) {
Expand Down Expand Up @@ -275,15 +274,18 @@ namespace nil {
}

template<typename BlueprintFieldType>
std::size_t generate_gates(
std::array<std::size_t, 2> generate_gates(
const plonk_native_decomposition<BlueprintFieldType> &component,
circuit<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>> &bp,
assignment<crypto3::zk::snark::plonk_constraint_system<BlueprintFieldType>>
&assignment,
const typename plonk_native_decomposition<BlueprintFieldType>::input_type
&instance_input) {
&instance_input,
const typename lookup_library<BlueprintFieldType>::left_reserved_type &lookup_tables_indices) {

using var = typename plonk_native_decomposition<BlueprintFieldType>::var;
using constraint = crypto3::zk::snark::plonk_constraint<BlueprintFieldType>;
using lookup_constraint = crypto3::zk::snark::plonk_lookup_constraint<BlueprintFieldType>;

const typename BlueprintFieldType::integral_type one = 1;
std::array<std::size_t, 2> selectors;
Expand Down
24 changes: 12 additions & 12 deletions test/hashes/plonk/decomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,29 @@ void test_decomposition(std::vector<typename BlueprintFieldType::value_type> pub

auto result_check = [&expected_res](AssignmentType &assignment,
typename component_type::result_type &real_res) {
for (std::size_t i = 0; i < real_res.output.size(); i++){
std::cout << var_value(assignment, real_res.output[i]).data << std::endl;
}
for (std::size_t i = 0; i < expected_res.size(); i++){
std::cout << expected_res[i].data << std::endl;
}
// for (std::size_t i = 0; i < real_res.output.size(); i++){
// std::cout << var_value(assignment, real_res.output[i]).data << std::endl;
// }
// for (std::size_t i = 0; i < expected_res.size(); i++){
// std::cout << expected_res[i].data << std::endl;
// }
for (std::size_t i = 0; i < real_res.output.size(); i++){
assert(expected_res[i] == var_value(assignment, real_res.output[i]));
}
};
auto result_check_to_fail = [&expected_res](AssignmentType &assignment,
typename component_type::result_type &real_res) { };
auto result_check_to_fail = [](AssignmentType &assignment,
typename component_type::result_type &real_res) {};

component_type component_instance({0, 1, 2, 3, 4, 5, 6, 7, 8},{},{});

if (expected_to_pass) {
crypto3::test_component<component_type, BlueprintFieldType, ArithmetizationParams, hash_type, Lambda>(
crypto3::test_component<component_type, BlueprintFieldType, hash_type, Lambda>(
component_instance, desc, public_input, result_check, instance_input,
nil::crypto3::detail::connectedness_check_type::WEAK);
nil::blueprint::connectedness_check_type::type::WEAK);
} else {
crypto3::test_component_to_fail<component_type, BlueprintFieldType, ArithmetizationParams, hash_type, Lambda>(
crypto3::test_component_to_fail<component_type, BlueprintFieldType, hash_type, Lambda>(
component_instance, desc, public_input, result_check_to_fail, instance_input,
nil::crypto3::detail::connectedness_check_type::WEAK);
nil::blueprint::connectedness_check_type::type::WEAK);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/hashes/plonk/sha256_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE(blueprint_plonk_sha256_process) {
using BlueprintFieldType = typename curve_type::base_field_type;
constexpr std::size_t WitnessColumns = 9;
constexpr std::size_t PublicInputColumns = 1;
constexpr std::size_t ConstantColumns = 20;
constexpr std::size_t ConstantColumns = 33;
constexpr std::size_t SelectorColumns = 30;
using hash_type = nil::crypto3::hashes::keccak_1600<256>;
constexpr std::size_t Lambda = 1;
Expand Down

0 comments on commit 4455c41

Please sign in to comment.