Skip to content

Commit

Permalink
last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielKotov committed Oct 2, 2024
1 parent bda8275 commit d9486f2
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,10 @@ inline void Graph_<FF>::process_current_plookup_gate(bb::UltraCircuitBuilder& ul
if (id == bb::plookup::SHA256_WITNESS_SLICE_3 || id == bb::plookup::SHA256_WITNESS_SLICE_7_ROTATE_4 ||
id == bb::plookup::SHA256_WITNESS_SLICE_8_ROTATE_7 ||
id == bb::plookup::SHA256_WITNESS_SLICE_14_ROTATE_1 || id == bb::plookup::SHA256_BASE16_ROTATE2 ||
id == bb::plookup::SHA256_BASE16 || id == bb::plookup::SHA256_BASE28_ROTATE6 ||
id == bb::plookup::SHA256_BASE28_ROTATE3) {
id == bb::plookup::SHA256_BASE16 || id == bb::plookup::SHA256_BASE16_ROTATE6 ||
id == bb::plookup::SHA256_BASE16_ROTATE7 || id == bb::plookup::SHA256_BASE16_ROTATE8 ||
id == bb::plookup::SHA256_BASE28_ROTATE6 || id == bb::plookup::SHA256_BASE28_ROTATE3 ||
id == bb::plookup::SHA256_BASE28) {
uint32_t real_right_idx = to_real(lookup_block.w_r()[gate_index]);
uint32_t real_out_idx = to_real(lookup_block.w_o()[gate_index]);
if (variables_gate_counts[real_out_idx] != 1 || variables_gate_counts[real_right_idx] != 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,42 +73,6 @@ TEST(ultra_circuit_constructor, test_variables_gate_counts_for_sha256_55_bytes)
}
}

HEAVY_TEST(ultra_circuit_constructor, test_variable_gates_count_for_sha256_NIST_vector_five)
{
auto builder = Builder();

packed_byte_array_ct input(
&builder,
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAA");

packed_byte_array_ct output_bits = stdlib::sha256(input);
Graph graph = Graph(builder);
std::unordered_set<uint32_t> variables_in_on_gate = graph.show_variables_in_one_gate(builder);
for (const auto& elem : variables_in_on_gate) {
bool result1 = check_in_byte_array(elem, input);
bool result2 = check_in_byte_array(elem, output_bits);
bool result3 = check_in_range_lists(elem, 3, builder);
bool check = (result1 == 1) || (result2 == 1) || (result3 == 1);
if (check == false) {
info("elem == ", elem);
info(result1);
info(result2);
info(result3);
info();
}
EXPECT_EQ(check, true);
}
}

TEST(ultra_circuit_constructor, test_variable_gates_count_for_sha256_NIST_vector_one)
{
auto builder = Builder();
Expand Down Expand Up @@ -185,4 +149,40 @@ TEST(ultra_circuit_constructor, test_variable_gates_count_sha256_NIST_vector_fou
bool check = (result1 == 1) || (result2 == 1) || (result3 == 1);
EXPECT_EQ(check, true);
}
}

HEAVY_TEST(ultra_circuit_constructor, test_variable_gates_count_for_sha256_NIST_vector_five)
{
auto builder = Builder();

packed_byte_array_ct input(
&builder,
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAA");

packed_byte_array_ct output_bits = stdlib::sha256(input);
Graph graph = Graph(builder);
std::unordered_set<uint32_t> variables_in_on_gate = graph.show_variables_in_one_gate(builder);
for (const auto& elem : variables_in_on_gate) {
bool result1 = check_in_byte_array(elem, input);
bool result2 = check_in_byte_array(elem, output_bits);
bool result3 = check_in_range_lists(elem, 3, builder);
bool check = (result1 == 1) || (result2 == 1) || (result3 == 1);
if (check == false) {
info("elem == ", elem);
info(result1);
info(result2);
info(result3);
info();
}
EXPECT_EQ(check, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ std::array<field_t<Builder>, 8> sha256_block(const std::array<field_t<Builder>,
/**
* Initialize round variables with previous block output
**/
auto a = map_into_maj_sparse_form(h_init[0]);
sparse_value<Builder> a = sparse_value<Builder>(h_init[0]);
auto b = map_into_maj_sparse_form(h_init[1]);
auto c = map_into_maj_sparse_form(h_init[2]);
// auto d = sparse_value<Builder>(h_init[3]);
auto d = map_into_maj_sparse_form(h_init[3]);
auto e = map_into_choose_sparse_form(h_init[4]);
sparse_value<Builder> d = sparse_value<Builder>(h_init[3]);
sparse_value<Builder> e = sparse_value<Builder>(h_init[4]);
auto f = map_into_choose_sparse_form(h_init[5]);
auto g = map_into_choose_sparse_form(h_init[6]);
auto h = map_into_choose_sparse_form(h_init[7]);
sparse_value<Builder> h = sparse_value<Builder>(h_init[7]);

/**
* Extend witness
Expand Down

0 comments on commit d9486f2

Please sign in to comment.