lambdaworks icon indicating copy to clipboard operation
lambdaworks copied to clipboard

Add Babybear field to pre defined fields

Open MauroToscano opened this issue 2 years ago • 3 comments
trafficstars

This task consists of three tasks:

  • [x] Add Babybear field to pre defined fields on : math/src/field/fields/fft_friendly, using the right modulus.
  • [x] Implement IsPrimeField for BabyBear
  • [x] Make it FFT friendly
  • [ ] Add the degree six and eight extension

For reference, this is the 31 bit used by Risc Zero, as described here:

This field is suitable to be used with the MontgomeryBackend. It can be done with a small MontgomeryBackend of 32 bits later. But if it's not available when doing this issue, it can be done using the one with u64 limbs.

Constant for the modulus is:

2^31 - 2^27 + 1

For first time contributors, we recommend doing task 1, then 2, then 3, and skip task 4.

It may be useful to finish this issue before three, but it's not mandatory.

MauroToscano avatar Sep 04 '23 13:09 MauroToscano

Do you want the babybear field to be in a similar vein as https://github.com/lambdaclass/lambdaworks/blob/main/math/src/field/fields/p448_goldilocks_prime_field.rs?

mdvillagra avatar Sep 05 '23 00:09 mdvillagra

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 IsFieldpart seems right.

@MauroToscano which tests? which code are you referring to?

mdvillagra avatar Sep 17 '23 02:09 mdvillagra

@MauroToscano is it really necessary to implement the isPrime trait? It is already implemented for MontgomeryBackendPrimeField here and babybear already uses MontgomeryBackendPrimeField here.

mdvillagra avatar Sep 25 '23 23:09 mdvillagra