Skip to content

Commit

Permalink
Minor changes in sha2-256 component. #107
Browse files Browse the repository at this point in the history
  • Loading branch information
CblPOK-git authored and nkaskov committed Mar 2, 2023
1 parent 9ee7077 commit 043467b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ namespace nil {
std::array<var, 2> output;

result_type(const sha256 &component, std::uint32_t start_row_index) {
std::array<var, 2> output = {var(component.W(0), start_row_index + rows_amount - 1, false),
var(component.W(1), start_row_index + rows_amount - 1, false)};
output = {var(component.W(0), start_row_index + rows_amount - 1, false),
var(component.W(1), start_row_index + rows_amount - 1, false)};
}
};

Expand Down
8 changes: 6 additions & 2 deletions test/hashes/plonk/sha256.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ void test_sha256(std::vector<typename BlueprintFieldType::value_type> public_inp
var(0, 0, false, var::column_type::public_input), var(0, 1, false, var::column_type::public_input),
var(0, 2, false, var::column_type::public_input), var(0, 3, false, var::column_type::public_input)};

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

typename component_type::input_type instance_input = {input_state_var};
auto result_check = [](AssignmentType &assignment,
typename component_type::result_type &real_res) {
std::cout << std::hex << "real_res: " << var_value(assignment, real_res.output[0]).data << " " << var_value(assignment, real_res.output[1]).data << std::endl;
};

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

crypto3::test_component<component_type, BlueprintFieldType, ArithmetizationParams, hash_type, Lambda>(
component_instance, public_input, result_check, instance_input);
}
Expand All @@ -84,6 +85,9 @@ BOOST_AUTO_TEST_CASE(blueprint_plonk_sha256_test0) {
typename BlueprintFieldType::value_type s = typename BlueprintFieldType::value_type(2).pow(126);

test_sha256<BlueprintFieldType>({s, s + 1, s + 2, s + 3});
test_sha256<BlueprintFieldType>({0, 0, 0, 0});
test_sha256<BlueprintFieldType>({0xffffffffffffffff_cppui64, 0xffffffffffffffff_cppui64, 0xffffffffffffffff_cppui64, 0xffffffffffffffff_cppui64});
test_sha256<BlueprintFieldType>({1, 1, 1, 1});
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 043467b

Please sign in to comment.