Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "sha256_constraint.hpp"
#include "barretenberg/stdlib/hash/sha256/sha256.hpp"
#include "barretenberg/stdlib/hash/sha256/sha256_plookup.hpp"
#include "msgpack/v3/unpack_decl.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "msgpack/v3/unpack_decl.hpp"

why is this needed?

#include "round.hpp"

namespace acir_format {
Expand Down Expand Up @@ -39,7 +40,12 @@ template <typename Builder> void create_sha256_constraints(Builder& builder, con
auto bytes = output_bytes.bytes();

for (size_t i = 0; i < bytes.size(); ++i) {
builder.assert_equal(bytes[i].normalize().witness_index, constraint.result[i]);
auto normalised = bytes[i].normalize();
if (normalised.is_constant()) {
builder.fix_witness(constraint.result[i], normalised.get_value());
} else {
builder.assert_equal(bytes[i].normalize().witness_index, constraint.result[i]);
}
}
}

Expand Down Expand Up @@ -69,17 +75,22 @@ void create_sha256_compression_constraints(Builder& builder, const Sha256Compres
auto output_bytes = stdlib::sha256_plookup::sha256_block<Builder>(hash_inputs, inputs);

for (size_t i = 0; i < 8; ++i) {
poly_triple assert_equal{
.a = output_bytes[i].normalize().witness_index,
.b = constraint.result[i],
.c = 0,
.q_m = 0,
.q_l = 1,
.q_r = -1,
.q_o = 0,
.q_c = 0,
};
builder.create_poly_gate(assert_equal);
auto normalised_output = output_bytes[i].normalize();
if (normalised_output.is_constant()) {
builder.fix_witness(constraint.result[i], normalised_output.get_value());
} else {
poly_triple assert_equal{
.a = normalised_output.witness_index,
.b = constraint.result[i],
.c = 0,
.q_m = 0,
.q_l = 1,
.q_r = -1,
.q_o = 0,
.q_c = 0,
};
builder.create_poly_gate(assert_equal);
}
}
}

Expand Down