diff --git a/bin/assigner/src/main.cpp b/bin/assigner/src/main.cpp index e37e7ca5..7e00fc24 100644 --- a/bin/assigner/src/main.cpp +++ b/bin/assigner/src/main.cpp @@ -180,13 +180,25 @@ void print_size_t( ) { using TTypeBase = nil::marshalling::field_type; auto integer_container = nil::marshalling::types::integral(input); - std::vector char_vector; - char_vector.resize(integer_container.length(), 0x00); - auto write_iter = char_vector.begin(); - nil::marshalling::status_type status = integer_container.write(write_iter, char_vector.size()); - out.write(reinterpret_cast(char_vector.data()), char_vector.size()); + std::array char_array{}; + auto write_iter = char_array.begin(); + ASSERT(integer_container.write(write_iter, char_array.size()) == nil::marshalling::status_type::success); + out.write(reinterpret_cast(char_array.data()), char_array.size()); } +template +inline void print_zero_field( + std::ostream &out +) { + using TTypeBase = nil::marshalling::field_type; + using AssignmentTableType = assignment_proxy; + using field_element = nil::crypto3::marshalling::types::field_element< + TTypeBase, typename AssignmentTableType::field_type::value_type>; + std::array array{}; + out.write(reinterpret_cast(array.data()), array.size()); +} + + template void print_field( const typename assignment_proxy::field_type::value_type &input, @@ -195,11 +207,10 @@ void print_field( using TTypeBase = nil::marshalling::field_type; using AssignmentTableType = assignment_proxy; auto field_container = nil::crypto3::marshalling::types::field_element(input); - std::vector char_vector; - char_vector.resize(field_container.length(), 0x00); - auto write_iter = char_vector.begin(); - nil::marshalling::status_type status = field_container.write(write_iter, char_vector.size()); - out.write(reinterpret_cast(char_vector.data()), char_vector.size()); + std::array char_array{}; + auto write_iter = char_array.begin(); + ASSERT(field_container.write(write_iter, char_array.size()) == nil::marshalling::status_type::success); + out.write(reinterpret_cast(char_array.data()), char_array.size()); } template @@ -212,7 +223,7 @@ void print_vector_value( if (i < table_col.size()) { print_field(table_col[i], out); } else { - print_field(0, out); + print_zero_field(out); } } } @@ -329,7 +340,7 @@ void print_assignment_table(const assignment_proxy &table_p } ASSERT(offset < padded_rows_amount); while(offset < padded_rows_amount) { - print_field(0, out); + print_zero_field(out); offset++; } witness_idx += padded_rows_amount; @@ -359,7 +370,7 @@ void print_assignment_table(const assignment_proxy &table_p } ASSERT(offset < padded_rows_amount); while(offset < padded_rows_amount) { - print_field(0, out); + print_zero_field(out); offset++; } @@ -382,15 +393,15 @@ void print_assignment_table(const assignment_proxy &table_p if (selector_rows.find(j) != selector_rows.end()) { print_field(table_proxy.selector(i, j), out); } else { - print_field(0, out); + print_zero_field(out); } offset++; } } ASSERT(offset < padded_rows_amount); while(offset < padded_rows_amount) { - print_field(0, out); - offset++; + print_zero_field(out); + offset++; } selector_idx += padded_rows_amount;