Conversation
This file contains hidden or 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
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.
To optimise arithmetic on BN254 reduction is not performed after each arithmetic operations but delayed until the intermediate result doesn't fit in 256 bits.
PR adds
MulShift—const-evaluable struct that derives Warren magic(m, s)forunder-approximating
⌊val / P⌋at compile time.div_p_6b— approximation using the upper 6 bits of the high limb; achievesa quotient in [0, 4] with no multiplier, targeting ARM64/x86 add/lea instruction.
div_p_32b— approximation using the upper 32 bits; tighter quotient in[0, 5], targeting 32×32→64 multiplier hardware.
subtraction_reduce— generic wrapper that applies anydiv_pvariant andsubtracts
q * PviaU64_P_MULTIPLES.gen_multiples.py— generates the*_P_MULTIPLEStable constants.sub_reduce.py— analysis script comparing reduction strategies based on limb size.