-
Notifications
You must be signed in to change notification settings - Fork 273
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
integer-openssl proposal #183
Conversation
so this would be as a better "bsd" default than current integer simple?
theres a LOT of surface area for a good implementation, and among open source implementations, openssl may not be the best, though its omni presence is a boon. for those watching from home
point being: would be great to see some benchmarking data for mult/ sqrt, etc on rationals, naturals, integers, for showing how these all compare on the differently naive / sophisticated algorithms therein. :) |
https://gmplib.org/repo/gmp/file/tip/mpn/x86_64/gmp-mparam.h is the current example thresholds of gmp. i think karatsuba corresponds to toom22 i guess i'm just concerned that the openssl tuning parameters are based on performance data older than some contributors to ghc and llvm :) |
@cartazio Seems you have a far better understanding on the maths involved - thanks for the overview. As far as linking is concerned, the current PoC is linked dynamically against the Some benchmarks of multiplication and divison of small and big (4k bit) integers against the currently builtin (for most users thats integer-gmp) can be run with the PoC. Thr Readme page also shows (older) benchmarks agaonst integer-openssl. I will update them with some graphs soon. There is also a some prior work on estimating performance of different open source integer libraries in the ghc wiki |
Sounds like a good work to me. But to an external observer it's very mysterious that you propose to call it Anyway, some less confusing name might be worth considering. Or not. Just raising it because it took me some time to realise that this proposal was not related to crypto |
It’s also worth noting that at least at icfp etc, there was some discussion
with Ben in investing effort
As for performance : this comparison Information and analysis needs to be
part of this proposal. Because that’s it’s only value prop vs integer
simple. If you need help doing that , great. But the open ssl big number c
code hasn’t had tuning in 20 years. So you really need to do a systematic
perf comparison.
…On Mon, Nov 19, 2018 at 5:47 AM simonpj ***@***.***> wrote:
Sounds like a good work to me.
But to an external observer it's very mysterious that you propose to call
it integer-openssl. That makes it sounds as if this library is something
to do with crypto etc. But I assume it's not. I'm guessing it's because the
impl uses code from openssl?
Anyway, some less confusing name might be worth considering. Or not. Just
raising it because it took me some time to realise that this proposal was
not related to crypto
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwlYo1-k18lcylWPLDCkaUZCQPqXPks5uwoxLgaJpZM4Yn7kR>
.
|
* at icfp Ben and I spoke about actually doing a systematic investigation
of current bsd friendly big number libs to see if any could replace gmp for
ghc as the default and keep performance parity or better on small and
asymptotic perf both.
On Mon, Nov 19, 2018 at 7:31 AM Carter Schonwald <[email protected]>
wrote:
… It’s also worth noting that at least at icfp etc, there was some
discussion with Ben in investing effort
As for performance : this comparison Information and analysis needs to be
part of this proposal. Because that’s it’s only value prop vs integer
simple. If you need help doing that , great. But the open ssl big number c
code hasn’t had tuning in 20 years. So you really need to do a systematic
perf comparison.
On Mon, Nov 19, 2018 at 5:47 AM simonpj ***@***.***> wrote:
> Sounds like a good work to me.
>
> But to an external observer it's very mysterious that you propose to call
> it integer-openssl. That makes it sounds as if this library is something
> to do with crypto etc. But I assume it's not. I'm guessing it's because the
> impl uses code from openssl?
>
> Anyway, some less confusing name might be worth considering. Or not. Just
> raising it because it took me some time to realise that this proposal was
> not related to crypto
>
> —
> You are receiving this because you were mentioned.
>
>
> Reply to this email directly, view it on GitHub
> <#183 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAAQwlYo1-k18lcylWPLDCkaUZCQPqXPks5uwoxLgaJpZM4Yn7kR>
> .
>
|
One of the suggested reasons for inclusion is to "allow public key algorithms". Of course you can
|
I agree with the spirit of what Piyush says :
Additionally dragging a big project like OpenSSL into ghc build deps might
have a huge cost. And for big number math per se we already have great
code.
Additionally ,
https://ghc.haskell.org/trac/ghc/wiki/Design/IntegerGmp2 paves a path
towards allowing the big num lib to be to be selected in userland , though
I think Herbert might appreciate some help pushing that along. (The gmp2
design appeal is that it moves Any new big num stuff into being feasislvd
in user space )
I guess
…On Mon, Nov 19, 2018 at 8:07 AM Piyush P Kurur ***@***.***> wrote:
One of the suggested reasons for inclusion is to "allow public key
algorithms". Of course you can
use that in the class room but not for serious crypto.
1.
Haskell requires a integer library because it provides large arbitrary
integer multiplication. But
it would be dangerous to implement pki (I am assuming RSA) based on
that. A better motivation
could be representing integers in compilers.
2.
For crypto purposes it would be sufficient (and better) to implement
say 4026 or some fixed size integers carefully done so that there are no
side channels etc.
3.
More importantly if ghc has to depend on openssl that would be a pity.
I do not think it is a good code base to depend on plus it bring out a lot
of other useless (for ghc) stuff.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwuj-SvPEaW3TcO6c2djJfMfWvEOHks5uwq0jgaJpZM4Yn7kR>
.
|
@piyush-kurur The cryptography example was given as the haskell package @cartazio Comparing the performance is definitely important and I tried to get early estimates how much faster than integer-simple and also how much slower than integer-gmp the prototypical implementation of multiplication and division is, I'll add these preliminary results to the PoC and link them in the proposal. In general I'd like to say that I took the BIGNUM implementation of openssl as it was a) BSD licensed, b) complete, c) correct and d) likely available on most systems. If we find better alternatives, I am happy to update the proposal, name and implementation to use something else :) |
My apologies if this was already clear: I think it would make the most sense to consider this as a more efficient alternative to I believe this is what the proposal as-written is proposing. Consequently, I don't think the concern that GHC will gain a dependency on OpenSSL is well-founded. |
Added a section on why openssl was chosen for a proof of concept and add criterion benchmarks from munihac.
There's also https://github.com/libtom/libtommath (edit: and https://github.com/libtom/tomsfastmath now as well), I wonder how they compare to OpenSSL's bignums. |
I started a look at libtommath. But I need to fork it to make the oss
license less asnine. I tried to reach out to the author to get it fixed
upstream and that didn’t go anywhere. Happily it’s a license that at least
in the US is easy to fork into a sane one.
…On Wed, Nov 21, 2018 at 6:21 AM Mikhail Glushenkov ***@***.***> wrote:
There's also https://github.com/libtom/libtommath, I wonder how it
compares to OpenSSL's bignums.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwksAC1Og3ktSDHBJG2liBvvzXrxFks5uxTcegaJpZM4Yn7kR>
.
|
It seems to be dually licensed now, the first one is the asinine license you mention, and the other one is public domain (like SQLite). |
Confusingling enough: public domain as a legal construct doesn’t exist is
every country. So you still want a more explicit license grant. If you
look at the homepage for SQLite, you’ll see they sell licenses for the
occasional paranoid corporate user of SQLite that basically promises they
will vigorously defend their right to give the customer the code as public
domain.
It’s a confusing footnote. But an important one none the less. Maybe I’ll
have a read of the lib Tom stuff this holiday.
…On Wed, Nov 21, 2018 at 8:34 AM Mikhail Glushenkov ***@***.***> wrote:
It seems to be dually licensed now, the first one is the asinine license
you mention, and the other one is public domain (like SQLite).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwpIjan7hIw145fLMMfCWAbMc03jeks5uxVZ6gaJpZM4Yn7kR>
.
|
libtommath looks promising as well. After a quick glance over the header, all required ops should be there.. all but one I could not find in openssl/bn so far either: integer <-> double conversion. I am not too good in maths, but in a quick chat with @hvr on monday, he mentioned that one probably does not want to do that by hand. Other than that, also got updated to what the original intention by @hvr with integer-gmp and link time selection of an integer library was. I'll try to incorporate that into the proposal Also, the https://github.com/libtom/libtommath/blob/develop/LICENSE is kinda hilarious! |
@ch1bo I also suggest libtommath, in particular since it can be vendored easily into an integer-tommath package or into GHC by copying a single c file. Concerning integer<->double conversion, I made libtom/libtommath#123 a while ago, which is not yet part of tommath unfortunately. |
@ch1bo thanks for the response. Also @bgamari thanks for clarifying that it is not |
There’s certainly tradeoffs to be made for engineering side channel proof
applied number theory.
…On Wed, Nov 21, 2018 at 11:31 AM Piyush P Kurur ***@***.***> wrote:
@ch1bo <https://github.com/ch1bo> thanks for the response. Also @bgamari
<https://github.com/bgamari> thanks for clarifying that it is not
to replace gmp. Rereading the proposal the misunderstanding was entirely
my fault.
However I am uncomfortable with having an indirect suggestion of using the
multi-precision
Integer at the haskell level for cryptography. Even when the underlying
library is designed for crypto
I think it is tricky as I am not sure how ghc moves around large integers
in its memory during GC.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwlkJoJZrq5b0TZiaRG3VFbRbaCDVks5uxX_NgaJpZM4Yn7kR>
.
|
@minad if you could help shepard that license clarification into being in master that'd be lovely :) |
(i'm a little bit too spread thin to do more than be a resource on the sidelines atm :) ) |
@cartazio I will see what I can do regarding libtommath |
17: LPGL3 -> LGPL3 44: it's BIGNUM -> its BIGNUM 46: ticks all boxes -> tick all the boxes 61: should be also possiblen -> should also be possible 77: like they do with work currently with -> like they currently are to work with 100: Cost do exist -> Costs do exist 101: depends however -> depends, however, 103: Interface changes is -> Interface changes are 130: library, where implementation is tested and benchmarked against the builtin one. -> library. Test and benchmark the implementation against the built-in one. 132: half are -> half is 135: both, -> both 141: working in progress -> work in progress
Caught a couple typos while reading
We really ought to us backpack for |
Oh: for a common signature they can all instantiate?
…On Mon, Dec 3, 2018 at 10:23 AM John Ericson ***@***.***> wrote:
We really ought to us backpack for integer-*. I'd hope with 3
implementations it would finally be worth someones time to do so.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#183 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAQwhq4BbRCIRnJwynXMNRHK23oNpY1ks5u1UHWgaJpZM4Yn7kR>
.
|
@Ericson2314 yes, this should be a perfect fit for backpack. It was also brought up by @hvr as a suggestion. I am pretty new to backpack, but I should incorporate it into the proposal.. |
Tommath changed the license to Unlicense, which is essentially public domain and similar to MIT in jurisdictions which do not recognize the concept of public domain. Furthermore additional functions were added (float conversion,...), which are also useful for a hypothetical integer-tommath. |
Since I tried this recently, here's some problems that will have to be solved:
Ideally, we'd have |
On Mon, Jan 07, 2019 at 09:28:03AM -0800, Alec Theriault wrote:
> @Ericson2314 yes, this should be a perfect fit for backpack. It was also brought up by @hvr as a suggestion.
>
> I am pretty new to backpack, but I should incorporate it into the proposal..
Since I tried this recently, here's some problems that will have to be solved:
[snip]
* `integer-simple` and `integer-gmp` don't expose quite the same
functions ([I'm working on
that](https://gitlab.haskell.org/harpocrates/ghc/commit/d0d1fd61018296c104811e06005db251e6075a8f))
I will be happy to contribute whatever little I can if there is some
one else leading the backpaciksation.
|
Would this project make sense in the context of the GSOC? See https://www.reddit.com/r/haskell/comments/ae1i6z/reminder_please_submit_gsoc_ideas/edmpgit |
Happy to have the implementation part of this as a GSoC project. If anyone here is interested in mentoring, please let me know. |
On Tue, Jan 15, 2019 at 03:38:16PM +0000, Jasper Van der Jeugt wrote:
Happy to have the implementation part of this as a GSoC project. If
anyone here is interested in mentoring, please let me know.
I can contribute towards mentoring but might not be able to put enough
time in the process. In any case if there is a successful GSoC project
please keep me updated.
|
Little activity recently, marking this as dormant. |
6b33e58
to
e7fdbc7
Compare
@harpocrates Thanks for that - this is already merged right?
Although I am a backpack noob, I gave this a try (also a while back) in here https://github.com/ch1bo/backpack-integer However with the current state of backpack adoption a first iteration without backpack sounds more realistic? |
Closing this due to inactivity, but it can be reopened when necessary. |
Finally created a MR for GHC here: https://gitlab.haskell.org/ghc/ghc/merge_requests/1677. This adds |
I have been working on a new @ch1bo if you could try to add |
@hsyl20 Your work on |
Sadly not anymore. It was initially in https://github.com/haskus/packages/tree/master/haskus-integer with some tests but a lot of things have changed since then (bug fixes, etc.).
I have some benchmarks which use I still have to integrate the QuickCheck tests into GHC's testsuite. Last time I tried, installing QuickCheck for the tests seemed to be a pain. |
Proposal to add a fast, BSD-licensed alternative for GHC's Integer type, next to currently available
integer-gmp
(default, fast and LPGL3-licensed) andinteger-simple
(slow, but pure and BSD3-licensed) implementations. Concretely, this would use OpenSSLs "BIGNUM" arbitrary size integer library contained inlibcrypto
.Rendered