Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 043467b

Browse files
CblPOK-gitnkaskov
authored andcommitted
Minor changes in sha2-256 component. #107
1 parent 9ee7077 commit 043467b

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

include/nil/blueprint/components/hashes/sha256/plonk/sha256.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ namespace nil {
7777
std::array<var, 2> output;
7878

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

test/hashes/plonk/sha256.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ void test_sha256(std::vector<typename BlueprintFieldType::value_type> public_inp
6464
var(0, 0, false, var::column_type::public_input), var(0, 1, false, var::column_type::public_input),
6565
var(0, 2, false, var::column_type::public_input), var(0, 3, false, var::column_type::public_input)};
6666

67+
component_type component_instance({0, 1, 2, 3, 4, 5, 6, 7, 8},{0},{});
68+
6769
typename component_type::input_type instance_input = {input_state_var};
6870
auto result_check = [](AssignmentType &assignment,
6971
typename component_type::result_type &real_res) {
72+
std::cout << std::hex << "real_res: " << var_value(assignment, real_res.output[0]).data << " " << var_value(assignment, real_res.output[1]).data << std::endl;
7073
};
7174

72-
component_type component_instance({0, 1, 2, 3, 4, 5, 6, 7, 8},{0},{});
73-
7475
crypto3::test_component<component_type, BlueprintFieldType, ArithmetizationParams, hash_type, Lambda>(
7576
component_instance, public_input, result_check, instance_input);
7677
}
@@ -84,6 +85,9 @@ BOOST_AUTO_TEST_CASE(blueprint_plonk_sha256_test0) {
8485
typename BlueprintFieldType::value_type s = typename BlueprintFieldType::value_type(2).pow(126);
8586

8687
test_sha256<BlueprintFieldType>({s, s + 1, s + 2, s + 3});
88+
test_sha256<BlueprintFieldType>({0, 0, 0, 0});
89+
test_sha256<BlueprintFieldType>({0xffffffffffffffff_cppui64, 0xffffffffffffffff_cppui64, 0xffffffffffffffff_cppui64, 0xffffffffffffffff_cppui64});
90+
test_sha256<BlueprintFieldType>({1, 1, 1, 1});
8791
}
8892

8993
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)