-
Notifications
You must be signed in to change notification settings - Fork 136
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
Add Babybear field #549
Add Babybear field #549
Conversation
Codecov Report
@@ Coverage Diff @@
## main #549 +/- ##
==========================================
- Coverage 95.83% 95.79% -0.04%
==========================================
Files 78 79 +1
Lines 12311 12370 +59
==========================================
+ Hits 11798 11850 +52
- Misses 513 520 +7
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
Babybear Field should be using the MontgomeryBackendPrimeField
. The code should set the right constants using that backend. See Stark252PrimeField
as an example
What about the field operations? Do I still leave them there? Or just implement the modulus? The file |
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.
Nice! Thanks for the PR!
I left a minor request to move and rename stuff.
unsigned_integer::element::UnsignedInteger, | ||
}; | ||
|
||
pub type U64 = UnsignedInteger<1>; |
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.
Please move this to unsigned_integer/element.rs
(here). So all unsigned integer type aliases are together.
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.
This a nice idea
}; | ||
|
||
pub type U64 = UnsignedInteger<1>; | ||
pub type U64PrimeField<T> = MontgomeryBackendPrimeField<T, 1>; |
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.
There's already a U64PrimeField
(here).
@MauroToscano @Oppen I guess there's no need to have both u64primefields if the one with the Montgomery backend is more performant. Maybe we should create an issue to benchmark them and remove the slow one.
For the time being I would change the name of this type alias to U64MontgomeryBackendPrimeField
or something along those lines. To avoid confusion.
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.
We should review this. But let's do it ourselves, and discuss it outside this PR.
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.
The change of name would be nice though
guys, I don't know why another PR was created about this issue. I just did a push and that's it. |
no worries. Looks like they point to different branches in your fork. |
Mdvillagra/issue539
I did some clean up on my fork, and now it seems to be fine. I didn't noticed but I was working on another branch. Now I pushed into my main branch. |
Cool. Looks like the lint check is failing. That's prolly solved by running |
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.
Awesome. Thanks!
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.
Since there's code for the FFT/NTT, there should be a test to check if it's working properly. It can be submitted as a package of IsFFt
with tests in another PR, or fixed here. The IsField
part seems right.
Either add the tests, or remove the FFT part
I will delete the FFT part right now and add it in another PR. |
.vscode/settings.json
Outdated
{ | ||
"githubPullRequests.ignoredPullRequestBranches": [ | ||
"main" | ||
] | ||
} |
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.
Do we really want to merge this?
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.
should probably add it to the .gitignore
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.
probably is better to just delete it right?
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.
I deleted the file
impl PartialOrd for FieldElement<Babybear31PrimeField> { | ||
fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> { | ||
self.representative().partial_cmp(&other.representative()) | ||
} | ||
} | ||
|
||
impl Ord for FieldElement<Babybear31PrimeField> { | ||
fn cmp(&self, other: &Self) -> core::cmp::Ordering { | ||
self.representative().cmp(&other.representative()) | ||
} | ||
} |
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.
This isn't needed, but it's ok, we can document this later and remove if needed. Doesn't hurt either
Babybear field implementation
Description
Add Babybear field with arithmetic operations as requested on issue #539. The field uses
MontgomeryBackendPrimeField
and implements the same traits as inStark252PrimeField
. The field elements are encoded using typeu64
considering that Babybear only requires 31 bits.Type of change
Checklist