Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
87 changes: 18 additions & 69 deletions avm-transpiler/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions barretenberg/cpp/src/barretenberg/crypto/blake3s/blake3s.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <iostream>
#include <type_traits>

#include "barretenberg/common/assert.hpp"
#include "blake3s.hpp"

namespace blake3 {
Expand Down Expand Up @@ -240,6 +241,7 @@ constexpr void blake3_hasher_finalize(const blake3_hasher* self, uint8_t* out)

std::vector<uint8_t> blake3s(std::vector<uint8_t> const& input)
{
ASSERT(input.size() <= 1024, "Barretenberg does not support blake3s with input lengths greater than 1024 bytes.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a test here as well that triggers this ASSERT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was actually not building. Since this is outside stdlib, I decided to change it to an error throw and catch it in the test.

blake3_hasher hasher;
blake3_hasher_init(&hasher);
blake3_hasher_update(&hasher, static_cast<const uint8_t*>(input.data()), input.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,6 @@ std::vector<uint8_t> blake3s(std::vector<uint8_t> const& input,
// Initialize the hasher.
blake3_hasher hasher;
blake3_hasher_init(&hasher);

switch (mode_id) {
case HASH_MODE:
blake3_hasher_init(&hasher);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ template <typename Builder> void create_blake3_constraints(Builder& builder, con

// XXX: The implementation requires us to truncate the element to the nearest byte and not bit
auto num_bytes = round_to_nearest_byte(num_bits);

ASSERT(num_bytes <= 1024, "barretenberg does not support blake3 inputs with more than 1024 bytes");
field_ct element = to_field_ct(witness_index, builder);
byte_array_ct element_bytes(element, num_bytes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ using namespace blake3_internal;

template <typename Builder> byte_array<Builder> blake3s(const byte_array<Builder>& input)
{
ASSERT(input.size() <= 1024, "Barretenberg does not support blake3s with input lengths greater than 1024 bytes.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice! Could you please also add tests that trigger this ASSERT for completeness? You probably need to use EXPECT_DEATH for such a test, see this test for example.


if constexpr (HasPlookup<Builder>) {
return blake3s_plookup::blake3s<Builder>(input);
}
Expand Down
Loading