Skip to content
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

Constify all math functions #38

Merged
merged 7 commits into from
Sep 19, 2024
Merged

Conversation

levitte
Copy link
Collaborator

@levitte levitte commented Sep 17, 2024

This is supposed to bring this library to the same standards as other MPI libraries, and most of all, to be able to avoid all the deconstifying casts that currently happen in libtomcrypt when linking with tomsfastmath specifically.

@levitte
Copy link
Collaborator Author

levitte commented Sep 17, 2024

Note that for this to be useful yet backward compatible, #36 needs to be merged as well.

I'm currently testing this with a cleaner libtomcrypt. It will remain a draft until I'm satisfied that I got it all.

@levitte
Copy link
Collaborator Author

levitte commented Sep 17, 2024

Also, this warrants updating the version to at least 0.14.0

@levitte
Copy link
Collaborator Author

levitte commented Sep 17, 2024

It irritates me that fp_exptmod can't be entirely constified as it should... I'll have think about that, 'cause that just shouldn't be.

@levitte levitte marked this pull request as ready for review September 17, 2024 11:07
@levitte
Copy link
Collaborator Author

levitte commented Sep 17, 2024

It irritates me that fp_exptmod can't be entirely constified as it should... I'll have think about that, 'cause that just shouldn't be.

Fixed it, it was much easier than anticipated

@levitte
Copy link
Collaborator Author

levitte commented Sep 17, 2024

@sjaeckel, would you mind enabling workflows for me?

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

Oh, generators! I hadn't noticed those.... Thanks

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

I don't quite like the long line output of the generators, gotta admit. But, that's work for another PR

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

Is this deemed complete by now?

Copy link
Member

@sjaeckel sjaeckel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite like the long line output of the generators, gotta admit. But, that's work for another PR

What? You don't like >50k char wide lines?

TBH I don't care since they're auto-generated and I'd leave it like that.

Thanks a lot for this PR!

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

What? You don't like >50k char wide lines?

🤣

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

I saw you fixed all the end-of-line spaces. Cool!

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

In my opinion, this can be merged as it currently stands

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

I would propose a version bump to 0.13.99 or something like that (implying that "next" is 0.14.0)

@sjaeckel
Copy link
Member

Oh, I just realized ... we're not done here ... :(

tfm.tex is missing an update!

@levitte
Copy link
Collaborator Author

levitte commented Sep 18, 2024

Oh! Ok, I can fix that tomorrow (it being middle of the night here, it's sleep time)

@levitte
Copy link
Collaborator Author

levitte commented Sep 19, 2024

Documentation updated

levitte and others added 7 commits September 19, 2024 14:57
This covers:

- fp_count_bits()
- fp_unsigned_bin_size()
- fp_to_unsigned_bin()
- fp_signed_bin_size()
- fp_to_signed_bin()
- fp_radix_size()
- fp_toradix()
- fp_toradix_n()

Interestingly, a few of the radix conversion functions were already
appropriately consitified.
This covers:

- fp_cmp()
- fp_cmp_mag()
- fp_cmp_d()
- fp_add()
- fp_add_d()
- fp_sub()
- fp_sub_d()
This covers:

- fp_div_2d()
- fp_mod_2d()
- fp_mul_2d()
- fp_mul_2()
- fp_div_2()
- fp_cnt_lsb()

Technically, these are bit shifting and bit counting functions.

Side note: it's a bit curious that they're all implemented in src/bit,
except for fp_mul_2d() and fp_mul_2().
This covers:

- fp_mul()
- fp_div()
- fp_mod()
- fp_mul_d()
- fp_div_d()
- fp_mod_d()
- fp_sqr()
This covers:

- fp_addmod()
- fp_submod()
- fp_mulmod()
- fp_sqrmod()
- fp_invmod()
- fp_gcd()
- fp_lcm()
- fp_montgomery_setup()
- fp_montgomery_calc_normalization()
- fp_montgomery_reduce()
- fp_exptmod()
- fp_prime_miller_rabin()
- fp_isprime()
- fp_isprime_ex()

This also changes fp_exptmod(), as it changed X temporarily.  This turns out
to be completely unnecessary.
Signed-off-by: Steffen Jaeckel <[email protected]>
@levitte
Copy link
Collaborator Author

levitte commented Sep 19, 2024

Anything else I've missed?

@sjaeckel sjaeckel merged commit ab5814d into libtom:develop Sep 19, 2024
63 checks passed
@sjaeckel
Copy link
Member

Anything else I've missed?

Nope, I've only rebased.

@sjaeckel sjaeckel mentioned this pull request Sep 19, 2024
@levitte levitte deleted the constify-math branch September 19, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants