-
Notifications
You must be signed in to change notification settings - Fork 12
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
Activate custom gates in JS and add rangeCheck64 gadget #179
Conversation
@@ -20,6 +20,41 @@ use std::path::Path; | |||
use std::sync::Arc; | |||
use wasm_bindgen::prelude::*; | |||
|
|||
pub struct SimpleFeatureFlags { | |||
pub range_check0: bool, | |||
pub range_check1: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a clarifying question for me: what does range_check1
correspond to? range_check0
is the 64
bit range check; what is the other one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's how I understand it (@jspada would know the full details):
range_check0
actually has space for up to 88 bits (for the 64-bit check we set the upper two 12-bit limbs to constant zero). However, when used in the 88-bit mode it doesn't fully constrain all limbs by itself and needs to "collaborate" with subsequent gates.
The main objective for both range check gates was to enable a 3x88-bit check (used in foreign field arithmetic, supports bigint sizes up to 264 = 3 * 88 bits). The range_check1
gate is what is needed together with two range_check0
gates and one Zero
gate to collaboratively do this 3*88 bit check.
Note that that's 264 bits of range check in 4 gates, which is 264 / 4 = 66 bits per gate on average. So the collaborative approach gives you a 2 bit edge over the single gate version here 😅 Just doing 4 64-bit range checks separately would have only given us 256 bit checks which would've been to small for important use cases in foreign field multiplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
companion of o1-labs/o1js#1176, see PR description there