Conversation
Update MODULUS_128 to MODULUS_U128
Use shave bits in sample func
|
We probably will find a way to bypass the nightly compilation failures in another PR... so ignore that for now |
|
oh there is already a PR in the work for that: #1059 (comment) |
This reverts commit c9cd675.
|
After meeting with @Pratyush and @z-tech, we agreed it would be meaningful to merge the #[derive(MontConfig)]
#[modulus = "2147483647"]
#[generator = "7"]
pub struct SmallFp32ConfigM31;
pub type SmallFp32M31 = SmallFp<SmallFp32ConfigM31>;However, the user still needs to explicitly state what type they want to use. To make it "automatic", we might create a new Instead, we propose a simple macro |
|
Hi, @Pratyush @weikengchen many people I speak with are excited to start using this and I have a growing chain of unmerged code from projects that are blocked by this PR. Spongefish needs to specifically support small fields which requires changes in Crypto Primitives and Efficient Sumcheck needs to bump Spongefish and both of these are essential for downstream implementations like Warp. There is a healthy number of follow up projects pending that involve all five of these repos. Can we please set a deadline for merging? |
|
I am 12 files away :) (I was only 6 files away four months ago but there are new changes) |
| let mut e = generator; | ||
| for _i in 0..adicity { | ||
| e = e.modpow(&base.into(), &modulus) | ||
| } |
There was a problem hiding this comment.
I think you forget to check something here?
| 1u128 << k_bits | ||
| }; | ||
| let r_mod_n = if k_bits == 128 { | ||
| (((1u128 << 127) % modulus) + ((1u128 << 127) % modulus)) % modulus |
There was a problem hiding this comment.
how sure are we that would work for prime that is larger than 1 << 127?
In those cases, it still has (1 << 127) + (1 << 127) = 1 << 128 causing an overflow?
| fn mod_inverse_pow2(n: u128, k_bits: u32) -> u128 { | ||
| let mut inv = 1u128; | ||
| for _ in 0..k_bits { | ||
| inv = inv.wrapping_mul(2u128.wrapping_sub(n.wrapping_mul(inv))); |
There was a problem hiding this comment.
If it is convenient, can you point me to why it was implemented this way? (It is not obvious)
weikengchen
left a comment
There was a problem hiding this comment.
Check the final feedback and we can get this wrapped up
Description
The primary motivation of this PR is to create a generalized path toward vectorized/ SIMD instruction optimizations for finite fields in Arkworks.
In the process, we pick up a non-trivial performance boost in serial.
SmallFp, a procedural macro for instantiating prime fields with modulus< 2^127u8,u16,u32,u64,u128)SLIDES: https://andrewzitek.xyz/images/small_fp_slides.pdf
Closes: #1038
This work was done in collaboration with @z-tech