-
Notifications
You must be signed in to change notification settings - Fork 7
Validate field elements to ensure 254-bit constraint #909
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
base: main
Are you sure you want to change the base?
Conversation
This introduces a constant for the maximum bit width of field elements (254 bits) and updates the ByteWidth and BitWidth methods to utilize this constant. The Accept method is also modified to ensure values fit within the defined bit width.
This commit introduces a new script, `update_curve.sh`, to automate the replacement of BLS12-377 references with BN254 in all Go files. The script updates both import paths and comments throughout the codebase to reflect the change in elliptic curve used.
|
@DavePearce hey, could you please review the changes, and check if everythings alright ! |
Hi @albertyosef --- sorry I'm not following what you are trying to achieve here? Do you have some reason for wanting the BN254 curve? |
@DavePearce I apologize for the confusion. I misinterpreted the original issue (#282) about field element validation. I incorrectly assumed we needed to switch to BN254 when the actual requirement was just to ensure proper 254-bit constraint validation for field elements. Let me revise the PR to focus on the actual issue:
I'll remove the curve switching changes and submit an updated version that only addresses the field element validation. Thank you for catching this misunderstanding. |
…12-377 This commit removes the `update_curve.sh` script, which was used to automate the replacement of BLS12-377 references with BN254 in Go files. Additionally, it updates all relevant import paths and references throughout the codebase to reflect the use of BLS12-377 instead of BN254.
Hi @DavePearce, apologies for the earlier confusion regarding the BN254 curve. I've revised the PR to focus solely on the field element validation as per issue #282. The changes now correctly implement the 254-bit constraint, include the fieldElementBitwidth constant, and have corresponding test cases. Thanks for your understanding! Please do guide me if there is any changes required. |
Description:
This PR addresses field element validation to ensure proper bit-width constraints are enforced. Previously, we accepted field elements that fit within 256 bits without properly validating against the BN254 curve's 254-bit constraint.
Key Changes:
fieldElementBitWidth
constant (254 bits) for explicit validationTechnical Details:
bls12-377/fr
tobn254/fr
for correct field arithmetic(fieldElementBitWidth+7)/8
for clarityTesting:
Fixes #282