-
Notifications
You must be signed in to change notification settings - Fork 236
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Noir development branch (serialization changes) (#3858)
The report gates diff workflow relies on a compiled from source version of Noir which uses a released version of bb. If any changes are made to bb, it is not reflected in the compiled version of Noir. This can lead to failures if the serialization is changed for example. Since report-gates-diff is a github actions workflow, it doesn't have access the compiled bb binary in CCI. We don't want to recompile it on bb as that would take upwards of half an hour. So that we don't block Noir related PRs that have been reviewed, this branch will be used to merge in the breaking changes to serialization until the issue with reports gate diff has been fixed. # Checklist: Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge. - [ ] If the pull request requires a cryptography review (e.g. cryptographic algorithm implementations) I have added the 'crypto' tag. - [ ] I have reviewed my diff in github, line by line and removed unexpected formatting changes, testing logs, or commented-out code. - [ ] Every change is related to the PR description. - [ ] I have [linked](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) this pull request to relevant issues (if any exist). --------- Co-authored-by: guipublic <[email protected]> Co-authored-by: guipublic <[email protected]> Co-authored-by: Tom French <[email protected]>
- Loading branch information
1 parent
8cda00d
commit d2ae2cd
Showing
35 changed files
with
913 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
barretenberg/cpp/src/barretenberg/dsl/acir_format/blake3_constraint.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#include "blake3_constraint.hpp" | ||
#include "round.hpp" | ||
|
||
namespace acir_format { | ||
|
||
template <typename Builder> void create_blake3_constraints(Builder& builder, const Blake3Constraint& constraint) | ||
{ | ||
using byte_array_ct = proof_system::plonk::stdlib::byte_array<Builder>; | ||
using field_ct = proof_system::plonk::stdlib::field_t<Builder>; | ||
|
||
// Create byte array struct | ||
byte_array_ct arr(&builder); | ||
|
||
// Get the witness assignment for each witness index | ||
// Write the witness assignment to the byte_array | ||
for (const auto& witness_index_num_bits : constraint.inputs) { | ||
auto witness_index = witness_index_num_bits.witness; | ||
auto num_bits = witness_index_num_bits.num_bits; | ||
|
||
// 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); | ||
|
||
field_ct element = field_ct::from_witness_index(&builder, witness_index); | ||
byte_array_ct element_bytes(element, num_bytes); | ||
|
||
arr.write(element_bytes); | ||
} | ||
|
||
byte_array_ct output_bytes = proof_system::plonk::stdlib::blake3s<Builder>(arr); | ||
|
||
// Convert byte array to vector of field_t | ||
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]); | ||
} | ||
} | ||
|
||
template void create_blake3_constraints<UltraCircuitBuilder>(UltraCircuitBuilder& builder, | ||
const Blake3Constraint& constraint); | ||
template void create_blake3_constraints<GoblinUltraCircuitBuilder>(GoblinUltraCircuitBuilder& builder, | ||
const Blake3Constraint& constraint); | ||
|
||
} // namespace acir_format |
29 changes: 29 additions & 0 deletions
29
barretenberg/cpp/src/barretenberg/dsl/acir_format/blake3_constraint.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
#include "barretenberg/dsl/types.hpp" | ||
#include "barretenberg/serialize/msgpack.hpp" | ||
#include <cstdint> | ||
#include <vector> | ||
|
||
namespace acir_format { | ||
|
||
struct Blake3Input { | ||
uint32_t witness; | ||
uint32_t num_bits; | ||
|
||
// For serialization, update with any new fields | ||
MSGPACK_FIELDS(witness, num_bits); | ||
friend bool operator==(Blake3Input const& lhs, Blake3Input const& rhs) = default; | ||
}; | ||
|
||
struct Blake3Constraint { | ||
std::vector<Blake3Input> inputs; | ||
std::vector<uint32_t> result; | ||
|
||
// For serialization, update with any new fields | ||
MSGPACK_FIELDS(inputs, result); | ||
friend bool operator==(Blake3Constraint const& lhs, Blake3Constraint const& rhs) = default; | ||
}; | ||
|
||
template <typename Builder> void create_blake3_constraints(Builder& builder, const Blake3Constraint& constraint); | ||
|
||
} // namespace acir_format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.