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(boojum)!: Deleted the repetition in normalization #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Fitznik
Copy link

@Fitznik Fitznik commented Nov 18, 2024

When we perform normalization, which is the multiplication of a number by 1, then in the same multiplication we prove that the result is greater than the module and then in normalization we repeat this process, which duplicates the constraints

@Fitznik Fitznik requested review from popzxc and shamatar November 18, 2024 01:34
@popzxc popzxc changed the title Deleted the repetition in normalization fix(boojum): Deleted the repetition in normalization Nov 18, 2024
Comment on lines -144 to -148
// sub modulus
let modulus = self
.params
.modulus
.map(|el| cs.allocate_constant(F::from_u64_unchecked(el as u64)));
Copy link
Member

Choose a reason for hiding this comment

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

I'm not an expert, but since this (seemingly) changes the layout of the circuit, is it a breaking change (e.g. it requires to generate new keys)?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, a new key needs to be generated. However, this is mostly a performance improvement and unrelated to security, so it is not urgent to fix.

Copy link
Member

Choose a reason for hiding this comment

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

I've marked it as a breaking change though: note the ! in the fix! (it instructs the release bot that the change is breaking), and applied Protocol upgrade label (for general awareness -- so that this PR is not merged accidentally).
Please do so in the future PRs if you know that it requires new VKs.

Also cc @mm-zk --- IIRC you maintain a table of tasks/PRs that should be included for each upgrade -- please add this PR there.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for flagging this!

@shamatar
Copy link
Member

Not sure that multiplication guarantees full normalization. It can still give the same number of bits, but not < modulus canonical representation

@Fitznik
Copy link
Author

Fitznik commented Nov 19, 2024

In our implementation, the enforce_reduced function (at the end of multiplication) ensures that the final result is strictly within [0,P) by explicitly performing modular reduction and constraining the canonical form.

The reason for this commit is that the stuffing of normalize and enforce_reduce is identical.

@popzxc popzxc changed the title fix(boojum): Deleted the repetition in normalization fix!(boojum): Deleted the repetition in normalization Nov 19, 2024
@popzxc popzxc changed the title fix!(boojum): Deleted the repetition in normalization fix(boojum)!: Deleted the repetition in normalization Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants