Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed a failing test and added a small fuzzer #1384

Merged
merged 3 commits into from
Aug 3, 2023

Conversation

Rumata888
Copy link
Contributor

@Rumata888 Rumata888 commented Aug 2, 2023

Goblin translator tests were failing due to an incorrect assert (with certain probability). Added a small fuzzer that helped find the bug.

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 this pull request to relevant issues (if any exist).

@Rumata888 Rumata888 self-assigned this Aug 2, 2023
@Rumata888 Rumata888 added the crypto cryptography label Aug 2, 2023
Copy link
Collaborator

@ludamad ludamad left a comment

Choose a reason for hiding this comment

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

Fuzzer stuff looks really cool, there's a bit of crypto I don't readily understand but I'll leave it to you if you feel it needs a look-over

@@ -184,6 +185,102 @@ concept InstructionWeightsEnabled = requires {
typename T::InstructionWeights;
T::InstructionWeights::_LIMIT;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a function I've added for the future. I hope to create a variadic template for buffer mutations of elements so that anyone can build a fuzzer in 5 minutes with cool mutations

@Rumata888
Copy link
Contributor Author

Fuzzer stuff looks really cool, there's a bit of crypto I don't readily understand but I'll leave it to you if you feel it needs a look-over

Thanks for reviewing. I'll ask @ledwards2225 to review the crypto part

@@ -0,0 +1,275 @@
/**
* @file goblin_translator_circuit_builder.cpp
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I simply moved this code from .test.cpp and commented out all info and variables used just for info (messed with fuzzing)

ASSERT(uint256_t(limbs[NUM_BINARY_LIMBS - 1]) < (uint256_t(1) << NUM_LAST_LIMB_BITS));
} else {

ASSERT(uint256_t(limbs[NUM_BINARY_LIMBS - 1]) < (SHIFT_1));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fix

using Fr = ::curve::BN254::ScalarField;
using Fq = ::curve::BN254::BaseField;

extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created a mini-fuzzer which explored possible values and quickly found the assert issue.

@Rumata888 Rumata888 requested a review from ledwards2225 August 2, 2023 17:47
Copy link
Contributor

@ledwards2225 ledwards2225 left a comment

Choose a reason for hiding this comment

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

Fix LGTM

@Rumata888 Rumata888 marked this pull request as ready for review August 3, 2023 11:45
@Rumata888 Rumata888 merged commit f258e08 into master Aug 3, 2023
@Rumata888 Rumata888 deleted the is/mini_goblin_translator_fuzzer branch August 3, 2023 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crypto cryptography
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants