-
Notifications
You must be signed in to change notification settings - Fork 92
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
Make static context a feature and allow dynamic context generation #41
Conversation
Can you ELI5 what "static|dynamic context" means in this context? |
@dvdplm It's the pre-computed table used to accelerate various calculations. Previously we only allow storing the table as static variables directly in the library. This PR allows disabling those variables (to reduce binary size, if needed) and generate the tables dynamically. |
core/src/ecmult.rs
Outdated
/// Create a new `ECMultContext`. | ||
pub const fn new(pre_g: [AffineStorage; ECMULT_TABLE_SIZE_G]) -> Self { | ||
/// Create a new `ECMultContext` from raw values. | ||
pub const unsafe fn new_raw(pre_g: [AffineStorage; ECMULT_TABLE_SIZE_G]) -> Self { |
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.
what makes it unsafe? is it due to potential misuse in crypto logic and not in rust terms?
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.
If the table is not filled in the correct data of pre_g
, then usage of it would be invalid. So yeah it's in crypto logic, but also not sure if it will lead to anything panicking.
Does not apply.
Co-Authored-By: Andronik Ordian <[email protected]>
Co-Authored-By: David <[email protected]>
Co-Authored-By: David <[email protected]>
How much bigger is the static vs dynamic build? How much does the table generation cost under normal use? I think it'd be good to get some of this info into the README to help users decide. :) |
It is reported to be quite significant -- around 1mb or so. I knew some users were discouraged previously from using |
Added #46 |
…aritytech#41) * Make static context a feature and allow dynamic context generation * new_box -> new_boxed * Remove "inputs and outputs must not overlap" comment Does not apply. * Update core/src/ecmult.rs Co-Authored-By: Andronik Ordian <[email protected]> * Add comment about unsafe block in new_boxed * Tidy up comments * More documents about unsafety * Remove deconstruct_raw * Add missing docs * Use vec macro * in -> on * Update src/lib.rs Co-Authored-By: David <[email protected]> * Update src/lib.rs Co-Authored-By: David <[email protected]> Co-authored-by: Andronik Ordian <[email protected]> Co-authored-by: David <[email protected]>
This changes the static contexts to be a feature that can be enabled or disabled, and allow contexts to be dynamically generated. By disabling static contexts, users accomplish much smaller binary size, but the trade-off is then that contexts must be generated dynamically (which is not a cheap operation).