-
Notifications
You must be signed in to change notification settings - Fork 19
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
Barret reduction for modexp #170
Draft
fkrause98
wants to merge
59
commits into
main
Choose a base branch
from
barret-reduction-for-modexp
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Add `bigUIntShl` implementation * Add constants * Fix compilation
* Add `bigUIntShr` implementation * Add constants
* Implement bigUIntBitOr * Fix bigUIntBitOr * Fix bigUIntBitOr Co-authored-by: Ivan Litteri <[email protected]> * Fix missing closing brackets --------- Co-authored-by: Ivan Litteri <[email protected]>
* Implement bigUIntCondSelect * Fix missing curly braces Co-authored-by: Ivan Litteri <[email protected]> * Implement Big UInt Right Shift (#137) * Add `bigUIntShr` implementation * Add constants * Implement Big UInt Bitwise Or for modexp (#135) * Implement bigUIntBitOr * Fix bigUIntBitOr * Fix bigUIntBitOr Co-authored-by: Ivan Litteri <[email protected]> * Fix missing closing brackets --------- Co-authored-by: Ivan Litteri <[email protected]> --------- Co-authored-by: Ivan Litteri <[email protected]>
* First implementation of mul operation for bigints * Fix multiplication for big integers * Fix some merge issues * Improve comments and function docs * Delete whitespaces
* First substraction draft * Fix compile problems * Working implementation * Updated code * Updated code * Update subtract implementation * Remove console_log * Add docs for function * Update function docs * Remove tests from from ModExp.yul * Fix typo * Restore horrible whitespaces to avoid an ugly merge conflict * Update precompiles/Modexp.yul Co-authored-by: Ivan Litteri <[email protected]> * Revert "Update precompiles/Modexp.yul" This reverts commit 582bc41. --------- Co-authored-by: Joaquín P. Centeno <[email protected]> Co-authored-by: Ivan Litteri <[email protected]>
* Make Big UInt API functions naming consistent * Refactor `bigUIntAdd` variable names * Refactor `bigUIntMul` variable names * Refactor `subLimbsWithBorrow` * Refactor `bigUintSubtractionWithBorrow` * Refactor `bigUIntAdd` * Fix `bigUIntSubWithBorrow` * Format `storeLimbValueAtOffset` * Refactor `bigUIntBitOr` Made it consistent with the rest of the code convention and naming * Refactor `bigUIntCondSelect` Made it consistent with the rest of the code convention and naming * Reorder `overflowingSubWithBorrow` * Move comment to modexp API Docs section
* Division draft * Non working draft * Fix compile errors * Use proper pointers for quotient and remainder * Add fix note, some more changes * Add comment * Implement `big_uint_bit_size` * Increase pointer to prevent it from steping over console_log * WIP divrem * Fix loop and zero initializer * Push test cases * Add other test case * Add docs and tests for `big_uint_inplace_or_1` * Fix bug related to bit shifting * Fix borrow return in big uint sub function * Delete playground file used for debugging * Fix sub with borrow function * Add playground again to check more big integer division tests * Remove playground used for testing * Write documentation for new shift functions * Improve naming and documentation for new helper functions * Rename bigUIntOrWith1 to bigUintInPlaceOrWith1 * Add tmp buffer parameters to bigUIntDivRem. Improve docs. * Simplify subLimbsWithBorrow Co-authored-by: Ivan Litteri <[email protected]> * Remove `mul` call from `bigUIntInPlaceOrWith1` Co-authored-by: Ivan Litteri <[email protected]> * Remove multiplications from copyBigUint Co-authored-by: Ivan Litteri <[email protected]> * Optimize bigUIntBitSize loop Co-authored-by: Ivan Litteri <[email protected]> * Simplify zeroWithLimbSizeAt --------- Co-authored-by: Francisco Krause Arnim <[email protected]> Co-authored-by: IAvecilla <[email protected]> Co-authored-by: Ivan Litteri <[email protected]>
* Division draft * Non working draft * Fix compile errors * Use proper pointers for quotient and remainder * Add fix note, some more changes * Add comment * Implement `big_uint_bit_size` * Increase pointer to prevent it from steping over console_log * WIP divrem * Fix loop and zero initializer * Push test cases * Add other test case * Add docs and tests for `big_uint_inplace_or_1` * Fix bug related to bit shifting * Fix borrow return in big uint sub function * Delete playground file used for debugging * Fix sub with borrow function * Add playground again to check more big integer division tests * Remove playground used for testing * Write documentation for new shift functions * Improve naming and documentation for new helper functions * Rename bigUIntOrWith1 to bigUintInPlaceOrWith1 * Add tmp buffer parameters to bigUIntDivRem. Improve docs. * Add big uint mul mod skeleton * Remove wrong comment * Update algorithm comment * Add limb size doubling and divide by two for mul mod operation * Functions to duplicate and halve limb size work in place * Use camelCase * Remove console_log * Add docs * Update doc --------- Co-authored-by: Francisco Krause Arnim <[email protected]> Co-authored-by: Joaquín P. Centeno <[email protected]>
…into modexp_reimplementation
* Add free memory pointer function * Update precompiles/Modexp.yul Co-authored-by: Ivan Litteri <[email protected]> * Update precompiles/Modexp.yul Co-authored-by: Ivan Litteri <[email protected]> --------- Co-authored-by: Ivan Litteri <[email protected]>
* WIP: modexp skeleton * Use of mul mod function for big integers * imlement aux function to check if big uint is larger than 1 * minor fix * Restore modexp from target branch * Fix mul mod * Finish modexp implementation * Remove playground used for debugging * Update modexp with final state of modular exponentiation function * Fix merge issue * Change all names to camel case * fix typo Co-authored-by: Francisco Krause Arnim <[email protected]> --------- Co-authored-by: IAvecilla <[email protected]> Co-authored-by: Ivan Litteri <[email protected]> Co-authored-by: Francisco Krause Arnim <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pending tasks:
barret_reduction
implementation.1. Make sure this reduction is done AFTER the first loop so the base is inside the [0, n**2) range.
2. Make sure the reduction is not used if the modulo is a power of 2, which can done "easily" through
ands.
Useful references: