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

Eliminate hard-coded BN_N_LIMBS and BN_LIMB_WIDTH dependency. #327

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

mpenciak
Copy link
Contributor

@mpenciak mpenciak commented Feb 15, 2024

In an attempt to see what would happen to the number of constraints if we changed the parameters BN_N_LIMBS and BN_LIMB_WIDTH, I found a couple places where the arithmetic inadvertently was dependent on the values being hardcoded as 4 and 64 respectively.

I believe this PR makes the necessary changes to make the codebase general enough to allow for varying these parameters. The expect tests expectedly (:drum: haha) fail when changing these two constants, but everything else passes.

Comment on lines 444 to 446
let carry_bits = (((max_word.to_f64().unwrap() * 2.0).log2() - self.params.limb_width as f64)
.ceil()
+ 0.1) as usize;
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like it could lead to unexpected results in some situations due to a potential loss of precision with floats.

@adr1anh
Copy link
Contributor

adr1anh commented Feb 16, 2024

The change looks good to me, though I haven't looked into this gadget enough to understand if this is enough to support arbitrary configurations. Ideally, we should replace this with bellpepper-gadgets/emulated.

@huitseeker
Copy link
Contributor

@adr1anh @mpenciak
Hi folks, could we get a decision on this PR with the code base we have today? Surely it seems a 6-line change is a thing we can make a decision (positive or negative) today, even if the ultimate goal of moving to bellpepper-emulated seems optimal tomorrow?

@adr1anh
Copy link
Contributor

adr1anh commented Feb 26, 2024

The change does seem reasonable to me, and can be backported to Nova too, even if we move to bellpepper-emulated later.

@mpenciak mpenciak added this pull request to the merge queue Feb 26, 2024
Merged via the queue into dev with commit 9c4b1ec Feb 26, 2024
9 checks passed
@mpenciak mpenciak deleted the constants_change branch February 26, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants