This repository has been archived by the owner on Nov 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
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
- We need num type in order to use ` num::Integer::is_even()` function for the implementation of `is_even()` function for `FieldElement`
- Added use of `num::Integer` trait to use implement `is_even()` function. - Derive `PartialOrd` for `FieldElement` struct. - Implement `is_even()` for `FieldElement`. - Implement first part of `inverse` for `FieldElement` to be concise, `PhaseI` described on the paper: https://ieeexplore.ieee.org/document/863048
- Phase II takes care about acomplishing the last step to complete the `AlmMontInv()` function specified on the paper: IEEE TRANSACTIONS ON COMPUTERS, VOL. 49, NO. 7, JULY 2000 763 The Montgomery Modular Inverse - Revisited E. Sava¸s, C¸. K. Ko¸c - This returns `(a^-1) * 2^n (mod p)`
- Implementation of McIvor, Corinne & Mcloone, Maire & Mccanny, J.V.. (2004). Improved Montgomery modular inverse algorithm. Electronics Letters. 40. 1110 - 1112. 10.1049/el:20045610. - Stopped until `two_pow_k()` func is implemented.
-Perform the operation `2^k` returning the result as a `FieldElement`. Note: Input `k` has to relay over the range: 0..253 otherways, it will fail.
- Corrected the implementation for the `two_pow_k()` function substracting `52^i` consistently on each slot. - Implemented tests for all of the edge- cases of the function and all are passing. - The implementation done, might be enough performant, anyways, we can explore different implementations once #9 is solved.
- Finnished implementation according to the algorithm that appears on: The Montgomery Modular Inverse - Revisited E. Sava¸s, C¸. K. Ko¸: https://ieeexplore.ieee.org/document/863048 - Need for tests and a probable refactor of some wrong parts of the code.
- Implemented PartialOrd as the derivation was not doing the expected. - Implemented Ord for `FieldElement` since the derivation behaviour wasn't the expected. - Implement tests for `PartialOrd` & `Ord` implementations. - Fix some Phase I nitpicks.
- We need to perform 2-3 MontgomeryProds in order to perform the inverseMod operation.
- Implemented division by two for odd and even `FieldElements` with carrying. - Implemented tests for `half()` which pass successfully. - Implement `to_montgomery()` conversion function. - Implement `montgomery_mul()` for `FieldElement`. - Refactor last part of the algorithm with Montgomery mul function.
- Implemented `from_montgomery()` function in oder to be able to convert back numbers that live on the Montgomery domain. - Tying now the `inverse()` Phase I with `p = FieldElement::minus_one()` as is the biggest value we can give (since p = 0 (mod l)).
- Value of `p` has been proven to be working by writting `p` (which equals `FIELD_L` not as `FieldElement::zero()` but on it's normal conversion.
This solves some of the issues of #10 . - Added `INV_RR = (2^253)^2 (mod l)` on the u64 backend on `constants.rs`. - Implemented `montgomery_mul()` & to/from Montgomery conversions. Still needs to be reviewed and tested to see if the reduction with the new modulo is working as expected. - Added more comment-docs on `constants.rs` file.
- `ConditionallyNeg` and `ConditionallySelectable` aren't used at the moment so can ve removed. - Also removed `Eq` trait import.
- Increased the max range to `260` since on functions like `inverse()` we need to exponenciate to the Montgomery modulus, so `2^260`.
- Tests are failing atm. We should review the montgomery conversions and try to review it by parts.
- The tools mentioned on #11 have been implemented altogether with `montgomery_mul()`. - Implemented tests for both functions which are passing correctly.
- Fixed the loop on Phase II where the number of iterations should start from 0 instead of 1. - Two definitely hasn't to be on the montgomery domain. Last part of the algorithm has to be reviewed. **Phase I && Phase II have been tested and are working as expected to. They are correctly implemented and giving the results needed.** This is a big advance in order to close #9
**Refecences:** B. S. Kaliski Jr. - The Montgomery inverse and its applica-tions. IEEE Transactions on Computers, 44(8):1064–1065, August-1995 After this commit, #9 can be closed. -Implemented Kalinski Modular Inverse algorithm. - Implemented tests for the algorithm which are passing successfully. - Improved the docs of the inverse function. At this point, Implement the Savas & Koç modification of this algorithm to increase the performance of the operation will be great. So maybe we can implement the algorithm and then benchmark coth solutions to see which performs better with our `FieldElement` definition. Tools for the second algorithm implementation were builded on 54152f2 and allowed us to close #11
CPerezz
added
enhancement
New feature or request
review needed
This PR, MR or Issue status needs to be reviewed.
labels
May 28, 2019
This was referenced May 31, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
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.
Implemented all of the necessary functions and tools to implement the
Kalinski Modular Inverse Algorithm
forFieldElement
.This consists on the following implementations:
PartialOrd
trait definition forFieldElement
.PartialEq
trait definition forFieldElement
.two_pow_k()
function implementation forFieldElement
to enable perform:2^k for 0<= k <=260
. Implemented on Implement2^k
for FieldElement #10half()
function implementation forFieldElement
to perform division by2
forFieldElement
just using bit shifting operators. Implemented on bad3691To/From
Montgomery domain conversions forFieldElement
on Implement Montgomery arithmetics for Savas & Koç inversion algorithm. #11Kalinski's Modular Montgomery Inverse algorithm
on Implement Montgomery modular inverse algorithm #9Everything is tested, commented and documented.
Now we can continue with Point Addition algorithms that need the
inverse
operator to be performed. All ready to proceed with #8