Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9f962a8
Several patches to cycle_group and cycle_group fuzzer
Sarkoxed Feb 28, 2025
d5a6c55
standard
Sarkoxed Feb 28, 2025
01e2367
few updates
Sarkoxed Mar 6, 2025
e52d99d
not a bug
Sarkoxed Mar 6, 2025
a1b8d75
Standard form related fixes
Sarkoxed Mar 6, 2025
552214f
Fixed subtraction + new assert_equal
Sarkoxed Mar 6, 2025
03479d4
negative operator fix
Sarkoxed Mar 7, 2025
9112e0f
Non constant predicates
Sarkoxed Mar 7, 2025
81e911a
regression
Sarkoxed Mar 7, 2025
1aa2081
Handling const set inf + ==
Sarkoxed Mar 7, 2025
96c0656
new ==
Sarkoxed Mar 7, 2025
4ed0510
New features
Sarkoxed Mar 7, 2025
b50c80e
Better handling of const case
Sarkoxed Mar 7, 2025
6816467
Mixup bug
Sarkoxed Mar 11, 2025
9e3c662
Added pretty prints and defines to disable mul
Sarkoxed Mar 11, 2025
f260f60
Added keywords for BATCH_MUL and COND_ASSIGN
Sarkoxed Mar 11, 2025
1022444
new handlers for bool
Sarkoxed Mar 12, 2025
c0f16c6
should be here I guess
Sarkoxed Mar 12, 2025
3284a8f
Added few features
Sarkoxed Mar 12, 2025
afbcab1
is_standard()
Sarkoxed Mar 12, 2025
af74a20
Two more tests and one still fails
Sarkoxed Mar 12, 2025
0a3e45d
fuzzer update
Sarkoxed Mar 12, 2025
47053a0
less gates on average
Sarkoxed Mar 12, 2025
55bad89
Coverage track
Sarkoxed Mar 12, 2025
ea4d9ea
newline
Sarkoxed Mar 12, 2025
c8c8be2
Merge branch 'master' into as/cycle-group-patches
Sarkoxed Mar 12, 2025
7653b8d
refactoring due to methods growth
Sarkoxed Mar 12, 2025
380ec4e
Leave it like that for now
Sarkoxed Mar 12, 2025
3348ddb
Resolve the constantness issues
Sarkoxed Mar 12, 2025
2c11ad0
clang-format again
Sarkoxed Mar 12, 2025
bed01b2
fixes for ci 1
Sarkoxed Mar 12, 2025
ccb3f79
fixes for ci 2:
Sarkoxed Mar 12, 2025
4e0ce11
Remember origin tag
Sarkoxed Mar 12, 2025
90bf51d
Addressing bool_t comments
Sarkoxed Mar 13, 2025
507e0ab
Addressing CycleGroup comments
Sarkoxed Mar 13, 2025
10790af
Addressing fuzzer comments
Sarkoxed Mar 13, 2025
815ddbd
Comment on normalizations
Sarkoxed Mar 13, 2025
9450eb5
Merge branch 'master' into as/cycle-group-patches
Sarkoxed Mar 13, 2025
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
10 changes: 10 additions & 0 deletions barretenberg/cpp/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@
"binaryDir": "build-fuzzing",
"cacheVariables": {
"FUZZING": "ON"
},
"environment": {
"CFLAGS": "-fsanitize-coverage=indirect-calls,trace-pc-guard",
"CXXFLAGS": "-fsanitize-coverage=indirect-calls,trace-pc-guard",
"LDFLAGS": "-fsanitize-coverage=indirect-calls,trace-pc-guard"
}
},
{
Expand All @@ -282,6 +287,11 @@
"FUZZING": "ON",
"ENABLE_ASAN": "ON",
"DISABLE_ASM": "ON"
},
"environment": {
"CFLAGS": "-fsanitize-coverage=func",
"CXXFLAGS": "-fsanitize-coverage=func",
"LDFLAGS": "-fsanitize-coverage=func"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ template <typename Curve_> class IPA {
msm_scalars.emplace_back(a_zero);
msm_scalars.emplace_back(generator_challenge * a_zero.madd(b_zero, {-opening_claim.opening_pair.evaluation}));
GroupElement ipa_relation = GroupElement::batch_mul(msm_elements, msm_scalars);
ipa_relation.assert_equal(-opening_claim.commitment);
auto neg_commitment = -opening_claim.commitment;
ipa_relation.assert_equal(neg_commitment);

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1144): Add proper constraints for taking the log of a field_t.
Fr stdlib_log_poly_length(static_cast<uint256_t>(log_poly_length));
Expand Down Expand Up @@ -727,7 +728,8 @@ template <typename Curve_> class IPA {
msm_scalars.emplace_back(a_zero);
msm_scalars.emplace_back(generator_challenge * a_zero.madd(b_zero, {-opening_claim.opening_pair.evaluation}));
GroupElement ipa_relation = GroupElement::batch_mul(msm_elements, msm_scalars);
ipa_relation.assert_equal(-opening_claim.commitment);
auto neg_commitment = -opening_claim.commitment;
ipa_relation.assert_equal(neg_commitment);

return (ipa_relation.get_value() == -opening_claim.commitment.get_value());
}
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/barretenberg/common/fuzzer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ASSERT_EQUAL, ASSERT_NOT_EQUAL, SQR_ADD, ASSERT_EQUAL, ASSERT_NOT_EQUAL, SQR_ADD, SUBTRACT_WITH_CONSTRAINT, \
DIVIDE_WITH_CONSTRAINTS, SLICE, ASSERT_ZERO, ASSERT_NOT_ZERO, COND_NEGATE, ADD_MULTI, ASSERT_VALID, \
COND_SELECT, DOUBLE, RANDOMSEED, SELECT_IF_ZERO, SELECT_IF_EQ, REVERSE, GET_BIT, SET_BIT, SET, INVERT, AND, \
OR, XOR, MODULO, SHL, SHR, ROL, ROR, NOT
OR, XOR, MODULO, SHL, SHR, ROL, ROR, NOT, BATCH_MUL, COND_ASSIGN

struct HavocSettings {
size_t GEN_LLVM_POST_MUTATION_PROB; // Controls frequency of additional mutation after structural ones
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,11 @@ join_split_outputs join_split_circuit_component(join_split_inputs const& inputs)

// When allowing chaining, ensure propagation is to one's self (and not to some other user).
group_ct self = input_note_1.owner;
allow_chain_1.must_imply(output_note_1.owner == self, "inter-user chaining disallowed");
allow_chain_2.must_imply(output_note_2.owner == self, "inter-user chaining disallowed");

group_ct output_note_1_owner = output_note_1.owner;
group_ct output_note_2_owner = output_note_2.owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

standardize method changes the class state, so we can't mark assert_equal and == to const anymore. Hence we can't call them on consts either

Copy link
Contributor

Choose a reason for hiding this comment

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

ok

allow_chain_1.must_imply(output_note_1_owner == self, "inter-user chaining disallowed");
allow_chain_2.must_imply(output_note_2_owner == self, "inter-user chaining disallowed");

// Prevent chaining from a partial claim note.
is_defi_deposit.must_imply(!allow_chain_1, "cannot chain from a partial claim note");
Expand Down Expand Up @@ -190,7 +193,9 @@ join_split_outputs join_split_circuit_component(join_split_inputs const& inputs)
*/

// Verify input notes have the same account public key and account_required.
input_note_1.owner.assert_equal(input_note_2.owner, "input note owners don't match");
group_ct input_note_1_owner = input_note_1.owner;
group_ct input_note_2_owner = input_note_2.owner;
input_note_1_owner.assert_equal(input_note_2_owner, "input note owners don't match");
input_note_1.account_required.assert_equal(input_note_2.account_required,
"input note account_required don't match");

Expand All @@ -199,7 +204,7 @@ join_split_outputs join_split_circuit_component(join_split_inputs const& inputs)
inputs.account_private_key.assert_is_not_zero("account private key is zero");
auto account_public_key = group_ct(grumpkin::g1::affine_one) *
group_ct::cycle_scalar::create_from_bn254_scalar(inputs.account_private_key);
account_public_key.assert_equal(input_note_1.owner, "account_private_key incorrect");
account_public_key.assert_equal(input_note_1_owner, "account_private_key incorrect");
inputs.account_required.assert_equal(input_note_1.account_required, "account_required incorrect");

// Verify output notes creator_pubkey is either account_public_key.x or 0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ template <typename Builder> bool_t<Builder> bool_t<Builder>::operator^(const boo
template <typename Builder> bool_t<Builder> bool_t<Builder>::operator!() const
{
bool_t<Builder> result(*this);
if (result.is_constant()) {
result.witness_bool = !result.witness_bool;
return result;
}
result.witness_inverted = !result.witness_inverted;
return result;
}
Expand Down Expand Up @@ -441,6 +445,18 @@ bool_t<Builder> bool_t<Builder>::conditional_assign(const bool_t<Builder>& predi
const bool_t& lhs,
const bool_t& rhs)
{
if (predicate.is_constant()) {
auto result = bool_t(predicate.get_value() ? lhs : rhs);
result.set_origin_tag(OriginTag(predicate.get_origin_tag(), lhs.get_origin_tag(), rhs.get_origin_tag()));
return result;
}

bool same = lhs.witness_index == rhs.witness_index;
bool witness_same = same && lhs.witness_index != IS_CONSTANT && (lhs.witness_inverted == rhs.witness_inverted);
bool const_same = same && (lhs.witness_index == IS_CONSTANT) && (lhs.witness_bool == rhs.witness_bool);
if (witness_same || const_same) {
return lhs;
}
return (predicate && lhs) || (!predicate && rhs);
}

Expand Down Expand Up @@ -527,7 +543,8 @@ template <typename Builder> bool_t<Builder> bool_t<Builder>::implies_both_ways(c

template <typename Builder> bool_t<Builder> bool_t<Builder>::normalize() const
{
if (is_constant() || !witness_inverted) {
if (is_constant()) {
ASSERT(!this->witness_inverted);
return *this;
}

Expand Down
Loading